public function testAuthenticationIsOnlyInvokedIfUsernameAndPasswordSet()
 {
     $auth = new MockAuthenticator();
     $auth->setReturnValue("isAuthenticated", true);
     $auth->setReturnValue("getAuthExtensionName", "foo");
     $auth->expectOnce("isAuthenticated");
     $conn = new Swift_Connection_SMTP();
     $conn->setExtension("AUTH", array("foo"));
     $conn->attachAuthenticator($auth);
     $conn->setUsername("xxx");
     $conn->setPassword("yyyy");
     $conn->postConnect(new Swift($conn, "xxx", Swift::NO_START));
     $auth = new MockAuthenticator();
     $auth->setReturnValue("isAuthenticated", true);
     $auth->setReturnValue("getAuthExtensionName", "foo");
     $auth->expectNever("isAuthenticated");
     $conn = new Swift_Connection_SMTP();
     $conn->setExtension("AUTH", array("foo"));
     $conn->attachAuthenticator($auth);
     //No username/password set
     $conn->postConnect(new Swift($conn, "xxx", Swift::NO_START));
 }
  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();
  }