Records and automatically replays responses on subsequent requests for unit testing
コード例 #1
0
 public function testExisting()
 {
     $vcr = \Dshafik\GuzzleHttp\VcrHandler::turnOn(__DIR__ . '/fixtures/test-existing.json');
     $client = new \GuzzleHttp\Client(['handler' => $vcr]);
     $response = $client->get('/test');
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertArrayHasKey('X-VCR-Recording', $response->getHeaders());
     $this->assertEquals("1440121471", $response->getHeader('X-VCR-Recording')[0]);
     $this->assertEquals('Hello World', (string) $response->getBody());
 }
コード例 #2
0
 public function setUp()
 {
     if (!file_exists(__DIR__ . '/fixtures')) {
         mkdir(__DIR__ . '/fixtures');
     }
     $handler = new \Akamai\NetStorage\Handler\Authentication();
     $handler->setSigner((new \Akamai\NetStorage\Authentication())->setKey($this->key, $this->keyName));
     $stack = \Dshafik\GuzzleHttp\VcrHandler::turnOn(__DIR__ . '/fixtures/' . lcfirst(substr($this->getName(), 4)) . '.json');
     $stack->push($handler, 'netstorage-handler');
     $client = new \Akamai\Open\EdgeGrid\Client(['base_uri' => $this->host, 'handler' => $stack]);
     $adapter = new \Akamai\NetStorage\FileStoreAdapter($client, $this->cpCode);
     $this->fs = new \League\Flysystem\Filesystem($adapter);
 }
コード例 #3
0
ファイル: RevIntegrationVCRTest.php プロジェクト: unl/rev_api
 protected function getClient()
 {
     $vcr = VcrHandler::turnOn(__DIR__ . '/fixtures/' . $this->getName() . '.json');
     $rev = new Rev(getenv('REV_CLIENT_API_KEY'), getenv('REV_USER_API_KEY'), Rev::SANDBOX_HOST, array('handler' => $vcr));
     return $rev;
 }