Skip to content

Commit 4306195

Browse files
monobookdbu
authored andcommitted
Fix deprecated plugin interface (#2)
* fixed namespace * fixed tests * fixed autoload * changed getMockBuilder to createMock
1 parent 4cf4e01 commit 4306195

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
"email": "jerome@gamez.name"
1111
}
1212
],
13-
"require-dev": {
13+
"require": {
1414
"php": "^5.6|^7.0",
1515
"php-http/plugins": "^1.0",
16+
"guzzlehttp/psr7": "^1.2"
17+
},
18+
"require-dev": {
1619
"phpunit/phpunit": "^5.2",
17-
"guzzlehttp/psr7": "^1.2",
1820
"mikey179/vfsStream": "^1.6"
1921
},
20-
"autoload-dev": {
22+
"autoload": {
2123
"psr-4": {
2224
"Http\\Client\\Plugin\\Vcr\\": "src"
2325
}

src/VcrPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Http\Client\Plugin\Vcr;
44

5-
use Http\Client\Plugin\Plugin;
5+
use Http\Client\Common\Plugin;
66
use Http\Client\Plugin\Vcr\Exception\CannotBeReplayed;
77
use Http\Client\Plugin\Vcr\Exception\NotFound;
88
use Http\Promise\FulfilledPromise;
@@ -13,7 +13,9 @@
1313
class VcrPlugin implements Plugin
1414
{
1515
const HEADER_VCR = 'X-VCR';
16+
1617
const HEADER_VCR_REPLAY = 'replay';
18+
1719
const HEADER_VCR_RECORDED = 'recorded';
1820

1921
/**

tests/TrackTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class TrackTest extends VcrTestCase
3333

3434
protected function setUp()
3535
{
36-
$this->request = $this->getMock(RequestInterface::class);
37-
$this->response = $this->getMock(ResponseInterface::class);
36+
$this->request = $this->createMock(RequestInterface::class);
37+
$this->response = $this->createMock(ResponseInterface::class);
3838
$this->exception = new \Exception();
3939

4040
$this->track = Track::create($this->request);
@@ -69,7 +69,7 @@ public function testWithException()
6969

7070
public function testResponseBodyIsRewound()
7171
{
72-
$body = $this->getMock(StreamInterface::class);
72+
$body = $this->createMock(StreamInterface::class);
7373
$this->response->expects($this->once())->method('getBody')->willReturn($body);
7474

7575
$this->track->setResponse($this->response);

tests/VcrClientTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ class VcrClientTest extends VcrTestCase
2828

2929
protected function setUp()
3030
{
31-
$this->vcr = $this->getMockBuilder(Vcr::class)->getMock();
32-
$this->client = $this->getMock(ClientImplementation::class);
31+
$this->vcr = $this->createMock(Vcr::class);
32+
$this->client = $this->createMock(ClientImplementation::class);
3333
$this->vcrClient = new VcrClient($this->client, $this->vcr);
3434
}
3535

3636
public function testSendRequest()
3737
{
38-
$request = $this->getMock(RequestInterface::class);
39-
$response = $this->getMock(ResponseInterface::class);
38+
$request = $this->createMock(RequestInterface::class);
39+
$response = $this->createMock(ResponseInterface::class);
4040

4141
$this->client->expects($this->once())->method('sendRequest')->with($request)->willReturn($response);
4242

@@ -45,8 +45,8 @@ public function testSendRequest()
4545

4646
public function testSendAsyncRequest()
4747
{
48-
$request = $this->getMock(RequestInterface::class);
49-
$response = $this->getMock(ResponseInterface::class);
48+
$request = $this->createMock(RequestInterface::class);
49+
$response = $this->createMock(ResponseInterface::class);
5050
$fulfilledPromise = new FulfilledPromise($response);
5151

5252
$this->client->expects($this->once())->method('sendAsyncRequest')->with($request)->willReturn($fulfilledPromise);

tests/VcrPluginTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class VcrPluginTest extends VcrTestCase
4141

4242
protected function setUp()
4343
{
44-
$this->request = $this->getMock(RequestInterface::class);
44+
$this->request = $this->createMock(RequestInterface::class);
4545

4646
$this->track = $this->getMockBuilder(Track::class)->disableOriginalConstructor()->getMock();
4747
$this->track
@@ -103,7 +103,7 @@ public function testReplayException()
103103

104104
$promise = $this->plugin->handleRequest(
105105
$this->request,
106-
$this->fulfilledPromise($this->getMock(ResponseInterface::class)),
106+
$this->fulfilledPromise($this->createMock(ResponseInterface::class)),
107107
$this->rejectedPromise($exception)
108108
);
109109

tests/VcrTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class VcrTest extends VcrTestCase
2727

2828
protected function setUp()
2929
{
30-
$this->storage = $this->getMock(Storage::class);
30+
$this->storage = $this->createMock(Storage::class);
3131
$this->tape = $this->getMockBuilder(Tape::class)->disableOriginalConstructor()->getMock();
3232

3333
$this->vcr = Vcr::createWithStorage($this->storage);

0 commit comments

Comments
 (0)