Skip to content

Fix deprecated plugin interface #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
"email": "jerome@gamez.name"
}
],
"require-dev": {
"require": {
"php": "^5.6|^7.0",
"php-http/plugins": "^1.0",
"guzzlehttp/psr7": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^5.2",
"guzzlehttp/psr7": "^1.2",
"mikey179/vfsStream": "^1.6"
},
"autoload-dev": {
"autoload": {
"psr-4": {
"Http\\Client\\Plugin\\Vcr\\": "src"
}
Expand Down
4 changes: 3 additions & 1 deletion src/VcrPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Http\Client\Plugin\Vcr;

use Http\Client\Plugin\Plugin;
use Http\Client\Common\Plugin;
use Http\Client\Plugin\Vcr\Exception\CannotBeReplayed;
use Http\Client\Plugin\Vcr\Exception\NotFound;
use Http\Promise\FulfilledPromise;
Expand All @@ -13,7 +13,9 @@
class VcrPlugin implements Plugin
{
const HEADER_VCR = 'X-VCR';

const HEADER_VCR_REPLAY = 'replay';

const HEADER_VCR_RECORDED = 'recorded';

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/TrackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class TrackTest extends VcrTestCase

protected function setUp()
{
$this->request = $this->getMock(RequestInterface::class);
$this->response = $this->getMock(ResponseInterface::class);
$this->request = $this->createMock(RequestInterface::class);
$this->response = $this->createMock(ResponseInterface::class);
$this->exception = new \Exception();

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

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

$this->track->setResponse($this->response);
Expand Down
12 changes: 6 additions & 6 deletions tests/VcrClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class VcrClientTest extends VcrTestCase

protected function setUp()
{
$this->vcr = $this->getMockBuilder(Vcr::class)->getMock();
$this->client = $this->getMock(ClientImplementation::class);
$this->vcr = $this->createMock(Vcr::class);
$this->client = $this->createMock(ClientImplementation::class);
$this->vcrClient = new VcrClient($this->client, $this->vcr);
}

public function testSendRequest()
{
$request = $this->getMock(RequestInterface::class);
$response = $this->getMock(ResponseInterface::class);
$request = $this->createMock(RequestInterface::class);
$response = $this->createMock(ResponseInterface::class);

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

Expand All @@ -45,8 +45,8 @@ public function testSendRequest()

public function testSendAsyncRequest()
{
$request = $this->getMock(RequestInterface::class);
$response = $this->getMock(ResponseInterface::class);
$request = $this->createMock(RequestInterface::class);
$response = $this->createMock(ResponseInterface::class);
$fulfilledPromise = new FulfilledPromise($response);

$this->client->expects($this->once())->method('sendAsyncRequest')->with($request)->willReturn($fulfilledPromise);
Expand Down
4 changes: 2 additions & 2 deletions tests/VcrPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VcrPluginTest extends VcrTestCase

protected function setUp()
{
$this->request = $this->getMock(RequestInterface::class);
$this->request = $this->createMock(RequestInterface::class);

$this->track = $this->getMockBuilder(Track::class)->disableOriginalConstructor()->getMock();
$this->track
Expand Down Expand Up @@ -103,7 +103,7 @@ public function testReplayException()

$promise = $this->plugin->handleRequest(
$this->request,
$this->fulfilledPromise($this->getMock(ResponseInterface::class)),
$this->fulfilledPromise($this->createMock(ResponseInterface::class)),
$this->rejectedPromise($exception)
);

Expand Down
2 changes: 1 addition & 1 deletion tests/VcrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class VcrTest extends VcrTestCase

protected function setUp()
{
$this->storage = $this->getMock(Storage::class);
$this->storage = $this->createMock(Storage::class);
$this->tape = $this->getMockBuilder(Tape::class)->disableOriginalConstructor()->getMock();

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