当前位置: 首页>>代码示例>>PHP>>正文


PHP MockPlugin::getMockFile方法代码示例

本文整理汇总了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
 }
开发者ID:maniraju,项目名称:OpenTok-PHP-SDK,代码行数:32,代码来源:ArchiveTest.php

示例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']);
 }
开发者ID:pingers,项目名称:drupalreleasedate,代码行数:14,代码来源:DrupalIssueCountTest.php

示例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);
 }
开发者ID:justinbusschau,项目名称:hmrc-gift-aid,代码行数:19,代码来源:TestCase.php

示例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);
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:11,代码来源:GuzzleTestCase.php

示例5: getResponse

 private function getResponse($path)
 {
     return MockPlugin::getMockFile(__DIR__ . '/fixtures/' . $path);
 }
开发者ID:lyrixx,项目名称:ratp,代码行数:4,代码来源:ApiTest.php

示例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));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:13,代码来源:MockPluginTest.php

示例7: fixtureGuzzleCall

 public function fixtureGuzzleCall($route)
 {
     $response = MockPlugin::getMockFile(__DIR__ . '/../Fixtures/GuzzleResponses/' . $route . '.txt');
     $this->guzzleMock->addResponse($response);
     return $this;
 }
开发者ID:AdrenalineHunter,项目名称:SQSBundle,代码行数:6,代码来源:AwsServiceTest.php

示例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);
 }
开发者ID:KKRTEAM,项目名称:cis_admq,代码行数:14,代码来源:OpenTokTest.php

示例9: addMock

 private function addMock($path)
 {
     $this->mockPlugin->addResponse(MockPlugin::getMockFile(MOCK_BASE_PATH . '/' . $path));
 }
开发者ID:jwpage,项目名称:gocard-php-api,代码行数:4,代码来源:GoCardTest.php


注:本文中的Guzzle\Plugin\Mock\MockPlugin::getMockFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。