diff --git a/phpunit b/phpunit index 07c45b759d..466f8fbbc2 100755 --- a/phpunit +++ b/phpunit @@ -1,11 +1,14 @@ #!/usr/bin/env php = 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) { + putenv('SYMFONY_PHPUNIT_VERSION=6.0'); +} putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit'); require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit'; diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 4057c12211..583eff0aad 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -23,14 +23,14 @@ "require-dev": { "symfony/stopwatch": "~2.8|~3.0", "symfony/dependency-injection": "~2.8|~3.0", - "symfony/form": "^3.0.5", + "symfony/form": "^3.2.5", "symfony/http-kernel": "~2.8|~3.0", "symfony/property-access": "~2.8|~3.0", "symfony/property-info": "~2.8|3.0", "symfony/proxy-manager-bridge": "~2.8|~3.0", "symfony/security": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", - "symfony/validator": "~2.8|~3.0", + "symfony/validator": "^2.8.18|^3.2.5", "symfony/translation": "~2.8|~3.0", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.4", diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt index fac5c53ae7..cd73372487 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt @@ -18,6 +18,19 @@ require_once __DIR__.'/../../bootstrap.php'; @trigger_error('root deprecation', E_USER_DEPRECATED); +eval(<<<'EOPHP' +namespace PHPUnit\Util; + +class Test +{ + public static function getGroups() + { + return array(); + } +} +EOPHP +); + class PHPUnit_Util_Test { public static function getGroups() diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php index 034d07a30f..a178ac7e89 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php @@ -11,9 +11,10 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DnsMock; -class DnsMockTest extends \PHPUnit_Framework_TestCase +class DnsMockTest extends TestCase { protected function tearDown() { diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index aa5b70fc1d..f92fa96323 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -22,7 +22,7 @@ "require-dev": { "symfony/asset": "~2.8|~3.0", "symfony/finder": "~2.8|~3.0", - "symfony/form": "~3.1.9|^3.2.2", + "symfony/form": "^3.2.5", "symfony/http-kernel": "~3.2", "symfony/polyfill-intl-icu": "~1.0", "symfony/routing": "~2.8|~3.0", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index de9c429d0a..5daeec7e4e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -23,7 +23,7 @@ "symfony/config": "~2.8|~3.0", "symfony/event-dispatcher": "~2.8|~3.0", "symfony/http-foundation": "~3.1", - "symfony/http-kernel": "~3.2.2|~3.3", + "symfony/http-kernel": "^3.2.5", "symfony/polyfill-mbstring": "~1.0", "symfony/filesystem": "~2.8|~3.0", "symfony/finder": "~2.8|~3.0", @@ -41,7 +41,7 @@ "symfony/dom-crawler": "~2.8|~3.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/security": "~2.8|~3.0", - "symfony/form": "~2.8.16|~3.1.9|^3.2.2", + "symfony/form": "^2.8.18|^3.2.5", "symfony/expression-language": "~2.8|~3.0", "symfony/process": "~2.8|~3.0", "symfony/security-core": "~3.2", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 132093452f..12a16ed7af 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -28,7 +28,7 @@ "symfony/css-selector": "~2.8|~3.0", "symfony/dom-crawler": "~2.8|~3.0", "symfony/form": "~2.8|~3.0", - "symfony/framework-bundle": "~3.1", + "symfony/framework-bundle": "^3.2.5", "symfony/http-foundation": "~2.8|~3.0", "symfony/security-acl": "~2.8|~3.0", "symfony/templating": "~2.8|~3.0", diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php index c3cbd3bef7..65a040ec7c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php @@ -13,6 +13,18 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Cache\IntegrationTests\CachePoolTest; +if (!class_exists('PHPUnit_Framework_TestCase')) { + abstract class AdapterTestCase + { + public static function setUpBeforeClass() + { + self::markTestSkipped('cache/integration-tests is not yet compatible with namespaced phpunit versions.'); + } + } + + return; +} + abstract class AdapterTestCase extends CachePoolTest { protected function setUp() diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index 43fdb627ce..cb9f0e8ea1 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -11,7 +11,8 @@ namespace Symfony\Component\Console\Tests\Logger; -use Psr\Log\Test\LoggerInterfaceTest; +use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Symfony\Component\Console\Logger\ConsoleLogger; use Symfony\Component\Console\Output\BufferedOutput; @@ -22,8 +23,9 @@ use Symfony\Component\Console\Output\OutputInterface; * Console logger test. * * @author Kévin Dunglas + * @author Jordi Boggiano */ -class ConsoleLoggerTest extends LoggerInterfaceTest +class ConsoleLoggerTest extends TestCase { /** * @var DummyOutput @@ -31,7 +33,7 @@ class ConsoleLoggerTest extends LoggerInterfaceTest protected $output; /** - * {@inheritdoc} + * @return LoggerInterface */ public function getLogger() { @@ -50,7 +52,9 @@ class ConsoleLoggerTest extends LoggerInterfaceTest } /** - * {@inheritdoc} + * Return the log messages in order. + * + * @return string[] */ public function getLogs() { @@ -101,4 +105,113 @@ class ConsoleLoggerTest extends LoggerInterfaceTest $logger->error('bar'); $this->assertTrue($logger->hasErrored()); } + + public function testImplements() + { + $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); + } + + /** + * @dataProvider provideLevelsAndMessages + */ + public function testLogsAtAllLevels($level, $message) + { + $logger = $this->getLogger(); + $logger->{$level}($message, array('user' => 'Bob')); + $logger->log($level, $message, array('user' => 'Bob')); + + $expected = array( + $level.' message of level '.$level.' with context: Bob', + $level.' message of level '.$level.' with context: Bob', + ); + $this->assertEquals($expected, $this->getLogs()); + } + + public function provideLevelsAndMessages() + { + return array( + LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), + LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), + LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), + LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), + LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), + LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), + LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), + LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), + ); + } + + /** + * @expectedException \Psr\Log\InvalidArgumentException + */ + public function testThrowsOnInvalidLevel() + { + $logger = $this->getLogger(); + $logger->log('invalid level', 'Foo'); + } + + public function testContextReplacement() + { + $logger = $this->getLogger(); + $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); + + $expected = array('info {Message {nothing} Bob Bar a}'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testObjectCastToString() + { + if (method_exists($this, 'createPartialMock')) { + $dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString')); + } else { + $dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString')); + } + $dummy->expects($this->once()) + ->method('__toString') + ->will($this->returnValue('DUMMY')); + + $this->getLogger()->warning($dummy); + + $expected = array('warning DUMMY'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testContextCanContainAnything() + { + $context = array( + 'bool' => true, + 'null' => null, + 'string' => 'Foo', + 'int' => 0, + 'float' => 0.5, + 'nested' => array('with object' => new DummyTest()), + 'object' => new \DateTime(), + 'resource' => fopen('php://memory', 'r'), + ); + + $this->getLogger()->warning('Crazy context data', $context); + + $expected = array('warning Crazy context data'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testContextExceptionKeyCanBeExceptionOrOtherValues() + { + $logger = $this->getLogger(); + $logger->warning('Random message', array('exception' => 'oops')); + $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); + + $expected = array( + 'warning Random message', + 'critical Uncaught Exception!', + ); + $this->assertEquals($expected, $this->getLogs()); + } +} + +class DummyTest +{ + public function __toString() + { + } } diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index f8b836f351..5456f2e082 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -18,14 +18,14 @@ "require": { "php": ">=5.5.9", "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/intl": "~2.8|~3.0", + "symfony/intl": "^2.8.18|^3.2.5", "symfony/options-resolver": "~2.8|~3.0", "symfony/polyfill-mbstring": "~1.0", "symfony/property-access": "~2.8|~3.0" }, "require-dev": { "doctrine/collections": "~1.0", - "symfony/validator": "~2.8|~3.0", + "symfony/validator": "^2.8.18|^3.2.5", "symfony/dependency-injection": "~2.8|~3.0", "symfony/http-foundation": "~2.8|~3.0", "symfony/http-kernel": "~2.8|~3.0", diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 25cc061a69..06f56ce074 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -25,7 +25,7 @@ "symfony/expression-language": "~2.8|~3.0", "symfony/http-foundation": "~2.8|~3.0", "symfony/ldap": "~3.1", - "symfony/validator": "~2.8|~3.0", + "symfony/validator": "^2.8.18|^3.2.5", "psr/log": "~1.0" }, "suggest": { diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 430ea54eda..20325adc18 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -35,7 +35,7 @@ "symfony/finder": "~2.8|~3.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/routing": "~2.8|~3.0", - "symfony/validator": "~2.8|~3.0", + "symfony/validator": "^2.8.18|^3.2.5", "symfony/expression-language": "~2.8|~3.0", "symfony/ldap": "~3.1", "psr/log": "~1.0" diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 71a9be9fc9..d1aed828d4 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { "symfony/config": "~2.8|~3.0", - "symfony/intl": "~2.8|~3.0", + "symfony/intl": "^2.8.18|^3.2.5", "symfony/yaml": "~2.8|~3.0", "psr/log": "~1.0" }, diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index c0feaa29a8..f17085aa98 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "symfony/http-foundation": "~2.8|~3.0", - "symfony/intl": "~2.8|~3.0", + "symfony/intl": "^2.8.18|^3.2.5", "symfony/yaml": "~2.8|~3.0", "symfony/config": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index ac573faa35..01c78a389b 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Yaml\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Inline; use Symfony\Component\Yaml\Yaml; @@ -651,10 +652,15 @@ class InlineTest extends TestCase /** * @dataProvider getInvalidBinaryData + * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testParseInvalidBinaryData($data, $expectedMessage) { - $this->setExpectedExceptionRegExp('\Symfony\Component\Yaml\Exception\ParseException', $expectedMessage); + if (method_exists($this, 'expectException')) { + $this->expectExceptionMessageRegExp($expectedMessage); + } else { + $this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage); + } Inline::parse($data); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index e111ae2485..5328b27b36 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Yaml\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Parser; @@ -1314,10 +1315,15 @@ EOT /** * @dataProvider getInvalidBinaryData + * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ public function testParseInvalidBinaryData($data, $expectedMessage) { - $this->setExpectedExceptionRegExp('\Symfony\Component\Yaml\Exception\ParseException', $expectedMessage); + if (method_exists($this, 'expectException')) { + $this->expectExceptionMessageRegExp($expectedMessage); + } else { + $this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage); + } $this->parser->parse($data); }