diff --git a/.travis.yml b/.travis.yml index 508f6654..5238a8b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,11 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 env: - - TEST_COMMAND="composer test" + global: + - TEST_COMMAND="composer test" branches: except: @@ -24,7 +26,7 @@ matrix: include: - php: 5.5 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - - php: 7.1 + - php: 7.2 env: DEPENDENCIES=dev - php: hhvm dist: trusty @@ -35,6 +37,7 @@ matrix: before_install: - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; - if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; + - if [ $COVERAGE != true ]; then phpenv config-rm xdebug.ini; fi; install: - travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 6f9f5aea..107e8c42 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -470,15 +470,19 @@ private function createAuthenticationPluginNode() switch ($config['type']) { case 'basic': $this->validateAuthenticationType(['username', 'password'], $config, 'basic'); + break; case 'bearer': $this->validateAuthenticationType(['token'], $config, 'bearer'); + break; case 'service': $this->validateAuthenticationType(['service'], $config, 'service'); + break; case 'wsse': $this->validateAuthenticationType(['username', 'password'], $config, 'wsse'); + break; } diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php index c6753d1f..6f5df8f1 100644 --- a/DependencyInjection/HttplugExtension.php +++ b/DependencyInjection/HttplugExtension.php @@ -274,7 +274,8 @@ private function configureClient(ContainerBuilder $container, $clientName, array $plugins = []; foreach ($arguments['plugins'] as $plugin) { - list($pluginName, $pluginConfig) = each($plugin); + $pluginName = key($plugin); + $pluginConfig = current($plugin); if ('reference' === $pluginName) { $plugins[] = $pluginConfig['id']; } elseif ('authentication' === $pluginName) { diff --git a/Tests/Functional/ProfilingTest.php b/Tests/Functional/ProfilingTest.php index 1a06e535..60f9d40b 100644 --- a/Tests/Functional/ProfilingTest.php +++ b/Tests/Functional/ProfilingTest.php @@ -15,11 +15,12 @@ use Http\Message\Formatter\CurlCommandFormatter; use Http\Message\Formatter\FullHttpMessageFormatter; use Http\Mock\Client; +use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Stopwatch\Stopwatch; -class ProfilingTest extends \PHPUnit_Framework_TestCase +class ProfilingTest extends TestCase { /** * @var Collector @@ -63,14 +64,15 @@ public function testProfilingWithCachePlugin() $this->assertEquals('example.com', $stack->getRequestHost()); } + /** + * @expectedException \Exception + */ public function testProfilingWhenPluginThrowException() { $client = $this->createClient([ new ExceptionThrowerPlugin(), ]); - $this->setExpectedException(\Exception::class); - try { $client->sendRequest(new Request('GET', 'https://example.com')); } finally { diff --git a/Tests/Unit/ClientFactory/BuzzFactoryTest.php b/Tests/Unit/ClientFactory/BuzzFactoryTest.php index 8e3e0691..e427c669 100644 --- a/Tests/Unit/ClientFactory/BuzzFactoryTest.php +++ b/Tests/Unit/ClientFactory/BuzzFactoryTest.php @@ -5,11 +5,12 @@ use Http\Adapter\Buzz\Client; use Http\HttplugBundle\ClientFactory\BuzzFactory; use Http\Message\MessageFactory; +use PHPUnit\Framework\TestCase; /** * @author Tobias Nyholm */ -class BuzzFactoryTest extends \PHPUnit_Framework_TestCase +class BuzzFactoryTest extends TestCase { public function testCreateClient() { diff --git a/Tests/Unit/ClientFactory/CurlFactoryTest.php b/Tests/Unit/ClientFactory/CurlFactoryTest.php index 803233ec..5016b436 100644 --- a/Tests/Unit/ClientFactory/CurlFactoryTest.php +++ b/Tests/Unit/ClientFactory/CurlFactoryTest.php @@ -6,11 +6,12 @@ use Http\Client\Curl\Client; use Http\Message\MessageFactory; use Http\Message\StreamFactory; +use PHPUnit\Framework\TestCase; /** * @author Tobias Nyholm */ -class CurlFactoryTest extends \PHPUnit_Framework_TestCase +class CurlFactoryTest extends TestCase { public function testCreateClient() { diff --git a/Tests/Unit/ClientFactory/Guzzle6FactoryTest.php b/Tests/Unit/ClientFactory/Guzzle6FactoryTest.php index 08222147..b818bb17 100644 --- a/Tests/Unit/ClientFactory/Guzzle6FactoryTest.php +++ b/Tests/Unit/ClientFactory/Guzzle6FactoryTest.php @@ -4,11 +4,12 @@ use Http\HttplugBundle\ClientFactory\Guzzle6Factory; use Http\Adapter\Guzzle6\Client; +use PHPUnit\Framework\TestCase; /** * @author Tobias Nyholm */ -class Guzzle6FactoryTest extends \PHPUnit_Framework_TestCase +class Guzzle6FactoryTest extends TestCase { public function testCreateClient() { diff --git a/Tests/Unit/ClientFactory/ReactFactoryTest.php b/Tests/Unit/ClientFactory/ReactFactoryTest.php index c9117797..7f5d728b 100644 --- a/Tests/Unit/ClientFactory/ReactFactoryTest.php +++ b/Tests/Unit/ClientFactory/ReactFactoryTest.php @@ -5,11 +5,12 @@ use Http\Adapter\React\Client; use Http\HttplugBundle\ClientFactory\ReactFactory; use Http\Message\MessageFactory; +use PHPUnit\Framework\TestCase; /** * @author Tobias Nyholm */ -class ReactFactoryTest extends \PHPUnit_Framework_TestCase +class ReactFactoryTest extends TestCase { public function testCreateClient() { diff --git a/Tests/Unit/ClientFactory/SocketFactoryTest.php b/Tests/Unit/ClientFactory/SocketFactoryTest.php index 613e9a55..8fc6b89c 100644 --- a/Tests/Unit/ClientFactory/SocketFactoryTest.php +++ b/Tests/Unit/ClientFactory/SocketFactoryTest.php @@ -5,11 +5,12 @@ use Http\Client\Socket\Client; use Http\HttplugBundle\ClientFactory\SocketFactory; use Http\Message\MessageFactory; +use PHPUnit\Framework\TestCase; /** * @author Tobias Nyholm */ -class SocketFactoryTest extends \PHPUnit_Framework_TestCase +class SocketFactoryTest extends TestCase { public function testCreateClient() { diff --git a/Tests/Unit/Collector/CollectorTest.php b/Tests/Unit/Collector/CollectorTest.php index 54c5a21e..7bd8766a 100644 --- a/Tests/Unit/Collector/CollectorTest.php +++ b/Tests/Unit/Collector/CollectorTest.php @@ -4,8 +4,9 @@ use Http\HttplugBundle\Collector\Collector; use Http\HttplugBundle\Collector\Stack; +use PHPUnit\Framework\TestCase; -class CollectorTest extends \PHPUnit_Framework_TestCase +class CollectorTest extends TestCase { public function testCollectClientNames() { diff --git a/Tests/Unit/Collector/FormatterTest.php b/Tests/Unit/Collector/FormatterTest.php index 270ea3f5..a8e4c320 100644 --- a/Tests/Unit/Collector/FormatterTest.php +++ b/Tests/Unit/Collector/FormatterTest.php @@ -9,8 +9,9 @@ use Http\HttplugBundle\Collector\Formatter; use Http\Message\Formatter as MessageFormatter; use Http\Message\Formatter\CurlCommandFormatter; +use PHPUnit\Framework\TestCase; -class FormatterTest extends \PHPUnit_Framework_TestCase +class FormatterTest extends TestCase { /** * @var MessageFormatter diff --git a/Tests/Unit/Collector/ProfileClientFactoryTest.php b/Tests/Unit/Collector/ProfileClientFactoryTest.php index aeb58c5e..507704e9 100644 --- a/Tests/Unit/Collector/ProfileClientFactoryTest.php +++ b/Tests/Unit/Collector/ProfileClientFactoryTest.php @@ -8,9 +8,10 @@ use Http\HttplugBundle\Collector\Formatter; use Http\HttplugBundle\Collector\ProfileClient; use Http\HttplugBundle\Collector\ProfileClientFactory; +use PHPUnit\Framework\TestCase; use Symfony\Component\Stopwatch\Stopwatch; -class ProfileClientFactoryTest extends \PHPUnit_Framework_TestCase +class ProfileClientFactoryTest extends TestCase { /** * @var Collector diff --git a/Tests/Unit/Collector/ProfileClientTest.php b/Tests/Unit/Collector/ProfileClientTest.php index 9dbe1896..121015bb 100644 --- a/Tests/Unit/Collector/ProfileClientTest.php +++ b/Tests/Unit/Collector/ProfileClientTest.php @@ -14,13 +14,14 @@ use Http\Promise\FulfilledPromise; use Http\Promise\Promise; use Http\Promise\RejectedPromise; +use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\UriInterface; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Stopwatch\StopwatchEvent; -class ProfileClientTest extends \PHPUnit_Framework_TestCase +class ProfileClientTest extends TestCase { /** * @var Collector diff --git a/Tests/Unit/Collector/ProfilePluginTest.php b/Tests/Unit/Collector/ProfilePluginTest.php index d82eb291..7a06a527 100644 --- a/Tests/Unit/Collector/ProfilePluginTest.php +++ b/Tests/Unit/Collector/ProfilePluginTest.php @@ -13,10 +13,11 @@ use Http\Promise\FulfilledPromise; use Http\Promise\Promise; use Http\Promise\RejectedPromise; +use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class ProfilePluginTest extends \PHPUnit_Framework_TestCase +class ProfilePluginTest extends TestCase { /** * @var Plugin @@ -167,10 +168,11 @@ public function testOnFulfilled() $this->assertEquals('FormattedResponse', $profile->getResponse()); } + /** + * @expectedException \Http\Client\Exception\TransferException + */ public function testOnRejected() { - $this->setExpectedException(TransferException::class); - $promise = $this->subject->handleRequest($this->request, function () { return $this->rejectedPromise; }, function () { diff --git a/Tests/Unit/Collector/StackPluginTest.php b/Tests/Unit/Collector/StackPluginTest.php index a2a0e826..fd56b8f1 100644 --- a/Tests/Unit/Collector/StackPluginTest.php +++ b/Tests/Unit/Collector/StackPluginTest.php @@ -2,7 +2,6 @@ namespace Http\HttplugBundle\Tests\Unit\Collector; -use Exception; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Http\Client\Exception\HttpException; @@ -12,10 +11,12 @@ use Http\HttplugBundle\Collector\StackPlugin; use Http\Promise\FulfilledPromise; use Http\Promise\RejectedPromise; +use PHPUnit\Framework\Error\Warning; +use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class StackPluginTest extends \PHPUnit_Framework_TestCase +class StackPluginTest extends TestCase { /** * @var Collector @@ -38,7 +39,7 @@ class StackPluginTest extends \PHPUnit_Framework_TestCase private $response; /** - * @var Exception + * @var \Exception */ private $exception; @@ -130,6 +131,9 @@ public function testOnFulfilled() $this->assertEquals('FormattedResponse', $currentStack->getResponse()); } + /** + * @expectedException \Exception + */ public function testOnRejected() { //Capture the current stack @@ -147,8 +151,6 @@ public function testOnRejected() ->method('deactivateStack') ; - $this->setExpectedException(Exception::class); - $next = function () { return new RejectedPromise($this->exception); }; @@ -162,6 +164,9 @@ public function testOnRejected() $this->assertTrue($currentStack->isFailed()); } + /** + * @expectedException \Exception + */ public function testOnException() { $this->collector @@ -169,8 +174,6 @@ public function testOnException() ->method('deactivateStack') ; - $this->setExpectedException(\Exception::class); - $next = function () { throw new \Exception(); }; @@ -181,18 +184,18 @@ public function testOnException() public function testOnError() { - if (!interface_exists(\Throwable::class)) { + if (PHP_VERSION_ID <= 70000) { $this->markTestSkipped(); } + //PHPUnit wrap any \Error into a \PHPUnit\Framework\Error\Warning. + $this->expectException(Warning::class); + $this->collector ->expects($this->once()) ->method('deactivateStack') ; - //PHPUnit wrap any \Error into a \PHPUnit_Framework_Error. So we are expecting the - $this->setExpectedException(\PHPUnit_Framework_Error::class); - $next = function () { return 2 / 0; }; diff --git a/Tests/Unit/Discovery/ConfiguredClientsStrategyTest.php b/Tests/Unit/Discovery/ConfiguredClientsStrategyTest.php index 68de9997..5be7868b 100644 --- a/Tests/Unit/Discovery/ConfiguredClientsStrategyTest.php +++ b/Tests/Unit/Discovery/ConfiguredClientsStrategyTest.php @@ -5,8 +5,9 @@ use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Http\HttplugBundle\Discovery\ConfiguredClientsStrategy; +use PHPUnit\Framework\TestCase; -class ConfiguredClientsStrategyTest extends \PHPUnit_Framework_TestCase +class ConfiguredClientsStrategyTest extends TestCase { public function testGetCandidates() { diff --git a/composer.json b/composer.json index 76a8746a..920137b1 100644 --- a/composer.json +++ b/composer.json @@ -29,10 +29,11 @@ "php-http/message": "^1.4", "php-http/discovery": "^1.0", "twig/twig": "^1.18 || ^2.0", - "symfony/asset": "^2.8 || ^3.0" + "symfony/asset": "^2.8 || ^3.0", + "symfony/symfony": "2.8.27" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.4", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.1", "phpunit/php-token-stream": "^1.1.8", "php-http/curl-client": "^1.0", "php-http/socket-client": "^1.0", @@ -49,7 +50,7 @@ "symfony/browser-kit": "^2.8 || ^3.0", "symfony/dom-crawler": "^2.8 || ^3.0", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "matthiasnoback/symfony-dependency-injection-test": "^1.0", + "matthiasnoback/symfony-dependency-injection-test": "^1.0 || ^2.0", "nyholm/nsa": "^1.1" }, "conflict": { @@ -60,6 +61,11 @@ "Http\\HttplugBundle\\": "" } }, + "autoload-dev": { + "classmap": [ + "Tests/Resources/app/AppKernel.php" + ] + }, "scripts": { "test": "vendor/bin/phpunit", "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b548381d..0bf66029 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -28,5 +28,6 @@ +