本文整理汇总了PHP中Psr\Http\Message\UriInterface::method方法的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface::method方法的具体用法?PHP UriInterface::method怎么用?PHP UriInterface::method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\UriInterface
的用法示例。
在下文中一共展示了UriInterface::method方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shouldCatchInvalidBody
/** @test */
public function shouldCatchInvalidBody()
{
$body = $this->getMock('\\Psr\\Http\\Message\\StreamInterface');
$body->method('getContents')->willReturn('{"title":"Aaa"}');
$this->request->method('getMethod')->willReturn('post');
$this->uri->method('getPath')->willReturn('/songs');
$this->request->method('getHeaderLine')->with('Content-Type')->willReturn('application/json');
$this->request->method('getBody')->willReturn($body);
$this->setExpectedException('\\Raml\\Validator\\ValidatorRequestException', 'title (minLength), artist (required)');
$validator = $this->getValidatorForSchema(__DIR__ . '/../fixture/validator/requestBody.raml');
$validator->validateRequest($this->request);
}
示例2: shouldCatchInvalidBody
/** @test */
public function shouldCatchInvalidBody()
{
$json = '{}';
$headers = ['X-Required-Header' => ['123456'], 'X-Long-Optional-Header' => ['Abcdefghijkl']];
$map = [['X-Required-Header', [['123456']]], ['X-Long-Optional-Header', [['Abcdefg', 'Abc']]]];
$body = $this->getMock('\\Psr\\Http\\Message\\StreamInterface');
$body->method('getContents')->willReturn($json);
$this->request->method('getMethod')->willReturn('post');
$this->uri->method('getPath')->willReturn('/songs');
$this->response->method('getStatusCode')->willReturn(200);
$this->response->method('getHeader')->willReturnMap($map);
$this->response->method('getHeaders')->willReturn($headers);
$this->response->method('getHeaderLine')->with('Content-Type')->willReturn('application/json');
$this->response->method('getBody')->willReturn($body);
$this->setExpectedException('\\Raml\\Validator\\ValidatorResponseException', 'title (required), artist (required)');
$validator = $this->getValidatorForSchema(__DIR__ . '/../fixture/validator/responseBody.raml');
$validator->validateResponse($this->request, $this->response);
}