/**
  * @test
  */
 public function firstMatchingResponderForContentTypeGetsReturned()
 {
     $returnValue = $this->getMock(Responder::class);
     $this->manager->expects($this->once())->method('getBestMatch')->will($this->returnValue('application/json'));
     $this->resolver2->expects($this->once())->method('resolve')->will($this->returnValue($returnValue));
     $responder = $this->resolver->resolve($this->request, $this->domainPayload);
     $this->assertEquals($returnValue, $responder);
 }
 /**
  * @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 responderResolverReturnsFirstMatch()
 {
     $domainPayload = new DomainPayload('test');
     $this->action->expects($this->once())->method('prepareAndExecute')->will($this->returnValue($domainPayload));
     $this->router->expects($this->once())->method('resolveActionToken')->will($this->returnValue($this->request));
     $returnValue = $this->buildResponse('<html>', 200);
     $this->responder->expects($this->once())->method('buildResponse')->will($this->returnValue($returnValue));
     $this->responderResolver->expects($this->once())->method('resolve')->will($this->returnValue($this->responder));
     $responderResolver2 = $this->getMock(ResponderResolver::class);
     $responderResolver2->expects($this->never())->method('resolve');
     $this->middleware = $this->getMock(AdroitMiddleware::class, ['resolveAction'], [[], [$this->responderResolver, $responderResolver2], $this->router]);
     $this->middleware->expects($this->once())->method('resolveAction')->will($this->returnValue($this->action));
     $response = $this->middleware->__invoke($this->request, new Response());
     $this->assertSame($returnValue, $response);
 }