本文整理汇总了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();
}
示例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']);
}
示例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);
}