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


PHP Response::shouldReceive方法代码示例

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


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

示例1: testRespondDoesParameters

 public function testRespondDoesParameters()
 {
     // parameters
     $status = 100;
     $headers = ['coolness' => '(awyeah)'];
     Response::shouldReceive('json')->with($this->data, $status, $headers)->once()->andReturn(true);
     expect($this->controller->respond($status, $headers))->true();
 }
开发者ID:C4Tech,项目名称:laravel-support,代码行数:8,代码来源:ControllerTest.php

示例2: testErrorHandlerWithExceptionAndMessageAndCode

 public function testErrorHandlerWithExceptionAndMessageAndCode()
 {
     $exception = new \Exception('some exception', 1001);
     $error_handler = new \Vinelab\Api\ErrorHandler($this->responder);
     $expected = ['status' => 401, 'error' => ['code' => 1001, 'message' => 'some exception']];
     $response = M::mock('Illuminate\\Http\\Response');
     $response->original = $expected;
     Response::shouldReceive('json')->once()->with($expected, $expected['status'], [], 0)->andReturn($response);
     $response = $error_handler->handle($exception, $exception->getCode(), 401)->original;
     $this->assertEquals($expected, $response);
     $this->assertInternalType('int', $response['status']);
 }
开发者ID:vinelab,项目名称:api-manager,代码行数:12,代码来源:ErrorHandlerTest.php

示例3: testCallingMapperAsArrayWithInstance

 public function testCallingMapperAsArrayWithInstance()
 {
     $mPost = M::mock('Post');
     $mPost->shouldReceive('setAttribute')->passthru();
     $mPost->id = 1;
     $mPost->text = 'Enim provident tempore reiciendis quit qui.';
     $mPost->active = true;
     $mPost->shouldReceive('getAttribute')->passthru();
     $expected = ['status' => 200, 'data' => ['id' => 1, 'text' => 'Enim provident tempore reiciendis quit qui.', 'active' => true]];
     $response = M::mock('Illuminate\\Http\\Response');
     $response->shouldReceive('getData')->once()->andReturn($expected);
     Response::shouldReceive('json')->once()->with($expected, 200, [], 0)->andReturn($response);
     $this->response_handler->setMapperNamespace('Vinelab\\Api\\Tests\\');
     $mapper = [new DummyMapper(), 'mapDatThing'];
     $result = $this->response_handler->content($mapper, $mPost);
     $this->assertInternalType('array', $result);
     $this->assertEquals($expected, $result);
 }
开发者ID:vinelab,项目名称:api-manager,代码行数:18,代码来源:ApiTest.php


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