Skip to content

Commit

Permalink
Merge pull request #657 from phalcon/3.0.x
Browse files Browse the repository at this point in the history
3.0.1
  • Loading branch information
sergeyklay authored Aug 24, 2016
2 parents a72891b + 5b6f377 commit 82aa8c7
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
matrix:
- PHALCON_VERSION="3.0.x"
- PHALCON_VERSION="v3.0.0"
- PHALCON_VERSION="v3.0.1"

before_install:
- sudo service memcached stop
Expand Down Expand Up @@ -43,6 +44,7 @@ install:
- docker pull phalconphp/zephir:${TRAVIS_PHP_VERSION}

before_script:
- stty cols 160
- docker-compose -p incubator up -d
- sleep 1

Expand Down
5 changes: 5 additions & 0 deletions Library/Phalcon/Db/Dialect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ $data = $this->modelsManager->executeQuery(
$data = $this->modelsManager->executeQuery(
'SELECT id, name FROM App\Models\Customers WHERE FULLTEXT_MATCH_BMODE(name, description, "+CEO")'
);

// SELECT `customers`.`id`, `customers`.`name` FROM `customers` WHERE `customers`.`name` REGEXP('^John')
$data = $this->modelsManager->executeQuery(
'SELECT id, name FROM App\Models\Customers WHERE REGEXP(name, "^John")'
);
```

## Oracle
Expand Down
3 changes: 2 additions & 1 deletion Library/Phalcon/Error/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public static function register()
static::handle(new Error($options));
});

set_exception_handler(function (\Exception $e) {
set_exception_handler(function ($e) {
/** @var \Exception|\Error $e */
$options = [
'type' => $e->getCode(),
'message' => $e->getMessage(),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"squizlabs/php_codesniffer": "~2.6",
"codeception/codeception": "~2.2",
"codeception/mockery-module": "~0.2",
"codeception/aerospike-module": "~0.1",
"codeception/aerospike-module": "~1.0",
"codeception/specify": "~0.4",
"codeception/verify": "~0.3"
},
Expand Down
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ services:

aerospike:
restart: always
image: aerospike/aerospike-server
image: aerospike
container_name: incubator_aerospike
expose:
- "3000"
- "3001"
- "3002"
- "3003"
ports:
- "3000:3000"
- "3001:3001"
- "3002:3002"
- "3003:3003"
volumes:
- ./tests/_ci/aerospike.conf:/etc/aerospike/aerospike.conf

mongodb:
restart: always
Expand Down
53 changes: 53 additions & 0 deletions tests/_ci/aerospike.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
service {
user root
group root
paxos-single-replica-limit 1
pidfile /var/run/aerospike/asd.pid
service-threads 4
transaction-queues 4
transaction-threads-per-queue 4
proto-fd-max 15000
}

logging {
file /var/log/aerospike/aerospike.log {
context any info
}

console {
context any critical
}
}

network {
service {
address any
port 3000
}

heartbeat {
mode mesh
port 3002
interval 150
timeout 10
}

fabric {
port 3001
}

info {
port 3003
}
}

namespace test {
replication-factor 2
memory-size 100M
default-ttl 5d # 5 days, use 0 to never expire/evict.
storage-engine device {
file /opt/aerospike/data/test.dat
filesize 1G
data-in-memory true # Store data in memory in addition to file.
}
}
2 changes: 1 addition & 1 deletion tests/_ci/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ echo -e ""
/app/vendor/bin/phpcs --standard=PSR2 --colors --extensions=php --encoding=utf-8 Library/
result_phpcs=$?

/app/vendor/bin/codecept run "${RUN_ARGS}"
/app/vendor/bin/codecept run -vvv "${RUN_ARGS}"
result_codecept=$?

if [ ${result_codecept} -ne 0 -o ${result_phpcs} -ne 0 ];
Expand Down
27 changes: 7 additions & 20 deletions tests/unit/Annotations/Adapter/AerospikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use ReflectionProperty;
use Codeception\TestCase\Test;
use Phalcon\Annotations\Adapter\Aerospike;
use Phalcon\Cache\Backend\Aerospike as CacheBackend;

/**
* \Phalcon\Test\Annotations\Adapter\AerospikeTest
Expand All @@ -27,9 +28,6 @@
*/
class AerospikeTest extends Test
{
const BASE_CLASS = '\Phalcon\Annotations\Adapter\Aerospike';
const BACKEND_CLASS ='\Phalcon\Cache\Backend\Aerospike';

/**
* UnitTester Object
* @var UnitTester
Expand All @@ -41,35 +39,24 @@ class AerospikeTest extends Test
*/
protected function _before()
{
if (PHP_MAJOR_VERSION == 7) {
$this->markTestSkipped('The Aerospike module is not available for PHP 7 yet.');
}

if (!extension_loaded('aerospike')) {
$this->markTestSkipped('The Aerospike module is not available.');
}
}

/**
* executed after each test
*/
protected function _after()
{
}

public function testHasAerospikeProperty()
{
$this->assertClassHasAttribute('aerospike', self::BASE_CLASS);
$this->assertClassHasAttribute('aerospike', Aerospike::class);
}

public function testHasNamespaceProperty()
{
$this->assertClassHasAttribute('namespace', self::BASE_CLASS);
$this->assertClassHasAttribute('namespace', Aerospike::class);
}

public function testHasSetProperty()
{
$this->assertClassHasAttribute('set', self::BASE_CLASS);
$this->assertClassHasAttribute('set', Aerospike::class);
}

/**
Expand Down Expand Up @@ -104,21 +91,21 @@ public function testShouldGetCacheBackendThroughGetter()

$reflectedMethod = new ReflectionMethod(get_class($object), 'getCacheBackend');
$reflectedMethod->setAccessible(true);
$this->assertInstanceOf(self::BACKEND_CLASS, $reflectedMethod->invoke($object));
$this->assertInstanceOf(CacheBackend::class, $reflectedMethod->invoke($object));
}

public function testShouldGetCacheBackendThroughReflectionSetter()
{
$object = new Aerospike(['hosts' => [['addr' => TEST_AS_HOST, 'port' => TEST_AS_PORT]]]);
$mock = $this->getMock(self::BACKEND_CLASS, [], [], '', false);
$mock = $this->getMock(CacheBackend::class, [], [], '', false);

$reflectedProperty = new ReflectionProperty(get_class($object), 'aerospike');
$reflectedProperty->setAccessible(true);
$reflectedProperty->setValue($object, $mock);

$reflectedMethod = new ReflectionMethod(get_class($object), 'getCacheBackend');
$reflectedMethod->setAccessible(true);
$this->assertInstanceOf(self::BACKEND_CLASS, $reflectedMethod->invoke($object));
$this->assertInstanceOf(CacheBackend::class, $reflectedMethod->invoke($object));
}

/**
Expand Down
29 changes: 7 additions & 22 deletions tests/unit/Annotations/Adapter/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Phalcon\Test\Annotations\Adapter;

use UnitTester;
use ReflectionProperty;
use Codeception\TestCase\Test;
use Phalcon\Annotations\Adapter\Base;
use Phalcon\Cache\Backend\Memory as CacheBackend;
use Phalcon\Cache\Frontend\Data as CacheFrontend;
use Codeception\TestCase\Test;
use UnitTester;

/**
* \Phalcon\Test\Annotations\Adapter\BaseTest
Expand All @@ -27,32 +28,16 @@
*/
class BaseTest extends Test
{
const BASE_CLASS = '\Phalcon\Annotations\Adapter\Base';

/**
* UnitTester Object
* @var UnitTester
*/
protected $tester;

/**
* executed before each test
*/
protected function _before()
{
}

/**
* executed after each test
*/
protected function _after()
{
}

protected function getObject($options)
{
return $this->getMockForAbstractClass(
self::BASE_CLASS,
Base::class,
['options' => $options],
'',
true,
Expand Down Expand Up @@ -114,17 +99,17 @@ public function testConstructor($options, $expected)

public function testHasDefaultLifetime()
{
$this->assertClassHasStaticAttribute('defaultLifetime', self::BASE_CLASS);
$this->assertClassHasStaticAttribute('defaultLifetime', Base::class);
}

public function testHasDefaultPrefix()
{
$this->assertClassHasStaticAttribute('defaultPrefix', self::BASE_CLASS);
$this->assertClassHasStaticAttribute('defaultPrefix', Base::class);
}

public function testHasOptions()
{
$this->assertClassHasAttribute('options', self::BASE_CLASS);
$this->assertClassHasAttribute('options', Base::class);
}

public function providerReadWrite()
Expand Down
27 changes: 9 additions & 18 deletions tests/unit/Annotations/Adapter/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Phalcon\Test\Annotations\Adapter;

use stdClass;
use UnitTester;
use ReflectionMethod;
use ReflectionProperty;
use Phalcon\Annotations\Adapter\Memcached;
use Codeception\TestCase\Test;
use UnitTester;
use Phalcon\Cache\Backend\Libmemcached;
use Phalcon\Annotations\Adapter\Memcached;

/**
* \Phalcon\Test\Annotations\Adapter\MemcachedTest
Expand All @@ -28,9 +29,6 @@
*/
class MemcachedTest extends Test
{
const BASE_CLASS = '\Phalcon\Annotations\Adapter\Memcached';
const LIBMEMCACHED_CLASS ='\Phalcon\Cache\Backend\Libmemcached';

/**
* UnitTester Object
* @var UnitTester
Expand All @@ -47,13 +45,6 @@ protected function _before()
}
}

/**
* executed after each test
*/
protected function _after()
{
}

/**
* @expectedException \Phalcon\Annotations\Exception
* @expectedExceptionMessage No host given in options
Expand All @@ -65,17 +56,17 @@ public function testShouldCatchExceptionWhenNoHostGivenInOptions()

public function testHasDefaultPort()
{
$this->assertClassHasStaticAttribute('defaultPort', self::BASE_CLASS);
$this->assertClassHasStaticAttribute('defaultPort', Memcached::class);
}

public function testHasDefaultWeight()
{
$this->assertClassHasStaticAttribute('defaultWeight', self::BASE_CLASS);
$this->assertClassHasStaticAttribute('defaultWeight', Memcached::class);
}

public function testHasMemcached()
{
$this->assertClassHasAttribute('memcached', self::BASE_CLASS);
$this->assertClassHasAttribute('memcached', Memcached::class);
}

/**
Expand Down Expand Up @@ -110,21 +101,21 @@ public function testShouldGetCacheBackendThroughGetter()

$reflectedMethod = new ReflectionMethod(get_class($object), 'getCacheBackend');
$reflectedMethod->setAccessible(true);
$this->assertInstanceOf(self::LIBMEMCACHED_CLASS, $reflectedMethod->invoke($object));
$this->assertInstanceOf(Libmemcached::class, $reflectedMethod->invoke($object));
}

public function testShouldGetCacheBackendThroughReflectionSetter()
{
$object = new Memcached(['host' => TEST_MC_HOST]);
$mock = $this->getMock(self::LIBMEMCACHED_CLASS, [], [], '', false);
$mock = $this->getMock(Libmemcached::class, [], [], '', false);

$reflectedProperty = new ReflectionProperty(get_class($object), 'memcached');
$reflectedProperty->setAccessible(true);
$reflectedProperty->setValue($object, $mock);

$reflectedMethod = new ReflectionMethod(get_class($object), 'getCacheBackend');
$reflectedMethod->setAccessible(true);
$this->assertInstanceOf(self::LIBMEMCACHED_CLASS, $reflectedMethod->invoke($object));
$this->assertInstanceOf(Libmemcached::class, $reflectedMethod->invoke($object));
}

/**
Expand Down
Loading

0 comments on commit 82aa8c7

Please sign in to comment.