public function testSetResponse() { $response = new Response(); $server = new Server(); $return = $server->setResponse($response); $this->assertSame($return, $server); $this->assertSame($response, $server->getResponse()); }
public function testDoDispatch() { $result = 'Lorem ipsum dolor sit amet'; $params = ['foo' => 'bar', 'bat' => 'baz']; $controller = $this->getMock('FakeController', ['fakeAction']); $event = new DispatchEvent($controller, 'FakeController', 'fake', $params); $request = $this->getMock(ServerRequest::CLASS); $response = new Response(); $server = new Server(); $server->setRequest($request); $server->setResponse($response); $dispatcher = new DispatchesControllerListener(); $dispatcher->setServer($server); $request->expects($this->once())->method('withAddedAttributes')->with($this->callback(function ($attributes) use($params) { return empty(array_diff($params, $attributes)); }))->will($this->returnSelf()); $controller->expects($this->once())->method('fakeAction')->with($this->identicalTo($request), $this->identicalTo($response))->will($this->returnValue($result)); $dispatcher->doDispatch($event); }