Skip to content

Commit fd9ddb0

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

14 files changed

+48
-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: 14 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,11 @@
1211
use Http\HttplugBundle\Collector\StackPlugin;
1312
use Http\Promise\FulfilledPromise;
1413
use Http\Promise\RejectedPromise;
14+
use PHPUnit\Framework\TestCase;
1515
use Psr\Http\Message\RequestInterface;
1616
use Psr\Http\Message\ResponseInterface;
1717

18-
class StackPluginTest extends \PHPUnit_Framework_TestCase
18+
class StackPluginTest extends TestCase
1919
{
2020
/**
2121
* @var Collector
@@ -38,7 +38,7 @@ class StackPluginTest extends \PHPUnit_Framework_TestCase
3838
private $response;
3939

4040
/**
41-
* @var Exception
41+
* @var \Exception
4242
*/
4343
private $exception;
4444

@@ -130,6 +130,9 @@ public function testOnFulfilled()
130130
$this->assertEquals('FormattedResponse', $currentStack->getResponse());
131131
}
132132

133+
/**
134+
* @expectedException \Exception
135+
*/
133136
public function testOnRejected()
134137
{
135138
//Capture the current stack
@@ -147,8 +150,6 @@ public function testOnRejected()
147150
->method('deactivateStack')
148151
;
149152

150-
$this->setExpectedException(Exception::class);
151-
152153
$next = function () {
153154
return new RejectedPromise($this->exception);
154155
};
@@ -162,15 +163,16 @@ public function testOnRejected()
162163
$this->assertTrue($currentStack->isFailed());
163164
}
164165

166+
/**
167+
* @expectedException \Exception
168+
*/
165169
public function testOnException()
166170
{
167171
$this->collector
168172
->expects($this->once())
169173
->method('deactivateStack')
170174
;
171175

172-
$this->setExpectedException(\Exception::class);
173-
174176
$next = function () {
175177
throw new \Exception();
176178
};
@@ -179,6 +181,11 @@ public function testOnException()
179181
});
180182
}
181183

184+
/**
185+
* PHPUnit wrap any \Error into a \PHPUnit\Framework\Error\Warning
186+
*
187+
* @expectedException \PHPUnit\Framework\Error\Warning
188+
*/
182189
public function testOnError()
183190
{
184191
if (!interface_exists(\Throwable::class)) {
@@ -190,9 +197,6 @@ public function testOnError()
190197
->method('deactivateStack')
191198
;
192199

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

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)