public function testAuthExtensionsWithAsteriskAsNameAreRunAlways()
 {
     $auth = new MockAuthenticator();
     $auth->setReturnValue("isAuthenticated", true);
     $auth->setReturnValue("getAuthExtensionName", "*foo");
     $auth->expectOnce("isAuthenticated");
     $conn = new Swift_Connection_SMTP();
     $conn->setExtension("AUTH", array("not-an-asterisk"));
     $conn->attachAuthenticator($auth);
     $conn->setUsername("xxx");
     $conn->setPassword("yyyy");
     $conn->postConnect(new Swift($conn, "xxx", Swift::NO_START));
 }
 /**
  * Checks that the interface is actually invoked when needed.
  */
 public function testAuthenticatorIsInvokedIfSMTPUsernameAndPasswordSet()
 {
     try {
         $auth = new MockAuthenticator();
         $auth->setReturnValue("getAuthExtensionName", "FOO");
         $auth->expectOnce("isAuthenticated", array("foo", "bar", "*"));
         $smtp = new PartialSmtpConnection();
         $smtp->setExtension("AUTH", array("FOO"));
         $smtp->setUsername("foo");
         $smtp->setPassword("bar");
         $smtp->attachAuthenticator($auth);
         $smtp->postConnect(new Swift($smtp, "xx", Swift::NO_START));
     } catch (Swift_ConnectionException $e) {
         //
     }
 }
  function testInitializeUserIsLoggedIn()
  {
    $user = new MockUser($this);
    $authenticator = new MockAuthenticator($this);

    $this->toolkit->expectOnce('getUser');
    $this->toolkit->setReturnValue('getUser', $user);

    $user->expectOnce('isLoggedIn');
    $user->setReturnValue('isLoggedIn', true);
    $authenticator->expectNever('login', array(array('login' => '', 'password' => '')));

    $filter = new AuthenticationFilter();

    $filter->initializeUser();

    $user->tally();
    $authenticator->tally();
  }