From 3c0b441371bdb697cbfce6aba342563573c23b1f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 Oct 2015 11:03:54 +0200 Subject: [PATCH] [ci] Fix tests requirements --- .travis.yml | 2 +- appveyor.yml | 7 ++++--- .../Tests/ApcUniversalClassLoaderTest.php | 6 +++--- .../DateTimeToStringTransformerTest.php | 5 +---- .../Core/EventListener/TrimListenerTest.php | 5 +---- .../Profiler/MongoDbProfilerStorageTest.php | 17 +++++++++-------- .../Profiler/SqliteProfilerStorageTest.php | 6 +++--- .../Security/Tests/Acl/Dbal/AclProviderTest.php | 7 +++---- .../Tests/Acl/Dbal/MutableAclProviderTest.php | 7 +++---- .../Core/Encoder/BCryptPasswordEncoderTest.php | 17 ++++++----------- .../Tests/Mapping/Cache/ApcCacheTest.php | 5 ++++- 11 files changed, 38 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index e58001df17..2d1dcbfe6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_install: - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then phpenv config-rm xdebug.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - - if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; + - if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo -e "extension = apc.so\napc.enable_cli = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi; - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi; - if [ "$deps" != "skip" ]; then ./phpunit install; fi; diff --git a/appveyor.yml b/appveyor.yml index fd9153e47e..b9a95c9fd7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,8 +26,8 @@ install: - IF %PHP%==1 cd ext - IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/php_intl-3.0.0-5.3-nts-vc9-x86.zip - IF %PHP%==1 7z x php_intl-3.0.0-5.3-nts-vc9-x86.zip -y > 7z.log - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apc/3.1.13/php_apc-3.1.13-5.3-nts-vc9-x86.zip - - IF %PHP%==1 7z x php_apc-3.1.13-5.3-nts-vc9-x86.zip -y > 7z.log + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apcu/4.0.7/php_apcu-4.0.7-5.3-nts-vc9-x86.zip + - IF %PHP%==1 7z x php_apcu-4.0.7-5.3-nts-vc9-x86.zip -y > 7z.log - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/php_memcache-3.0.8-5.3-nts-vc9-x86.zip - IF %PHP%==1 7z x php_memcache-3.0.8-5.3-nts-vc9-x86.zip -y > 7z.log - IF %PHP%==1 cd .. @@ -38,7 +38,8 @@ install: - IF %PHP%==1 echo extension_dir=ext >> php.ini-min - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini-min - IF %PHP%==1 copy /Y php.ini-min php.ini-max - - IF %PHP%==1 echo extension=php_apc.dll >> php.ini-max + - IF %PHP%==1 echo extension=php_apcu.dll >> php.ini-max + - IF %PHP%==1 echo apc.enable_cli=1 >> php.ini-max - IF %PHP%==1 echo extension=php_intl.dll >> php.ini-max - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini-max - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini-max diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php index e468057f7f..40046f5530 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php @@ -20,10 +20,10 @@ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) { - $this->markTestSkipped('The apc extension is available, but not enabled.'); - } else { + if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { apc_clear_cache('user'); + } else { + $this->markTestSkipped('APC is not enabled.'); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index e50ba191d0..886d3b952a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -122,13 +122,10 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase /** * @dataProvider dataProvider + * @requires PHP 5.3.7 */ public function testReverseTransformUsingPipe($format, $input, $output) { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); - } - $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true); $output = new \DateTime($output); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php index 3818c7861f..e87f2dcd51 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php @@ -42,13 +42,10 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase /** * @dataProvider spaceProvider + * @requires extension mbstring */ public function testTrimUtf8Separators($hex) { - if (!function_exists('mb_convert_encoding')) { - $this->markTestSkipped('The "mb_convert_encoding" function is not available'); - } - // Convert hexadecimal representation into binary // H: hex string, high nibble first (UCS-2BE) // *: repeat until end of string diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php index 29525fe6bd..6550dc28d1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -47,19 +47,20 @@ class MongoDbProfilerStorageTestDataCollector extends DataCollector } } +/** + * @requires extension mongo + */ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest { protected static $storage; public static function setUpBeforeClass() { - if (extension_loaded('mongo')) { - self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400); - try { - self::$storage->getMongo(); - } catch (\MongoConnectionException $e) { - self::$storage = null; - } + self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400); + try { + self::$storage->getMongo(); + } catch (\MongoConnectionException $e) { + self::$storage = null; } } @@ -159,7 +160,7 @@ class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest if (self::$storage) { self::$storage->purge(); } else { - $this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost'); + $this->markTestSkipped('A MongoDB server on localhost is required.'); } } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php index 43546c1a16..4a1430321b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php @@ -13,6 +13,9 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler; use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage; +/** + * @requires extension pdo_sqlite + */ class SqliteProfilerStorageTest extends AbstractProfilerStorageTest { protected static $dbFile; @@ -34,9 +37,6 @@ class SqliteProfilerStorageTest extends AbstractProfilerStorageTest protected function setUp() { - if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } self::$storage->purge(); } diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php index 7ca493f70d..afbcb56dcf 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Security\Acl\Domain\ObjectIdentity; use Symfony\Component\Security\Acl\Dbal\Schema; use Doctrine\DBAL\DriverManager; +/** + * @requires extension pdo_sqlite + */ class AclProviderTest extends \PHPUnit_Framework_TestCase { protected $con; @@ -141,10 +144,6 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - self::markTestSkipped('This test requires SQLite support in your environment'); - } - $this->con = DriverManager::getConnection(array( 'driver' => 'pdo_sqlite', 'memory' => true, diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php index 00500f8779..32134062f0 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php @@ -27,6 +27,9 @@ use Symfony\Component\Security\Acl\Dbal\Schema; use Doctrine\DBAL\DriverManager; use Symfony\Component\Security\Acl\Domain\ObjectIdentity; +/** + * @requires extension pdo_sqlite + */ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase { protected $con; @@ -483,10 +486,6 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - self::markTestSkipped('This test requires SQLite support in your environment'); - } - $this->con = DriverManager::getConnection(array( 'driver' => 'pdo_sqlite', 'memory' => true, diff --git a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php index 3f8ba86467..076d954f4b 100644 --- a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php @@ -45,32 +45,27 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase } } + /** + * @requires PHP 5.3.7 + */ public function testResultLength() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); } + /** + * @requires PHP 5.3.7 + */ public function testValidation() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } - private function skipIfPhpVersionIsNotSupported() - { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Requires PHP >= 5.3.7'); - } - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php index 9db9b74061..10dafd3c21 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php @@ -13,11 +13,14 @@ namespace Symfony\Component\Validator\Tests\Mapping\Cache; use Symfony\Component\Validator\Mapping\Cache\ApcCache; +/** + * @requires extension apc + */ class ApcCacheTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - if (!ini_get('apc.enable') || !ini_get('apc.enable_cli')) { + if (!ini_get('apc.enabled') || !ini_get('apc.enable_cli')) { $this->markTestSkipped('APC is not enabled.'); } }