本文整理汇总了PHP中Guzzle\Plugin\Mock\MockPlugin::getMockFile方法的典型用法代码示例。如果您正苦于以下问题:PHP MockPlugin::getMockFile方法的具体用法?PHP MockPlugin::getMockFile怎么用?PHP MockPlugin::getMockFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Plugin\Mock\MockPlugin
的用法示例。
在下文中一共展示了MockPlugin::getMockFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDeletesArchive
public function testDeletesArchive()
{
// Arrange
$mock = new MockPlugin();
$response = MockPlugin::getMockFile(self::$mockBasePath . 'v2/partner/APIKEY/archive/ARCHIVEID/delete');
$mock->addResponse($response);
$this->client->addSubscriber($mock);
// Act
// TODO: should this test be run on an archive object whose fixture has status 'available'
// instead of 'started'?
$success = $this->archive->delete();
// Assert
$requests = $mock->getReceivedRequests();
$this->assertCount(1, $requests);
$request = $requests[0];
$this->assertEquals('DELETE', strtoupper($request->getMethod()));
$this->assertEquals('/v2/partner/' . $this->API_KEY . '/archive/' . $this->archiveData['id'], $request->getPath());
$this->assertEquals('api.opentok.com', $request->getHost());
$this->assertEquals('https', $request->getScheme());
$contentType = $request->getHeader('Content-Type');
$this->assertNotEmpty($contentType);
$this->assertEquals('application/json', $contentType);
$authString = $request->getHeader('X-TB-PARTNER-AUTH');
$this->assertNotEmpty($authString);
$this->assertEquals($this->API_KEY . ':' . $this->API_SECRET, $authString);
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.3.2-alpha.1', $userAgent->__toString());
$this->assertTrue($success);
// TODO: assert that all properties of the archive object were cleared
}
示例2: testMultiPageCount
/**
* Test a count request that cannot be satisfied with only the first page
* of results.
*/
public function testMultiPageCount()
{
$responses = array(MockPlugin::getMockFile(TEST_RESOURCE_PATH . '/http/drupal_org_major_bugs_0'), MockPlugin::getMockFile(TEST_RESOURCE_PATH . '/http/drupal_org_major_bugs_1'), MockPlugin::getMockFile(TEST_RESOURCE_PATH . '/http/drupal_org_major_bugs_2'), MockPlugin::getMockFile(TEST_RESOURCE_PATH . '/http/drupal_org_major_bugs_3'), MockPlugin::getMockFile(TEST_RESOURCE_PATH . '/http/drupal_org_major_bugs_4'), MockPlugin::getMockFile(TEST_RESOURCE_PATH . '/http/drupal_org_major_bugs_5'));
$mockPlugin = new MockPlugin($responses);
$client = new \Guzzle\Http\Client();
$client->addSubscriber($mockPlugin);
$issueCounter = new DrupalIssueCount($client);
$issueCount = $issueCounter->getCounts(array('status' => array(1, 13, 8, 14, 15, 4)), array('major_bugs' => array('priorities' => array(300), 'categories' => array(1))));
$this->assertEquals(271, $issueCount['major_bugs']);
}
示例3: getMockHttpResponse
/**
* Get a mock response for a client by mock file name
*
* @param string $path Relative path to the mock response file
* @return Response
*/
public function getMockHttpResponse($path)
{
if ($path instanceof Response) {
return $path;
}
$ref = new ReflectionObject($this);
$dir = dirname($ref->getFileName());
// if mock file doesn't exist, check parent directory
if (!file_exists($dir . '/Mock/' . $path) && file_exists($dir . '/../Mock/' . $path)) {
return MockPlugin::getMockFile($dir . '/../Mock/' . $path);
}
return MockPlugin::getMockFile($dir . '/Mock/' . $path);
}
示例4: getMockResponse
/**
* Get a mock response for a client by mock file name
*
* @param string $path Relative path to the mock response file
*
* @return Response
*/
public function getMockResponse($path)
{
return $path instanceof Response ? $path : MockPlugin::getMockFile(self::$mockBasePath . DIRECTORY_SEPARATOR . $path);
}
示例5: getResponse
private function getResponse($path)
{
return MockPlugin::getMockFile(__DIR__ . '/fixtures/' . $path);
}
示例6: testDetachesTemporaryWhenEmpty
/**
* @depends testAddsMockResponseToRequestFromClient
*/
public function testDetachesTemporaryWhenEmpty()
{
$p = new MockPlugin(null, true);
$p->addResponse(MockPlugin::getMockFile(__DIR__ . '/../../TestData/mock_response'));
$client = new Client('http://localhost:123/');
$client->getEventDispatcher()->addSubscriber($p, 9999);
$request = $client->get();
$request->send();
$this->assertFalse($this->hasSubscriber($client, $p));
}
示例7: fixtureGuzzleCall
public function fixtureGuzzleCall($route)
{
$response = MockPlugin::getMockFile(__DIR__ . '/../Fixtures/GuzzleResponses/' . $route . '.txt');
$this->guzzleMock->addResponse($response);
return $this;
}
示例8: testGetsExpiredArchive
public function testGetsExpiredArchive()
{
// Arrange
$mock = new MockPlugin();
$response = MockPlugin::getMockFile(self::$mockBasePath . 'v2/partner/APIKEY/archive/ARCHIVEID/get-expired');
$mock->addResponse($response);
$this->client->addSubscriber($mock);
$archiveId = '063e72a4-64b4-43c8-9da5-eca071daab89';
// Act
$archive = $this->opentok->getArchive($archiveId);
// Assert
$this->assertInstanceOf('OpenTok\\Archive', $archive);
$this->assertEquals("expired", $archive->status);
}
示例9: addMock
private function addMock($path)
{
$this->mockPlugin->addResponse(MockPlugin::getMockFile(MOCK_BASE_PATH . '/' . $path));
}