Skip to content

Commit 81efd33

Browse files
committed
add support for PHPUnit 6
1 parent cf5a957 commit 81efd33

14 files changed

+47
-29
lines changed

Tests/Functional/ProfilingTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
use Http\Message\Formatter\CurlCommandFormatter;
1616
use Http\Message\Formatter\FullHttpMessageFormatter;
1717
use Http\Mock\Client;
18+
use PHPUnit\Framework\TestCase;
1819
use Psr\Http\Message\RequestInterface;
1920
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2021
use Symfony\Component\Stopwatch\Stopwatch;
2122

22-
class ProfilingTest extends \PHPUnit_Framework_TestCase
23+
class ProfilingTest extends TestCase
2324
{
2425
/**
2526
* @var Collector
@@ -63,14 +64,15 @@ public function testProfilingWithCachePlugin()
6364
$this->assertEquals('example.com', $stack->getRequestHost());
6465
}
6566

67+
/**
68+
* @expectedException \Exception
69+
*/
6670
public function testProfilingWhenPluginThrowException()
6771
{
6872
$client = $this->createClient([
6973
new ExceptionThrowerPlugin(),
7074
]);
7175

72-
$this->setExpectedException(\Exception::class);
73-
7476
try {
7577
$client->sendRequest(new Request('GET', 'https://example.com'));
7678
} finally {

Tests/Unit/ClientFactory/BuzzFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
use Http\Adapter\Buzz\Client;
66
use Http\HttplugBundle\ClientFactory\BuzzFactory;
77
use Http\Message\MessageFactory;
8+
use PHPUnit\Framework\TestCase;
89

910
/**
1011
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1112
*/
12-
class BuzzFactoryTest extends \PHPUnit_Framework_TestCase
13+
class BuzzFactoryTest extends TestCase
1314
{
1415
public function testCreateClient()
1516
{

Tests/Unit/ClientFactory/CurlFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
use Http\Client\Curl\Client;
77
use Http\Message\MessageFactory;
88
use Http\Message\StreamFactory;
9+
use PHPUnit\Framework\TestCase;
910

1011
/**
1112
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1213
*/
13-
class CurlFactoryTest extends \PHPUnit_Framework_TestCase
14+
class CurlFactoryTest extends TestCase
1415
{
1516
public function testCreateClient()
1617
{

Tests/Unit/ClientFactory/Guzzle6FactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
use Http\HttplugBundle\ClientFactory\Guzzle6Factory;
66
use Http\Adapter\Guzzle6\Client;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1011
*/
11-
class Guzzle6FactoryTest extends \PHPUnit_Framework_TestCase
12+
class Guzzle6FactoryTest extends TestCase
1213
{
1314
public function testCreateClient()
1415
{

Tests/Unit/ClientFactory/ReactFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
use Http\Adapter\React\Client;
66
use Http\HttplugBundle\ClientFactory\ReactFactory;
77
use Http\Message\MessageFactory;
8+
use PHPUnit\Framework\TestCase;
89

910
/**
1011
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1112
*/
12-
class ReactFactoryTest extends \PHPUnit_Framework_TestCase
13+
class ReactFactoryTest extends TestCase
1314
{
1415
public function testCreateClient()
1516
{

Tests/Unit/ClientFactory/SocketFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
use Http\Client\Socket\Client;
66
use Http\HttplugBundle\ClientFactory\SocketFactory;
77
use Http\Message\MessageFactory;
8+
use PHPUnit\Framework\TestCase;
89

910
/**
1011
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1112
*/
12-
class SocketFactoryTest extends \PHPUnit_Framework_TestCase
13+
class SocketFactoryTest extends TestCase
1314
{
1415
public function testCreateClient()
1516
{

Tests/Unit/Collector/CollectorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
use Http\HttplugBundle\Collector\Collector;
66
use Http\HttplugBundle\Collector\Stack;
7+
use PHPUnit\Framework\TestCase;
78

8-
class CollectorTest extends \PHPUnit_Framework_TestCase
9+
class CollectorTest extends TestCase
910
{
1011
public function testCollectClientNames()
1112
{

Tests/Unit/Collector/FormatterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
use Http\HttplugBundle\Collector\Formatter;
1010
use Http\Message\Formatter as MessageFormatter;
1111
use Http\Message\Formatter\CurlCommandFormatter;
12+
use PHPUnit\Framework\TestCase;
1213

13-
class FormatterTest extends \PHPUnit_Framework_TestCase
14+
class FormatterTest extends TestCase
1415
{
1516
/**
1617
* @var MessageFormatter

Tests/Unit/Collector/ProfileClientFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
use Http\HttplugBundle\Collector\Formatter;
99
use Http\HttplugBundle\Collector\ProfileClient;
1010
use Http\HttplugBundle\Collector\ProfileClientFactory;
11+
use PHPUnit\Framework\TestCase;
1112
use Symfony\Component\Stopwatch\Stopwatch;
1213

13-
class ProfileClientFactoryTest extends \PHPUnit_Framework_TestCase
14+
class ProfileClientFactoryTest extends TestCase
1415
{
1516
/**
1617
* @var Collector

Tests/Unit/Collector/ProfileClientTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
use Http\Promise\FulfilledPromise;
1515
use Http\Promise\Promise;
1616
use Http\Promise\RejectedPromise;
17+
use PHPUnit\Framework\TestCase;
1718
use Psr\Http\Message\RequestInterface;
1819
use Psr\Http\Message\ResponseInterface;
1920
use Psr\Http\Message\UriInterface;
2021
use Symfony\Component\Stopwatch\Stopwatch;
2122
use Symfony\Component\Stopwatch\StopwatchEvent;
2223

23-
class ProfileClientTest extends \PHPUnit_Framework_TestCase
24+
class ProfileClientTest extends TestCase
2425
{
2526
/**
2627
* @var Collector

Tests/Unit/Collector/ProfilePluginTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
use Http\Promise\FulfilledPromise;
1414
use Http\Promise\Promise;
1515
use Http\Promise\RejectedPromise;
16+
use PHPUnit\Framework\TestCase;
1617
use Psr\Http\Message\RequestInterface;
1718
use Psr\Http\Message\ResponseInterface;
1819

19-
class ProfilePluginTest extends \PHPUnit_Framework_TestCase
20+
class ProfilePluginTest extends TestCase
2021
{
2122
/**
2223
* @var Plugin
@@ -167,10 +168,11 @@ public function testOnFulfilled()
167168
$this->assertEquals('FormattedResponse', $profile->getResponse());
168169
}
169170

171+
/**
172+
* @expectedException \Http\Client\Exception\TransferException
173+
*/
170174
public function testOnRejected()
171175
{
172-
$this->setExpectedException(TransferException::class);
173-
174176
$promise = $this->subject->handleRequest($this->request, function () {
175177
return $this->rejectedPromise;
176178
}, function () {

Tests/Unit/Collector/StackPluginTest.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Http\HttplugBundle\Tests\Unit\Collector;
44

5-
use Exception;
65
use GuzzleHttp\Psr7\Request;
76
use GuzzleHttp\Psr7\Response;
87
use Http\Client\Exception\HttpException;
@@ -12,10 +11,12 @@
1211
use Http\HttplugBundle\Collector\StackPlugin;
1312
use Http\Promise\FulfilledPromise;
1413
use Http\Promise\RejectedPromise;
14+
use PHPUnit\Framework\Error\Warning;
15+
use PHPUnit\Framework\TestCase;
1516
use Psr\Http\Message\RequestInterface;
1617
use Psr\Http\Message\ResponseInterface;
1718

18-
class StackPluginTest extends \PHPUnit_Framework_TestCase
19+
class StackPluginTest extends TestCase
1920
{
2021
/**
2122
* @var Collector
@@ -38,7 +39,7 @@ class StackPluginTest extends \PHPUnit_Framework_TestCase
3839
private $response;
3940

4041
/**
41-
* @var Exception
42+
* @var \Exception
4243
*/
4344
private $exception;
4445

@@ -130,6 +131,9 @@ public function testOnFulfilled()
130131
$this->assertEquals('FormattedResponse', $currentStack->getResponse());
131132
}
132133

134+
/**
135+
* @expectedException \Exception
136+
*/
133137
public function testOnRejected()
134138
{
135139
//Capture the current stack
@@ -147,8 +151,6 @@ public function testOnRejected()
147151
->method('deactivateStack')
148152
;
149153

150-
$this->setExpectedException(Exception::class);
151-
152154
$next = function () {
153155
return new RejectedPromise($this->exception);
154156
};
@@ -162,15 +164,16 @@ public function testOnRejected()
162164
$this->assertTrue($currentStack->isFailed());
163165
}
164166

167+
/**
168+
* @expectedException \Exception
169+
*/
165170
public function testOnException()
166171
{
167172
$this->collector
168173
->expects($this->once())
169174
->method('deactivateStack')
170175
;
171176

172-
$this->setExpectedException(\Exception::class);
173-
174177
$next = function () {
175178
throw new \Exception();
176179
};
@@ -185,14 +188,14 @@ public function testOnError()
185188
$this->markTestSkipped();
186189
}
187190

191+
//PHPUnit wrap any \Error into a \PHPUnit\Framework\Error\Warning.
192+
$this->expectException(Warning::class);
193+
188194
$this->collector
189195
->expects($this->once())
190196
->method('deactivateStack')
191197
;
192198

193-
//PHPUnit wrap any \Error into a \PHPUnit_Framework_Error. So we are expecting the
194-
$this->setExpectedException(\PHPUnit_Framework_Error::class);
195-
196199
$next = function () {
197200
return 2 / 0;
198201
};

Tests/Unit/Discovery/ConfiguredClientsStrategyTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
use Http\Client\HttpAsyncClient;
66
use Http\Client\HttpClient;
77
use Http\HttplugBundle\Discovery\ConfiguredClientsStrategy;
8+
use PHPUnit\Framework\TestCase;
89

9-
class ConfiguredClientsStrategyTest extends \PHPUnit_Framework_TestCase
10+
class ConfiguredClientsStrategyTest extends TestCase
1011
{
1112
public function testGetCandidates()
1213
{

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
"php-http/message": "^1.4",
3030
"php-http/discovery": "^1.0",
3131
"twig/twig": "^1.18 || ^2.0",
32-
"symfony/asset": "^2.8 || ^3.0"
32+
"symfony/asset": "^2.8 || ^3.0",
33+
"symfony/symfony": "2.8.27"
3334
},
3435
"require-dev": {
35-
"phpunit/phpunit": "^4.5 || ^5.4",
36+
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.1",
3637
"phpunit/php-token-stream": "^1.1.8",
3738
"php-http/curl-client": "^1.0",
3839
"php-http/socket-client": "^1.0",
@@ -49,7 +50,7 @@
4950
"symfony/browser-kit": "^2.8 || ^3.0",
5051
"symfony/dom-crawler": "^2.8 || ^3.0",
5152
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
52-
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
53+
"matthiasnoback/symfony-dependency-injection-test": "^1.0 || ^2.0",
5354
"nyholm/nsa": "^1.1"
5455
},
5556
"conflict": {

0 commit comments

Comments
 (0)