diff options
| author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-12-13 03:11:07 -0500 |
|---|---|---|
| committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-12-13 03:11:07 -0500 |
| commit | a4e48410821e2569a4561e06f1627cb9dbce76ca (patch) | |
| tree | d3b26d0e72c2eb482ccd7972aec3e717f6d920cd /tests/test_framework/phpbb_functional_test_case.php | |
| parent | 3c542b852a99f62337c8cf1c6d3e6551c4e3dca1 (diff) | |
| parent | 1441b70ae8e97782ae63c479b0635c1622078a48 (diff) | |
| download | forums-a4e48410821e2569a4561e06f1627cb9dbce76ca.tar forums-a4e48410821e2569a4561e06f1627cb9dbce76ca.tar.gz forums-a4e48410821e2569a4561e06f1627cb9dbce76ca.tar.bz2 forums-a4e48410821e2569a4561e06f1627cb9dbce76ca.tar.xz forums-a4e48410821e2569a4561e06f1627cb9dbce76ca.zip | |
Merge PR #1119 branch 'p/ticket/10491' into develop-olympus
* p/ticket/10491:
[ticket/10491] Make recreate_database static.
[ticket/10491] Install board once per test run.
[ticket/10491] Move board installation into setup before class.
[ticket/10491] Set up functional tests sensibly.
Diffstat (limited to 'tests/test_framework/phpbb_functional_test_case.php')
| -rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 71e88fbcf6..93a4ab2fbf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -35,13 +35,30 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $config = array(); static protected $already_installed = false; - public function setUp() + static public function setUpBeforeClass() { + parent::setUpBeforeClass(); + + self::$config = phpbb_test_case_helpers::get_test_config(); + if (!isset(self::$config['phpbb_functional_url'])) { - $this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); + self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } + if (!self::$already_installed) + { + self::install_board(); + self::$already_installed = true; + } + } + + public function setUp() + { + parent::setUp(); + + $this->bootstrap(); + $this->cookieJar = new CookieJar; $this->client = new Goutte\Client(array(), null, $this->cookieJar); // Reset the curl handle because it is 0 at this point and not a valid @@ -110,28 +127,14 @@ class phpbb_functional_test_case extends phpbb_test_case $this->backupStaticAttributesBlacklist += array( 'phpbb_functional_test_case' => array('config', 'already_installed'), ); - - if (!static::$already_installed) - { - $this->install_board(); - $this->bootstrap(); - static::$already_installed = true; - } } - protected function install_board() + static protected function install_board() { global $phpbb_root_path, $phpEx; - self::$config = phpbb_test_case_helpers::get_test_config(); - - if (!isset(self::$config['phpbb_functional_url'])) - { - return; - } - self::$config['table_prefix'] = 'phpbb_'; - $this->recreate_database(self::$config); + self::recreate_database(self::$config); if (file_exists($phpbb_root_path . "config.$phpEx")) { @@ -176,19 +179,20 @@ class phpbb_functional_test_case extends phpbb_test_case )); // end data - $content = $this->do_request('install'); - $this->assertContains('Welcome to Installation', $content); + $content = self::do_request('install'); + self::assertNotSame(false, $content); + self::assertContains('Welcome to Installation', $content); - $this->do_request('create_table', $data); + self::do_request('create_table', $data); - $this->do_request('config_file', $data); + self::do_request('config_file', $data); file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true)); - $this->do_request('final', $data); + self::do_request('final', $data); copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); } - private function do_request($sub, $post_data = null) + static private function do_request($sub, $post_data = null) { $context = null; @@ -207,7 +211,7 @@ class phpbb_functional_test_case extends phpbb_test_case return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context); } - private function recreate_database($config) + static private function recreate_database($config) { $db_conn_mgr = new phpbb_database_test_connection_manager($config); $db_conn_mgr->recreate_db(); |
