From 2c6328f976781c09e028cb38619b6ee901e99f68 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 28 May 2018 13:17:04 +0300 Subject: [PATCH] Update tests to use namespaced SkippedTestError exception --- tests/_support/Helper/CollectionTrait.php | 5 +-- .../Helper/ConnectionCheckerTrait.php | 3 +- .../_support/Helper/ResultsetHelperTrait.php | 5 +-- tests/_support/Module/Cache/Backend/File.php | 13 ++++---- tests/integration/Mvc/Model/BinderCest.php | 7 +++-- tests/integration/Mvc/View/SimpleCest.php | 7 +++-- tests/unit/Cache/Backend/ApcCest.php | 9 +++--- tests/unit/Cache/Backend/ApcuCest.php | 9 +++--- tests/unit/Cache/Backend/LibmemcachedCest.php | 3 +- tests/unit/Cache/Backend/RedisCest.php | 3 +- tests/unit/Db/Adapter/Pdo/MysqlTest.php | 8 ++--- tests/unit/Db/Adapter/Pdo/PostgresqlTest.php | 9 +++--- tests/unit/Mvc/Model/MetaData/ApcCest.php | 7 +++-- tests/unit/Mvc/Model/MetaData/ApcuCest.php | 7 +++-- .../Mvc/Model/MetaData/LibmemcachedCest.php | 7 +++-- tests/unit/Mvc/Model/MetaData/RedisCest.php | 7 +++-- tests/unit/Mvc/ModelTest.php | 31 ++++++++++--------- tests/unit/Translate/Adapter/GettextCest.php | 7 +++-- 18 files changed, 82 insertions(+), 65 deletions(-) diff --git a/tests/_support/Helper/CollectionTrait.php b/tests/_support/Helper/CollectionTrait.php index e15426a0d1e..b90c7a5f131 100644 --- a/tests/_support/Helper/CollectionTrait.php +++ b/tests/_support/Helper/CollectionTrait.php @@ -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 @@ -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' ); } diff --git a/tests/_support/Helper/ConnectionCheckerTrait.php b/tests/_support/Helper/ConnectionCheckerTrait.php index ba3c416c0e7..76f493538df 100644 --- a/tests/_support/Helper/ConnectionCheckerTrait.php +++ b/tests/_support/Helper/ConnectionCheckerTrait.php @@ -4,6 +4,7 @@ use Phalcon\Db\Adapter; use Phalcon\Di; +use PHPUnit\Framework\SkippedTestError; /** * Connection checker @@ -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()); } } } diff --git a/tests/_support/Helper/ResultsetHelperTrait.php b/tests/_support/Helper/ResultsetHelperTrait.php index 73440070b60..36c8da360c7 100644 --- a/tests/_support/Helper/ResultsetHelperTrait.php +++ b/tests/_support/Helper/ResultsetHelperTrait.php @@ -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 @@ -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' ); } @@ -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' ); } diff --git a/tests/_support/Module/Cache/Backend/File.php b/tests/_support/Module/Cache/Backend/File.php index 7a6d124f2cb..2e15110fd6a 100644 --- a/tests/_support/Module/Cache/Backend/File.php +++ b/tests/_support/Module/Cache/Backend/File.php @@ -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 @@ -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." ); } diff --git a/tests/integration/Mvc/Model/BinderCest.php b/tests/integration/Mvc/Model/BinderCest.php index 2938ddcc387..ca85cdcf4d3 100644 --- a/tests/integration/Mvc/Model/BinderCest.php +++ b/tests/integration/Mvc/Model/BinderCest.php @@ -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 @@ -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' ); } diff --git a/tests/integration/Mvc/View/SimpleCest.php b/tests/integration/Mvc/View/SimpleCest.php index 6eda084c8a3..94f30d7ee10 100644 --- a/tests/integration/Mvc/View/SimpleCest.php +++ b/tests/integration/Mvc/View/SimpleCest.php @@ -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 @@ -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.' ); } diff --git a/tests/unit/Cache/Backend/ApcCest.php b/tests/unit/Cache/Backend/ApcCest.php index 885a41ccb08..929cc524bc4 100644 --- a/tests/unit/Cache/Backend/ApcCest.php +++ b/tests/unit/Cache/Backend/ApcCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Cache/Backend/ApcuCest.php b/tests/unit/Cache/Backend/ApcuCest.php index 023c9fe17a0..812b426cb5f 100644 --- a/tests/unit/Cache/Backend/ApcuCest.php +++ b/tests/unit/Cache/Backend/ApcuCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Cache/Backend/LibmemcachedCest.php b/tests/unit/Cache/Backend/LibmemcachedCest.php index db35b8921da..c0722b000ee 100644 --- a/tests/unit/Cache/Backend/LibmemcachedCest.php +++ b/tests/unit/Cache/Backend/LibmemcachedCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Cache/Backend/RedisCest.php b/tests/unit/Cache/Backend/RedisCest.php index 44c39077cf5..8afce7d41ff 100644 --- a/tests/unit/Cache/Backend/RedisCest.php +++ b/tests/unit/Cache/Backend/RedisCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Db/Adapter/Pdo/MysqlTest.php b/tests/unit/Db/Adapter/Pdo/MysqlTest.php index b8eed493d7f..c98dbe7a9bf 100644 --- a/tests/unit/Db/Adapter/Pdo/MysqlTest.php +++ b/tests/unit/Db/Adapter/Pdo/MysqlTest.php @@ -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 @@ -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()); } } diff --git a/tests/unit/Db/Adapter/Pdo/PostgresqlTest.php b/tests/unit/Db/Adapter/Pdo/PostgresqlTest.php index faddb8310d1..1727edba65a 100644 --- a/tests/unit/Db/Adapter/Pdo/PostgresqlTest.php +++ b/tests/unit/Db/Adapter/Pdo/PostgresqlTest.php @@ -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 @@ -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()); } } diff --git a/tests/unit/Mvc/Model/MetaData/ApcCest.php b/tests/unit/Mvc/Model/MetaData/ApcCest.php index 78ffba3aace..9b9ba40b747 100644 --- a/tests/unit/Mvc/Model/MetaData/ApcCest.php +++ b/tests/unit/Mvc/Model/MetaData/ApcCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Mvc/Model/MetaData/ApcuCest.php b/tests/unit/Mvc/Model/MetaData/ApcuCest.php index e461517e46a..43c5916e953 100644 --- a/tests/unit/Mvc/Model/MetaData/ApcuCest.php +++ b/tests/unit/Mvc/Model/MetaData/ApcuCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Mvc/Model/MetaData/LibmemcachedCest.php b/tests/unit/Mvc/Model/MetaData/LibmemcachedCest.php index e95d34c370d..895d0c71fa0 100644 --- a/tests/unit/Mvc/Model/MetaData/LibmemcachedCest.php +++ b/tests/unit/Mvc/Model/MetaData/LibmemcachedCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Mvc/Model/MetaData/RedisCest.php b/tests/unit/Mvc/Model/MetaData/RedisCest.php index 103c8dfa686..283036033db 100644 --- a/tests/unit/Mvc/Model/MetaData/RedisCest.php +++ b/tests/unit/Mvc/Model/MetaData/RedisCest.php @@ -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 @@ -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' ); } diff --git a/tests/unit/Mvc/ModelTest.php b/tests/unit/Mvc/ModelTest.php index 261e85e95d9..39d5ede5535 100644 --- a/tests/unit/Mvc/ModelTest.php +++ b/tests/unit/Mvc/ModelTest.php @@ -4,26 +4,27 @@ use DateTime; use Helper\ModelTrait; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\Model\Message; -use Phalcon\Test\Models\ModelWithStringField; -use Phalcon\Test\Models\Users; use Phalcon\Cache\Backend\Apc; -use Phalcon\Test\Models\Robots; -use Phalcon\Mvc\Model\Exception; use Phalcon\Cache\Frontend\Data; -use Phalcon\Test\Models\Boutique; -use Phalcon\Test\Models\Packages; -use Phalcon\Test\Module\UnitTest; -use Phalcon\Test\Models\Robotters; -use Phalcon\Test\Models\Personers; -use Phalcon\Test\Models\Customers; -use Phalcon\Test\Models\PackageDetails; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\Message; use Phalcon\Mvc\Model\Resultset\Simple; +use Phalcon\Test\Models\AlbumORama\Albums; use Phalcon\Test\Models\BodyParts\Body; +use Phalcon\Test\Models\Boutique; +use Phalcon\Test\Models\Customers; +use Phalcon\Test\Models\ModelWithStringField; use Phalcon\Test\Models\News\Subscribers; -use Phalcon\Test\Models\AlbumORama\Albums; +use Phalcon\Test\Models\PackageDetails; +use Phalcon\Test\Models\Packages; +use Phalcon\Test\Models\Personers; +use Phalcon\Test\Models\Robots; +use Phalcon\Test\Models\Robotters; +use Phalcon\Test\Models\Users; use Phalcon\Test\Models\Validation; +use Phalcon\Test\Module\UnitTest; +use PHPUnit\Framework\SkippedTestError; /** * \Phalcon\Test\Unit\Mvc\ModelTest @@ -221,7 +222,7 @@ public function testSerializeSnapshotCache() } 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' ); } diff --git a/tests/unit/Translate/Adapter/GettextCest.php b/tests/unit/Translate/Adapter/GettextCest.php index 7cfaf38775a..af07ee8706e 100644 --- a/tests/unit/Translate/Adapter/GettextCest.php +++ b/tests/unit/Translate/Adapter/GettextCest.php @@ -2,8 +2,9 @@ namespace Phalcon\Test\Unit\Translate\Adapter; -use UnitTester; use Phalcon\Translate\Adapter\Gettext; +use PHPUnit\Framework\SkippedTestError; +use UnitTester; /** * \Phalcon\Test\Unit\Translate\Adapter\GettextCest @@ -31,13 +32,13 @@ class GettextCest public function _before(UnitTester $I) { if (!extension_loaded('gettext')) { - throw new \PHPUnit_Framework_SkippedTestError( + throw new SkippedTestError( 'Warning: gettext extension is not loaded' ); } if (!setlocale(LC_ALL, 'en_US.utf8')) { - throw new \PHPUnit_Framework_SkippedTestError( + throw new SkippedTestError( "Locale en_US.utf8 not enabled" ); }