mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/11620] Abstracted session setUp into a test_case class
When defining a database test case with a setUp function, it is important to call the parent's setup function, because that is when the database is setup. PHPBB3-11620
This commit is contained in:
parent
c96b0b1a47
commit
62d7a05700
5 changed files with 35 additions and 56 deletions
|
@ -7,27 +7,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/testable_facade.php';
|
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
|
||||||
|
|
||||||
class phpbb_session_create_test extends phpbb_database_test_case
|
class phpbb_session_create_test extends phpbb_session_test_case
|
||||||
{
|
{
|
||||||
public $session_factory;
|
|
||||||
public $db;
|
|
||||||
public $session_facade;
|
|
||||||
|
|
||||||
public function getDataSet()
|
public function getDataSet()
|
||||||
{
|
{
|
||||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml');
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->session_factory = new phpbb_session_testable_factory;
|
|
||||||
$this->db = $this->new_dbal();
|
|
||||||
$this->session_facade =
|
|
||||||
new phpbb_session_testable_facade($this->db, $this->session_factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
static function bot($bot_agent, $user_id, $bot_ip)
|
static function bot($bot_agent, $user_id, $bot_ip)
|
||||||
{
|
{
|
||||||
return array(array(
|
return array(array(
|
||||||
|
|
|
@ -7,27 +7,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/testable_facade.php';
|
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
|
||||||
|
|
||||||
class phpbb_session_extract_hostname_test extends phpbb_database_test_case
|
class phpbb_session_extract_hostname_test extends phpbb_session_test_case
|
||||||
{
|
{
|
||||||
public $session_factory;
|
|
||||||
public $db;
|
|
||||||
public $session_facade;
|
|
||||||
|
|
||||||
public function getDataSet()
|
public function getDataSet()
|
||||||
{
|
{
|
||||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->session_factory = new phpbb_session_testable_factory;
|
|
||||||
$this->db = $this->new_dbal();
|
|
||||||
$this->session_facade =
|
|
||||||
new phpbb_session_testable_facade($this->db, $this->session_factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function extract_current_hostname_data()
|
static public function extract_current_hostname_data()
|
||||||
{
|
{
|
||||||
return array (
|
return array (
|
||||||
|
|
|
@ -7,27 +7,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/testable_facade.php';
|
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
|
||||||
|
|
||||||
class phpbb_session_extract_page_test extends phpbb_database_test_case
|
class phpbb_session_extract_page_test extends phpbb_session_test_case
|
||||||
{
|
{
|
||||||
public $session_factory;
|
|
||||||
public $db;
|
|
||||||
public $session_facade;
|
|
||||||
|
|
||||||
public function getDataSet()
|
public function getDataSet()
|
||||||
{
|
{
|
||||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->session_factory = new phpbb_session_testable_factory;
|
|
||||||
$this->db = $this->new_dbal();
|
|
||||||
$this->session_facade =
|
|
||||||
new phpbb_session_testable_facade($this->db, $this->session_factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function extract_current_page_data()
|
static public function extract_current_page_data()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -7,27 +7,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/testable_facade.php';
|
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
|
||||||
|
|
||||||
class phpbb_session_validate_referrer_test extends phpbb_database_test_case
|
class phpbb_session_validate_referrer_test extends phpbb_session_test_case
|
||||||
{
|
{
|
||||||
public $session_factory;
|
|
||||||
public $db;
|
|
||||||
public $session_facade;
|
|
||||||
|
|
||||||
public function getDataSet()
|
public function getDataSet()
|
||||||
{
|
{
|
||||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
|
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->session_factory = new phpbb_session_testable_factory;
|
|
||||||
$this->db = $this->new_dbal();
|
|
||||||
$this->session_facade =
|
|
||||||
new phpbb_session_testable_facade($this->db, $this->session_factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
static function referrer_inputs() {
|
static function referrer_inputs() {
|
||||||
$ex = "example.org";
|
$ex = "example.org";
|
||||||
$alt = "example.com";
|
$alt = "example.com";
|
||||||
|
|
27
tests/test_framework/phpbb_session_test_case.php
Normal file
27
tests/test_framework/phpbb_session_test_case.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../session/testable_factory.php';
|
||||||
|
require_once dirname(__FILE__) . '/../session/testable_facade.php';
|
||||||
|
|
||||||
|
abstract class phpbb_session_test_case extends phpbb_database_test_case
|
||||||
|
{
|
||||||
|
protected $session_factory;
|
||||||
|
protected $session_facade;
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->session_factory = new phpbb_session_testable_factory;
|
||||||
|
$this->db = $this->new_dbal();
|
||||||
|
$this->session_facade =
|
||||||
|
new phpbb_session_testable_facade($this->db, $this->session_factory);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue