public function testPlayerCanReplayFromContent() { $mock = SimpleMockHandler::create()->withMultipleResponses(5, 200)->withMultipleResponses(5, 403)->withMultipleResponses(5, 404)->build(); $client = SimpleMockedClient::createMockedClient($mock, $this->recorder); for ($i = 0; $i < 15; $i++) { try { $client->get('/'); } catch (RequestException $e) { } } $content = $this->recorder->getTapeContent('tape-all'); $player = Player::replayFromContent($content); $this->assertInstanceOf('GuzzleHttp\\Client', $player->getClient()); $this->assertEquals(200, $player->get('/')->getStatusCode()); }
public function testRecorderIsDumpingTapes() { $mock = SimpleMockHandler::create()->withMultipleResponses(5, 200)->withMultipleResponses(5, 403)->withMultipleResponses(5, 404)->build(); $client = SimpleMockedClient::createMockedClient($mock, $this->recorder); for ($i = 0; $i < 15; $i++) { try { $client->get('/'); } catch (RequestException $e) { } } $this->recorder->dump(); $successTapeFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'record_tape-success.json'; $AllTapeFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'record_tape-all.json'; $UnauthTapeFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'record_tape-unauthorized.json'; $this->assertFileExists($successTapeFile); $this->assertFileExists($AllTapeFile); $this->assertFileExists($UnauthTapeFile); }