mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38:53 +00:00
[ticket/11620] Implemented a provider mock object.
Due to an auth_refactor, there is a new dependency in session.php on phpbb_container and a provider. For purposes of testing, implemented a simple one. PHPBB3-11620
This commit is contained in:
parent
6f8187f7fa
commit
5cdcb689df
2 changed files with 34 additions and 1 deletions
23
tests/mock/provider.php
Normal file
23
tests/mock/provider.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mock provider class with basic functions to help test
|
||||
* sessions.
|
||||
*/
|
||||
class phpbb_provider {
|
||||
function autologin()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
function kill()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -7,6 +7,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../mock/container_builder.php';
|
||||
require_once dirname(__FILE__) . '/../mock/provider.php';
|
||||
|
||||
/**
|
||||
* This class exists to setup an instance of phpbb's session class for testing.
|
||||
*
|
||||
|
@ -16,6 +19,7 @@
|
|||
*/
|
||||
class phpbb_session_testable_factory
|
||||
{
|
||||
protected $container;
|
||||
protected $config_data;
|
||||
protected $cache_data;
|
||||
protected $cookies;
|
||||
|
@ -65,7 +69,7 @@ class phpbb_session_testable_factory
|
|||
public function get_session(phpbb_db_driver $dbal)
|
||||
{
|
||||
// set up all the global variables used by session
|
||||
global $SID, $_SID, $db, $config, $cache, $request;
|
||||
global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container;
|
||||
|
||||
$request = $this->request = new phpbb_mock_request(
|
||||
array(),
|
||||
|
@ -83,6 +87,12 @@ class phpbb_session_testable_factory
|
|||
$cache = $this->cache = new phpbb_mock_cache($this->get_cache_data());
|
||||
$SID = $_SID = null;
|
||||
|
||||
$phpbb_container = $this->container = new phpbb_mock_container_builder();
|
||||
$phpbb_container->set(
|
||||
'auth.provider.db',
|
||||
new phpbb_provider()
|
||||
);
|
||||
|
||||
$session = new phpbb_mock_session_testable;
|
||||
return $session;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue