diff options
Diffstat (limited to 'tests/session')
-rw-r--r-- | tests/session/append_sid_test.php | 4 | ||||
-rw-r--r-- | tests/session/continue_test.php | 14 | ||||
-rw-r--r-- | tests/session/creation_test.php | 14 | ||||
-rw-r--r-- | tests/session/testable_factory.php | 24 |
4 files changed, 45 insertions, 11 deletions
diff --git a/tests/session/append_sid_test.php b/tests/session/append_sid_test.php index ce7bf71215..b9e9ac1aa9 100644 --- a/tests/session/append_sid_test.php +++ b/tests/session/append_sid_test.php @@ -45,6 +45,10 @@ class phpbb_session_append_sid_test extends phpbb_test_case */ public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description) { + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id)); } } + diff --git a/tests/session/continue_test.php b/tests/session/continue_test.php index c4f7f8d75b..e5a7f7a4a1 100644 --- a/tests/session/continue_test.php +++ b/tests/session/continue_test.php @@ -7,7 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../mock/cache.php'; require_once dirname(__FILE__) . '/testable_factory.php'; class phpbb_session_continue_test extends phpbb_database_test_case @@ -54,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/creation_test.php b/tests/session/creation_test.php index bef52c6554..fde76d6b06 100644 --- a/tests/session/creation_test.php +++ b/tests/session/creation_test.php @@ -7,7 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../mock/cache.php'; require_once dirname(__FILE__) . '/testable_factory.php'; class phpbb_session_creation_test extends phpbb_database_test_case @@ -21,7 +20,20 @@ class phpbb_session_creation_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); diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 00f79738ef..1e2b194ece 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../mock/session_testable.php'; - /** * This class exists to setup an instance of phpbb's session class for testing. * @@ -24,6 +22,7 @@ class phpbb_session_testable_factory protected $config; protected $cache; + protected $request; /** * Initialises the factory with a set of default config and cache values. @@ -60,23 +59,30 @@ class phpbb_session_testable_factory /** * Retrieve the configured session class instance * - * @param dbal $dbal The database connection to use for session data + * @param phpbb_db_driver $dbal The database connection to use for session data * @return phpbb_mock_session_testable A session instance */ - public function get_session(dbal $dbal) + public function get_session(phpbb_db_driver $dbal) { // set up all the global variables used by session - global $SID, $_SID, $db, $config, $cache; + global $SID, $_SID, $db, $config, $cache, $request; + + $request = $this->request = new phpbb_mock_request( + array(), + array(), + $this->cookies, + $this->server_data + ); + request_var(null, null, null, null, $request); + + $config = $this->config = new phpbb_config($this->get_config_data()); + set_config(null, null, null, $config); - $config = $this->config = $this->get_config_data(); $db = $dbal; $cache = $this->cache = new phpbb_mock_cache($this->get_cache_data()); $SID = $_SID = null; - $_COOKIE = $this->cookies; - $_SERVER = $this->server_data; - $session = new phpbb_mock_session_testable; return $session; } |