示例#1
0
 function it_returns_null_if_authentication_fails(Identifier $identifier, Caller $caller, Authenticator $authenticator)
 {
     $subject = ['username' => 'john.doe', 'password' => 'secret'];
     $identifier->identify($subject)->willReturn($caller);
     $authenticator->authenticate($subject, $caller)->willReturn(false);
     $this->authenticateAndReturn($subject)->shouldReturn(null);
 }
示例#2
0
 /**
  * Authenticates a subject and returns the associated caller
  *
  * @param array $subject
  *
  * @return Caller
  */
 public function authenticateAndReturn(array $subject)
 {
     $caller = $this->identifier->identify($subject);
     if ($this->authenticator->authenticate($subject, $caller)) {
         return $caller;
     }
 }