diff --git a/composer.json b/composer.json index f0bbaec..e27c260 100644 --- a/composer.json +++ b/composer.json @@ -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" } diff --git a/src/VcrPlugin.php b/src/VcrPlugin.php index d0f39a2..b86dc6d 100644 --- a/src/VcrPlugin.php +++ b/src/VcrPlugin.php @@ -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; @@ -13,7 +13,9 @@ class VcrPlugin implements Plugin { const HEADER_VCR = 'X-VCR'; + const HEADER_VCR_REPLAY = 'replay'; + const HEADER_VCR_RECORDED = 'recorded'; /** diff --git a/tests/TrackTest.php b/tests/TrackTest.php index a2b458c..2c4318c 100644 --- a/tests/TrackTest.php +++ b/tests/TrackTest.php @@ -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); @@ -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); diff --git a/tests/VcrClientTest.php b/tests/VcrClientTest.php index f6c89d8..dea6817 100644 --- a/tests/VcrClientTest.php +++ b/tests/VcrClientTest.php @@ -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); @@ -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); diff --git a/tests/VcrPluginTest.php b/tests/VcrPluginTest.php index 04042bc..394a1e4 100644 --- a/tests/VcrPluginTest.php +++ b/tests/VcrPluginTest.php @@ -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 @@ -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) ); diff --git a/tests/VcrTest.php b/tests/VcrTest.php index f3084d0..f0d3e65 100644 --- a/tests/VcrTest.php +++ b/tests/VcrTest.php @@ -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);