/** * @test */ public function firstMatchingResponderForContentTypeWillBeUsed() { $setResponder = null; $responder = $this->createMock(Responder::class); $this->manager->expects($this->once())->method('getBestMatch')->will($this->returnValue('application/json')); $this->resolver2->expects($this->once())->method('resolve')->will($this->returnValue($responder)); $request = (new ServerRequest())->withAttribute('domainPayload', new DomainPayload('')); $next = function (ServerRequestInterface $request, ResponseInterface $response) use(&$setResponder) { $setResponder = $request->getAttribute(Responder::class); return $response; }; $this->middleware->__invoke($request, $this->response, $next); $this->assertSame($responder, $setResponder); }
/** * @test */ public function willReturnNullIfAcceptHeaderIsNotPresent() { $bestMatch = $this->manager->getBestMatch($this->request); $this->assertNull($bestMatch); }