Skip to content

Commit

Permalink
Update tests to use namespaced SkippedTestError exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed May 28, 2018
1 parent 5227fdf commit cafc459
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 65 deletions.
5 changes: 3 additions & 2 deletions tests/_support/Helper/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Helper;

use Codeception\Actor;
use Mongo;
use MongoClient;
use Codeception\Actor;
use Phalcon\Mvc\Collection\Manager;
use PHPUnit\Framework\SkippedTestError;

/**
* Collection Initializer
Expand All @@ -22,7 +23,7 @@ trait CollectionTrait
protected function setupMongo(Actor $I)
{
if (!extension_loaded('mongo')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: mongo extension is not loaded'
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/_support/Helper/ConnectionCheckerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Phalcon\Db\Adapter;
use Phalcon\Di;
use PHPUnit\Framework\SkippedTestError;

/**
* Connection checker
Expand All @@ -24,7 +25,7 @@ protected function checkConnection(Adapter $old_conn)
$di->getShared('db');
} catch (\PDOException $e) {
$di->setShared('db', $old_conn);
throw new \PHPUnit_Framework_SkippedTestError("Unable to connect to the database: " . $e->getMessage());
throw new SkippedTestError("Unable to connect to the database: " . $e->getMessage());
}
}
}
5 changes: 3 additions & 2 deletions tests/_support/Helper/ResultsetHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Phalcon\Cache\BackendInterface;
use Phalcon\Mvc\Model\Metadata\Memory;
use Phalcon\Cache\Backend\Libmemcached;
use PHPUnit\Framework\SkippedTestError;

/**
* \Helper\ResultsetHelperTrait
Expand Down Expand Up @@ -74,7 +75,7 @@ protected function getFileCache()
protected function getMemcacheCache()
{
if (!extension_loaded('memcache')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: memcache extension is not loaded'
);
}
Expand All @@ -95,7 +96,7 @@ protected function getMemcacheCache()
protected function getLibmemcachedCache()
{
if (!extension_loaded('memcached')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: memcached extension is not loaded'
);
}
Expand Down
13 changes: 7 additions & 6 deletions tests/_support/Module/Cache/Backend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace Phalcon\Test\Module\Cache\Backend;

use Codeception\Configuration;
use Phalcon\Cache\Frontend\Data;
use Codeception\Module\Filesystem;
use Phalcon\Cache\FrontendInterface;
use Codeception\Exception\ModuleConfigException;
use Codeception\Lib\ModuleContainer;
use Phalcon\Cache\Frontend\Igbinary;
use Codeception\Module\Filesystem;
use Phalcon\Cache\Backend\File as FileBackend;
use Codeception\Exception\ModuleConfigException;
use Phalcon\Cache\Frontend\Data;
use Phalcon\Cache\Frontend\Igbinary;
use Phalcon\Cache\FrontendInterface;
use PHPUnit\Framework\SkippedTestError;

/**
* Phalcon\Test\Module\Cache\Backend\File
Expand Down Expand Up @@ -299,7 +300,7 @@ protected function getSupportedFrontends()
Igbinary::class => [
'validate_cb' => function () {
if (!extension_loaded('igbinary')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
"The 'igbinary' extension is not loaded."
);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/Mvc/Model/BinderCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Phalcon\Mvc\Model\MetaData\Memory;
use Phalcon\Test\Models\People;
use Phalcon\Test\Models\Robots;
use PHPUnit\Framework\SkippedTestError;

/**
* \Phalcon\Test\Integration\Mvc\Model\BindingCest
Expand Down Expand Up @@ -70,19 +71,19 @@ public function _before(IntegrationTester $I)
Di::setDefault($I->getApplication()->getDI());

if (!extension_loaded('apc')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc extension is not loaded'
);
}

if (!ini_get('apc.enabled') || (PHP_SAPI === 'cli' && !ini_get('apc.enable_cli'))) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc.enable_cli must be set to "On"'
);
}

if (extension_loaded('apcu') && version_compare(phpversion('apcu'), '5.1.6', '=')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: APCu v5.1.6 was broken. See: https://github.com/krakjoe/apcu/issues/203'
);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/Mvc/View/SimpleCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Phalcon\Test\Integration\Mvc\View;

use Phalcon\Di;
use IntegrationTester;
use Phalcon\Mvc\View\Simple;
use Phalcon\Cache\Backend\File;
use Phalcon\Cache\Frontend\Output;
use Phalcon\Di;
use Phalcon\Mvc\View\Simple;
use PHPUnit\Framework\SkippedTestError;

/**
* \Phalcon\Test\Integration\Mvc\View\SimpleCest
Expand Down Expand Up @@ -52,7 +53,7 @@ public function testRenderWithCache(IntegrationTester $I)
$I->wantToTest('Render by using simple view with cache');

if (PHP_MAJOR_VERSION == 7) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Skipped in view of the experimental support for PHP 7.'
);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/Cache/Backend/ApcCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Phalcon\Test\Unit\Cache\Backend;

use UnitTester;
use Phalcon\Cache\Backend\Apc;
use Phalcon\Cache\Frontend\Data;
use PHPUnit\Framework\SkippedTestError;
use UnitTester;

/**
* \Phalcon\Test\Unit\Cache\Backend\ApcCest
Expand All @@ -28,19 +29,19 @@ class ApcCest
public function _before(UnitTester $I)
{
if (!extension_loaded('apc')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc extension is not loaded'
);
}

if (!ini_get('apc.enabled') || (PHP_SAPI === 'cli' && !ini_get('apc.enable_cli'))) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc.enable_cli must be set to "On"'
);
}

if (extension_loaded('apcu') && version_compare(phpversion('apcu'), '5.1.6', '=')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: APCu v5.1.6 was broken. See: https://github.com/krakjoe/apcu/issues/203'
);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/Cache/Backend/ApcuCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Phalcon\Test\Unit\Cache\Backend;

use UnitTester;
use Phalcon\Cache\Backend\Apcu;
use Phalcon\Cache\Frontend\Data;
use PHPUnit\Framework\SkippedTestError;
use UnitTester;

/**
* \Phalcon\Test\Unit\Cache\Backend\ApcuCest
Expand All @@ -28,19 +29,19 @@ class ApcuCest
public function _before(UnitTester $I)
{
if (!extension_loaded('apcu')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: APCu extension is not loaded'
);
}

if (!ini_get('apc.enabled') || (PHP_SAPI === 'cli' && !ini_get('apc.enable_cli'))) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc.enable_cli must be set to "On"'
);
}

if (version_compare(phpversion('apcu'), '5.1.6', '=')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: APCu v5.1.6 was broken. See: https://github.com/krakjoe/apcu/issues/203'
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Cache/Backend/LibmemcachedCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Phalcon\Cache\Frontend\Data;
use Phalcon\Cache\Frontend\Output;
use Phalcon\Cache\Backend\Libmemcached;
use PHPUnit\Framework\SkippedTestError;

/**
* \Phalcon\Test\Unit\Cache\Backend\LibmemcachedCest
Expand All @@ -30,7 +31,7 @@ class LibmemcachedCest
public function _before(UnitTester $I)
{
if (!extension_loaded('memcached')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: memcached extension is not loaded'
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Cache/Backend/RedisCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Phalcon\Cache\Frontend\Data;
use Phalcon\Cache\Backend\Redis;
use Phalcon\Cache\Frontend\Output;
use PHPUnit\Framework\SkippedTestError;

/**
* \Phalcon\Test\Unit\Cache\Backend\RedisCest
Expand All @@ -32,7 +33,7 @@ public function _before(UnitTester $I)
$I->wantToTest('Redis cache backend');

if (!extension_loaded('redis')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: redis extension is not loaded'
);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Db/Adapter/Pdo/MysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Phalcon\Test\Unit\Db\Adapter\Pdo;

use Phalcon\Db;
use Helper\Dialect\MysqlTrait;
use Phalcon\Db\Adapter\Pdo\Mysql;
use Phalcon\Db\Reference;
use Phalcon\Test\Module\UnitTest;
use Phalcon\Db\Adapter\Pdo\Mysql;
use Helper\Dialect\MysqlTrait;
use PHPUnit\Framework\SkippedTestError;

/**
* \Phalcon\Test\Unit\Db\Adapter\Pdo\MysqlTest
Expand Down Expand Up @@ -48,7 +48,7 @@ public function _before()
'charset' => TEST_DB_MYSQL_CHARSET,
]);
} catch (\PDOException $e) {
throw new \PHPUnit_Framework_SkippedTestError("Unable to connect to the database: " . $e->getMessage());
throw new SkippedTestError("Unable to connect to the database: " . $e->getMessage());
}
}

Expand Down
9 changes: 5 additions & 4 deletions tests/unit/Db/Adapter/Pdo/PostgresqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Phalcon\Test\Unit\Db\Adapter\Pdo;

use Helper\Dialect\PostgresqlTrait;
use Phalcon\Db\Adapter\Pdo\Postgresql;
use Phalcon\Db\Column;
use Phalcon\Db\Dialect\Postgresql as DialectPostgresql;
use Phalcon\Db\Reference;
use Phalcon\Test\Module\UnitTest;
use Phalcon\Db\Adapter\Pdo\Postgresql;
use Phalcon\Db\Dialect\Postgresql as DialectPostgresql;
use Helper\Dialect\PostgresqlTrait;
use PHPUnit\Framework\SkippedTestError;

/**
* \Phalcon\Test\Unit\Db\Adapter\Pdo\PostgresqlTest
Expand Down Expand Up @@ -50,7 +51,7 @@ public function _before()
'schema' => TEST_DB_POSTGRESQL_SCHEMA
]);
} catch (\PDOException $e) {
throw new \PHPUnit_Framework_SkippedTestError("Unable to connect to the database: " . $e->getMessage());
throw new SkippedTestError("Unable to connect to the database: " . $e->getMessage());
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/unit/Mvc/Model/MetaData/ApcCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Phalcon\Test\Unit\Mvc\Model\MetaData;

use UnitTester;
use Phalcon\Test\Models\Robots;
use Phalcon\Mvc\Model\Metadata\Apc;
use Phalcon\Test\Models\Robots;
use PHPUnit\Framework\SkippedTestError;
use UnitTester;

/**
* \Phalcon\Test\Unit\Mvc\Model\Metadata\ApcCest
Expand All @@ -30,7 +31,7 @@ class ApcCest
public function _before(UnitTester $I)
{
if (!function_exists('apc_fetch')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc extension is not loaded'
);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/Mvc/Model/MetaData/ApcuCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Phalcon\Test\Unit\Mvc\Model\MetaData;

use UnitTester;
use Phalcon\Test\Models\Robots;
use Phalcon\Mvc\Model\Metadata\Apcu;
use Phalcon\Test\Models\Robots;
use PHPUnit\Framework\SkippedTestError;
use UnitTester;

/**
* \Phalcon\Test\Unit\Mvc\Model\Metadata\ApcuCest
Expand All @@ -31,7 +32,7 @@ class ApcuCest
public function _before(UnitTester $I)
{
if (!function_exists('apc_fetch')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: apc extension is not loaded'
);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/Mvc/Model/MetaData/LibmemcachedCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Phalcon\Test\Unit\Mvc\Model\MetaData;

use UnitTester;
use Phalcon\Test\Models\Robots;
use Phalcon\Mvc\Model\Metadata\Libmemcached;
use Phalcon\Test\Models\Robots;
use PHPUnit\Framework\SkippedTestError;
use UnitTester;

/**
* \Phalcon\Test\Unit\Mvc\Model\Metadata\LibmemcachedCest
Expand All @@ -30,7 +31,7 @@ class LibmemcachedCest
public function _before(UnitTester $I)
{
if (!class_exists('Memcached')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: Memcached class does not exist, test skipped'
);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/Mvc/Model/MetaData/RedisCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Phalcon\Test\Unit\Mvc\Model\MetaData;

use UnitTester;
use Phalcon\Test\Models\Robots;
use Phalcon\Mvc\Model\Metadata\Redis;
use Phalcon\Test\Models\Robots;
use PHPUnit\Framework\SkippedTestError;
use UnitTester;

/**
* \Phalcon\Test\Unit\Mvc\Model\Metadata\RedisCest
Expand All @@ -30,7 +31,7 @@ class RedisCest
public function _before(UnitTester $I)
{
if (!extension_loaded('redis')) {
throw new \PHPUnit_Framework_SkippedTestError(
throw new SkippedTestError(
'Warning: redis extension is not loaded'
);
}
Expand Down
Loading

0 comments on commit cafc459

Please sign in to comment.