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


PHP M::mock方法代码示例

本文整理汇总了PHP中M::mock方法的典型用法代码示例。如果您正苦于以下问题:PHP M::mock方法的具体用法?PHP M::mock怎么用?PHP M::mock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在M的用法示例。


在下文中一共展示了M::mock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testItWorks

 public function testItWorks()
 {
     $mock = M::mock('mindofmicah\\GoodReads\\Curl');
     $mock->shouldReceive('fetchInfo')->once()->andReturn(file_get_contents(__DIR__ . '/stubs/shelves/list.txt'));
     $response = Request::shelves('list', array('id' => 21308373), $mock);
     $this->assertInstanceOf('mindofmicah\\GoodReads\\Response', $response);
     $this->assertInstanceOf('mindofmicah\\GoodReads\\ResponseObj', $response->get('shelves'));
     $this->assertEquals('shelf_list', $response->headers('method'));
     $first_shelf = $response->get('shelves');
     $this->assertInstanceOf('mindofmicah\\GoodReads\\ResponseObj', $first_shelf);
     $first_child = current($first_shelf->child());
     //        print_r($first_child);
     $this->assertEquals('user_shelf', $first_child[0]->getType());
     $this->assertEquals(1, count($response->get('shelves')));
 }
开发者ID:mindofmicah,项目名称:goodreads,代码行数:15,代码来源:MyFirstTest.php

示例2: testGetDailyJournal

 /**
  * Check default value works
  * 
  * Mock a method of the class and mock the http client handler
  * 
  * @covers Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi::getDailyJournal
  */
 public function testGetDailyJournal()
 {
     // Create a mock and queue a few responses.
     $mock = new MockHandler([new Response(200, ['Content-Length' => 0]), new Response(200, ['X-Foo' => 'Bar'], '<body>
                 <div>
                     <h1>
                         Friday 11 March 2016
                     </h1>
                     <div id="mainInner">
                         <img class="image-frame" src="http://www.host.org/webui/Files/Room/small/my/image.jpg">
                     </div>
                 </div>
             </body>
             '), new Response(200, ['Content-Length' => 0]), new Response(200, ['Content-Length' => 0])]);
     $handler = HandlerStack::create($mock);
     $mock = M::mock('Cpeter\\PhpQkeylmEmailNotification\\Qkeylm\\QkeylmApi[login]', [['host' => 'http://www.host.org', 'page_journal' => '/journal_page', 'page_journal_date' => '/journal_page_print', 'child_name' => 'Adel', 'handler' => $handler]]);
     $mock->shouldReceive('login')->andReturn(true);
     $journal = $mock->getDailyJournal();
     $this->assertTrue(isset($journal['images']['http://www.host.org/webui/Files/Room/small/my/image.jpg']));
     $this->assertTrue(isset($journal['body']));
     $this->assertTrue($journal['date'] == '2016-03-11');
 }
开发者ID:cpeter,项目名称:php-qkeylm-email-notification,代码行数:29,代码来源:QkeylmTest.php


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