aboutsummaryrefslogtreecommitdiffstats
path: root/tests/session
diff options
context:
space:
mode:
Diffstat (limited to 'tests/session')
-rw-r--r--tests/session/continue_test.php13
-rw-r--r--tests/session/creation_test.php (renamed from tests/session/init_test.php)20
2 files changed, 30 insertions, 3 deletions
diff --git a/tests/session/continue_test.php b/tests/session/continue_test.php
index ad78d92299..e5a7f7a4a1 100644
--- a/tests/session/continue_test.php
+++ b/tests/session/continue_test.php
@@ -53,7 +53,20 @@ class phpbb_session_continue_test extends phpbb_database_test_case
*/
public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $ip, $expected_sessions, $expected_cookies, $message)
{
+ global $phpbb_container, $phpbb_root_path, $phpEx;
+
$db = $this->new_dbal();
+ $config = new phpbb_config(array());
+ $request = $this->getMock('phpbb_request');
+ $user = $this->getMock('phpbb_user');
+
+ $auth_provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx);
+ $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $phpbb_container->expects($this->any())
+ ->method('get')
+ ->with('auth.provider.db')
+ ->will($this->returnValue($auth_provider));
+
$session_factory = new phpbb_session_testable_factory;
$session_factory->set_cookies(array(
'_sid' => $session_id,
diff --git a/tests/session/init_test.php b/tests/session/creation_test.php
index 830de34ed0..fde76d6b06 100644
--- a/tests/session/init_test.php
+++ b/tests/session/creation_test.php
@@ -9,7 +9,7 @@
require_once dirname(__FILE__) . '/testable_factory.php';
-class phpbb_session_init_test extends phpbb_database_test_case
+class phpbb_session_creation_test extends phpbb_database_test_case
{
public function getDataSet()
{
@@ -20,7 +20,20 @@ class phpbb_session_init_test extends phpbb_database_test_case
public function test_login_session_create()
{
+ global $phpbb_container, $phpbb_root_path, $phpEx;
+
$db = $this->new_dbal();
+ $config = new phpbb_config(array());
+ $request = $this->getMock('phpbb_request');
+ $user = $this->getMock('phpbb_user');
+
+ $auth_provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx);
+ $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $phpbb_container->expects($this->any())
+ ->method('get')
+ ->with('auth.provider.db')
+ ->will($this->returnValue($auth_provider));
+
$session_factory = new phpbb_session_testable_factory;
$session = $session_factory->get_session($db);
@@ -34,10 +47,11 @@ class phpbb_session_init_test extends phpbb_database_test_case
$this->assertSqlResultEquals(
array(array('session_user_id' => 3)),
$sql,
- 'Check if exacly one session for user id 3 was created'
+ 'Check if exactly one session for user id 3 was created'
);
- $cookie_expire = $session->time_now + 31536000; // default is one year
+ $one_year_in_seconds = 365 * 24 * 60 * 60;
+ $cookie_expire = $session->time_now + $one_year_in_seconds;
$session->check_cookies($this, array(
'u' => array(null, $cookie_expire),