From f5c46f0ff42ac4cd2557a48a14bdb85c6f48d65f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 4 May 2017 21:07:18 +0200 Subject: [PATCH] test suite compatibility with PHPUnit 6 --- .travis.yml | 17 +++++++++-------- Tests/Factory/DiactorosFactoryTest.php | 9 +++++++-- Tests/Factory/HttpFoundationFactoryTest.php | 4 ++-- composer.json | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3008471..da2f48c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ sudo: false cache: directories: - $HOME/.composer/cache/files + - $HOME/symfony-bridge/.phpunit matrix: include: @@ -13,9 +14,9 @@ matrix: - php: 5.5 - php: 5.6 - php: 5.3 - env: deps=low + env: COMPOSER_OPTIONS="--prefer-lowest --prefer-stable" SYMFONY_DEPRECATIONS_HELPER=weak - php: 5.6 - env: deps=high + env: COMPOSER_OPTIONS="" SYMFONY_DEPRECATIONS_HELPER=weak - php: 7.0 - php: hhvm allow_failures: @@ -25,7 +26,9 @@ matrix: env: global: - deps=no - - SYMFONY_DEPRECATIONS_HELPER=weak + - SYMFONY_DEPRECATIONS_HELPER=strict + - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" + - COMPOSER_OPTIONS="--prefer-stable" before_install: - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi; @@ -37,10 +40,8 @@ before_install: install: - if [ "$TRAVIS_PHP_VERSION" != "5.3" ]; then composer require --no-update zendframework/zend-diactoros; fi; - - if [ "$deps" = "no" ]; then export SYMFONY_DEPRECATIONS_HELPER=strict; fi; - - if [ "$deps" = "no" ]; then composer --prefer-source install; fi; - - if [ "$deps" = "high" ]; then composer --prefer-source update; fi; - - if [ "$deps" = "low" ]; then composer --prefer-source --prefer-lowest --prefer-stable update; fi; + - composer update --prefer-source $COMPOSER_OPTIONS + - vendor/bin/simple-phpunit install script: - - phpunit + - vendor/bin/simple-phpunit diff --git a/Tests/Factory/DiactorosFactoryTest.php b/Tests/Factory/DiactorosFactoryTest.php index ddf0806..fbc1ce8 100644 --- a/Tests/Factory/DiactorosFactoryTest.php +++ b/Tests/Factory/DiactorosFactoryTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory; +use PHPUnit\Framework\TestCase; use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Cookie; @@ -22,7 +23,7 @@ /** * @author Kévin Dunglas */ -class DiactorosFactoryTest extends \PHPUnit_Framework_TestCase +class DiactorosFactoryTest extends TestCase { private $factory; private $tmpDir; @@ -143,7 +144,11 @@ public function testCreateResponse() $this->assertEquals('Response content.', $psrResponse->getBody()->__toString()); $this->assertEquals(202, $psrResponse->getStatusCode()); $this->assertEquals(array('2.8'), $psrResponse->getHeader('X-Symfony')); - $this->assertEquals(array('city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT; path=/; httponly'), $psrResponse->getHeader('Set-Cookie')); + + $cookieHeader = $psrResponse->getHeader('Set-Cookie'); + $this->assertInternalType('array', $cookieHeader); + $this->assertCount(1, $cookieHeader); + $this->assertRegExp('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}', $cookieHeader[0]); } public function testCreateResponseFromStreamed() diff --git a/Tests/Factory/HttpFoundationFactoryTest.php b/Tests/Factory/HttpFoundationFactoryTest.php index 47ef4e3..8790a20 100644 --- a/Tests/Factory/HttpFoundationFactoryTest.php +++ b/Tests/Factory/HttpFoundationFactoryTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory; +use PHPUnit\Framework\TestCase; use Psr\Http\Message\UploadedFileInterface; use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response; @@ -22,7 +23,7 @@ /** * @author Kévin Dunglas */ -class HttpFoundationFactoryTest extends \PHPUnit_Framework_TestCase +class HttpFoundationFactoryTest extends TestCase { /** @var HttpFoundationFactory */ private $factory; @@ -198,7 +199,6 @@ public function testCreateResponse() 'theme=light', 'test', 'ABC=AeD; Domain=dunglas.fr; Path=/kevin; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly', - ), ), new Stream('The response body'), diff --git a/composer.json b/composer.json index ad25080..90412ac 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "symfony/http-foundation": "~2.3|~3.0" }, "require-dev": { - "symfony/phpunit-bridge": "~2.7|~3.0" + "symfony/phpunit-bridge": "~3.2" }, "suggest": { "psr/http-message-implementation": "To use the HttpFoundation factory",