From 236632702cf7fe68cc9ad1dcfcc463e0d4c14d64 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 16 Dec 2014 19:07:14 +0100 Subject: add a isLoggedIn method to the usersession and deprecate the isLoggedIn method on the api --- tests/lib/user/session.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index aa1ea5841c0..d441f802087 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -34,6 +34,34 @@ class Session extends \Test\TestCase { $this->assertEquals('foo', $user->getUID()); } + public function testIsLoggedIn() { + $session = $this->getMock('\OC\Session\Memory', array(), array('')); + $session->expects($this->once()) + ->method('get') + ->with('user_id') + ->will($this->returnValue(null)); + + $backend = $this->getMock('OC_User_Dummy'); + $backend->expects($this->once()) + ->method('userExists') + ->with('foo') + ->will($this->returnValue(true)); + + $manager = new \OC\User\Manager(); + $manager->registerBackend($backend); + + $userSession = new \OC\User\Session($manager, $session); + $isLoggedIn = $userSession->isLoggedIn(); + $this->assertFalse($isLoggedIn); + + $session->expects($this->once()) + ->method('get') + ->with('user_id') + ->will($this->returnValue('foo')); + $isLoggedIn = $userSession->isLoggedIn(); + $this->assertTrue($isLoggedIn); + } + public function testSetUser() { $session = $this->getMock('\OC\Session\Memory', array(), array('')); $session->expects($this->once()) -- cgit v1.2.3