/** * @param \Tonic\Application $app * @param \Tonic\Request $request * @param \Tonic\ResourceMetadata $resourceMetadata * @param \Tonic\MethodMetadata $methodMetadata */ function it_shows_options($app, $request, $resourceMetadata, $methodMetadata) { $request->getMethod()->willReturn('options'); $request->getParams()->willReturn(array()); $methodMetadata->getConditions()->willReturn(array('method' => array('options'))); $resourceMetadata->getMethods()->willReturn(array('options' => $methodMetadata)); $app->getResourceMetadata(\Prophecy\Argument::any())->willReturn($resourceMetadata); $response = $this->exec(); $response->code->shouldBe(200); $response->getHeader('Allow')->shouldBe('OPTIONS'); $response->body->shouldBe(array('OPTIONS')); }
/** * @param \Tonic\Application $app * @param \Tonic\Request $request * @param \Tonic\ResourceMetadata $resourceMetadata */ function let($app, $request, $resourceMetadata, $mySecret) { $request->getMethod()->willReturn('GET'); $request->getParams()->willReturn(array()); $request->getAccept()->willReturn(array()); $request->getAcceptLanguage()->willReturn(array()); $mySecret->beADoubleOf('\\Tonic\\MethodMetadata'); $mySecret->getConditions()->willReturn(array('method' => array('GET'), 'secure' => array('aUser aPassword'))); $resourceMetadata->getClass()->willReturn('\\Tyrell\\Secret'); $resourceMetadata->getUri()->willReturn(array(array('/secret'))); $resourceMetadata->getMethod('setup')->willReturn(null); $resourceMetadata->getMethods()->willReturn(array('mySecret' => $mySecret)); $resourceMetadata->getMethod('setup')->willReturn(null); $app->getResourceMetadata(\Prophecy\Argument::any())->willReturn($resourceMetadata); $this->beConstructedWith($app, $request); }
/** * @param \Tonic\Application $app * @param \Tonic\Request $request */ function it_should_say_hello_computer($app, $request) { $app->uri(Argument::any(), Argument::any())->willReturn('/hello'); $request->getAccept()->willReturn(array('application/json')); $request->getContentType()->willReturn('application/json'); $request->getData()->willReturn(null); $request->setData(Argument::any())->willReturn(null); $response = $this->exec(); $response->code->shouldBe(200); $response->contentType->shouldBe('application/json'); $response->body->shouldBe(json_encode(array('hello' => null, 'url' => '/hello'))); }