Ejemplo n.º 1
0
 public function testFailedAttemptThenSucceeds()
 {
     $this->factory->expects($this->any())->method('create')->will($this->returnValue($this->pdo));
     $pdoStatement = $this->getMock(\PDOStatement::class);
     $pdoStatement->expects($this->any())->method('execute')->will($this->onConsecutiveCalls($this->throwException(new \PDOException()), $this->returnValue(true)));
     $this->pdo->expects($this->any())->method('prepare')->will($this->returnValue($pdoStatement));
     $this->config->expects($this->any())->method('getMaximumAttempts')->will($this->returnValue(2));
     $this->assertSame($this->pdo, $this->factory->__invoke($this->config));
 }
 /**
  * @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);
 }