[Pkg-owncloud-commits] [owncloud] 02/23: fix user session tests by making them update \OC:: as well
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 15:21:34 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 34cb09b777916319d69dd5834518ae7d8d783b41
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date: Fri Jul 18 10:46:17 2014 +0200
fix user session tests by making them update \OC:: as well
---
tests/lib/user/session.php | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php
index 2845a9c..16b5108 100644
--- a/tests/lib/user/session.php
+++ b/tests/lib/user/session.php
@@ -10,6 +10,17 @@
namespace Test\User;
class Session extends \PHPUnit_Framework_TestCase {
+
+ private $session;
+
+ public function setUp () {
+ $this->session = \OC::$session;
+ }
+
+ public function tearDown() {
+ \OC::$session = $this->session;
+ }
+
public function testGetUser() {
$session = $this->getMock('\OC\Session\Memory', array(), array(''));
$session->expects($this->once())
@@ -26,6 +37,8 @@ class Session extends \PHPUnit_Framework_TestCase {
$manager = new \OC\User\Manager();
$manager->registerBackend($backend);
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$user = $userSession->getUser();
$this->assertEquals('foo', $user->getUID());
@@ -46,6 +59,8 @@ class Session extends \PHPUnit_Framework_TestCase {
->method('getUID')
->will($this->returnValue('foo'));
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$userSession->setUser($user);
}
@@ -96,6 +111,8 @@ class Session extends \PHPUnit_Framework_TestCase {
->with('foo', 'bar')
->will($this->returnValue($user));
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$userSession->login('foo', 'bar');
$this->assertEquals($user, $userSession->getUser());
@@ -132,6 +149,8 @@ class Session extends \PHPUnit_Framework_TestCase {
->with('foo', 'bar')
->will($this->returnValue($user));
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$userSession->login('foo', 'bar');
}
@@ -166,6 +185,8 @@ class Session extends \PHPUnit_Framework_TestCase {
->with('foo', 'bar')
->will($this->returnValue(false));
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$userSession->login('foo', 'bar');
}
@@ -184,6 +205,8 @@ class Session extends \PHPUnit_Framework_TestCase {
->with('foo', 'bar')
->will($this->returnValue(false));
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$userSession->login('foo', 'bar');
}
@@ -233,6 +256,8 @@ class Session extends \PHPUnit_Framework_TestCase {
$token = 'goodToken';
\OC_Preferences::setValue('foo', 'login_token', $token, time());
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = $this->getMock(
'\OC\User\Session',
//override, otherwise tests will fail because of setcookie()
@@ -281,6 +306,8 @@ class Session extends \PHPUnit_Framework_TestCase {
$token = 'goodToken';
\OC_Preferences::setValue('foo', 'login_token', $token, time());
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$granted = $userSession->loginWithCookie('foo', 'badToken');
@@ -322,6 +349,8 @@ class Session extends \PHPUnit_Framework_TestCase {
$token = 'goodToken';
\OC_Preferences::setValue('foo', 'login_token', $token, time());
+ //also set the \OC::$session or the \OC\User\Session will use it
+ \OC::$session = $session;
$userSession = new \OC\User\Session($manager, $session);
$granted = $userSession->loginWithCookie('foo', $token);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list