private function assertAccessReloadedAndRestored($expectedTokenToBeReloaded) { $this->access->expects($this->exactly(2))->method('reloadAccess'); // verify access reloaded $this->auth->expects($this->at(0))->method('setLogin')->with($this->equalTo(null)); $this->auth->expects($this->at(1))->method('setTokenAuth')->with($this->equalTo($expectedTokenToBeReloaded)); $this->auth->expects($this->at(2))->method('authenticate')->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login1', $expectedTokenToBeReloaded))); // verify access restored $this->auth->expects($this->at(3))->method('setLogin')->with($this->equalTo(null)); $this->auth->expects($this->at(4))->method('setTokenAuth')->with($this->equalTo($tokenRestored = $this->userAuthToken)); $this->auth->expects($this->at(5))->method('authenticate')->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login', $this->userAuthToken))); }