Skip to content

Commit ec681ad

Browse files
authored
Merge pull request #6852 from rxu/ticket/17543-2
[ticket/17543] Optimize functional tests running time
2 parents e347fdc + f131e31 commit ec681ad

32 files changed

Lines changed: 278 additions & 340 deletions

tests/functional/acp_permissions_test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function test_change_permission($description, $permission_type, $permissi
9898
// XXX globals for \phpbb\auth\auth, refactor it later
9999
global $db, $cache;
100100
$db = $this->get_db();
101+
101102
$cache = new phpbb_mock_null_cache;
102103

103104
$auth = new \phpbb\auth\auth;

tests/functional/acp_registration_test.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ protected function set_email_enable($db, $status)
2828

2929
public function test_submitting_activation_method()
3030
{
31-
$db = $this->get_db();
32-
33-
$this->set_email_enable($db, false);
31+
$this->set_email_enable($this->db, false);
3432

3533
$this->add_lang('acp/board');
3634
$this->login();
@@ -50,6 +48,6 @@ public function test_submitting_activation_method()
5048
$crawler = self::submit($form);
5149
$this->assertNotContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text());
5250

53-
$this->set_email_enable($db, true);
51+
$this->set_email_enable($this->db, true);
5452
}
5553
}

tests/functional/auth_test.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ public function test_login_ucp_other_auth_provider()
4040
{
4141
global $cache, $config;
4242
$cache = new phpbb_mock_null_cache;
43-
$db = $this->get_db();
4443
$sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'foobar' WHERE config_name = 'auth_method'";
45-
$db->sql_query($sql);
44+
$this->db->sql_query($sql);
4645
$config['auth_method'] = 'foobar';
4746
$this->login('anothertestuser');
4847
$crawler = self::request('GET', 'index.php');
4948
$this->assertStringContainsString('anothertestuser', $crawler->filter('#username_logged_in')->text());
5049
$sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'db' WHERE config_name = 'auth_method'";
51-
$db->sql_query($sql);
50+
$this->db->sql_query($sql);
5251
$config['auth_method'] = 'db';
5352
}
5453

tests/functional/download_test.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ public function test_download_softdeleted_topic()
225225

226226
public function load_ids($data)
227227
{
228-
$this->db = $this->get_db();
229-
230228
if (!empty($data['forums']))
231229
{
232230
array_walk($data['forums'], function(&$value, $key)

tests/functional/extension_controller_test.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,33 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
2222
'./',
2323
);
2424

25-
static public function setUpBeforeClass(): void
25+
public static function setUpBeforeClass(): void
2626
{
2727
parent::setUpBeforeClass();
2828

2929
self::$helper = new phpbb_test_case_helpers(__CLASS__);
3030
self::$helper->copy_ext_fixtures(__DIR__ . '/fixtures/ext/', self::$fixtures);
31+
32+
self::install_ext('foo/bar');
33+
self::install_ext('foo/foo');
3134
}
3235

33-
static public function tearDownAfterClass(): void
36+
public static function tearDownAfterClass(): void
3437
{
3538
parent::tearDownAfterClass();
3639

40+
self::uninstall_ext('foo/bar');
41+
self::uninstall_ext('foo/foo');
3742
self::$helper->restore_original_ext_dir();
3843
}
3944

40-
protected static function setup_extensions()
41-
{
42-
return ['foo/bar', 'foo/foo'];
43-
}
44-
4545
protected function setUp(): void
4646
{
4747
parent::setUp();
4848

4949
$this->purge_cache();
5050
}
5151

52-
protected function tearDown(): void
53-
{
54-
$this->uninstall_ext('foo/bar');
55-
$this->uninstall_ext('foo/foo');
56-
57-
parent::tearDown();
58-
}
59-
6052
/**
6153
* Check a controller for extension foo/bar.
6254
*/

tests/functional/extension_module_test.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,24 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
2323
'./',
2424
);
2525

26-
static public function setUpBeforeClass(): void
26+
public static function setUpBeforeClass(): void
2727
{
2828
parent::setUpBeforeClass();
2929

3030
self::$helper = new phpbb_test_case_helpers(__CLASS__);
3131
self::$helper->copy_ext_fixtures(__DIR__ . '/fixtures/ext/', self::$fixtures);
32+
33+
self::install_ext('foo/bar');
3234
}
3335

34-
static public function tearDownAfterClass(): void
36+
public static function tearDownAfterClass(): void
3537
{
3638
parent::tearDownAfterClass();
3739

40+
self::uninstall_ext('foo/bar');
3841
self::$helper->restore_original_ext_dir();
3942
}
4043

41-
protected function tearDown(): void
42-
{
43-
$this->uninstall_ext('foo/bar');
44-
45-
parent::tearDown();
46-
}
47-
48-
protected static function setup_extensions()
49-
{
50-
return ['foo/bar'];
51-
}
52-
5344
public function test_acp()
5445
{
5546
$this->add_lang('common');

tests/functional/extension_template_event_order_test.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,29 @@
1616
*/
1717
class phpbb_functional_extension_template_event_order_test extends phpbb_functional_test_case
1818
{
19-
static private $helper;
19+
private static $helper;
2020

21-
static protected $fixtures = [
21+
protected static $fixtures = [
2222
'./',
2323
];
2424

25-
static public function setUpBeforeClass(): void
25+
public static function setUpBeforeClass(): void
2626
{
2727
parent::setUpBeforeClass();
2828

2929
self::$helper = new phpbb_test_case_helpers(__CLASS__);
3030
self::$helper->copy_ext_fixtures(__DIR__ . '/fixtures/ext/', self::$fixtures);
31+
32+
self::install_ext('foo/bar');
33+
self::install_ext('foo/foo');
3134
}
3235

33-
static public function tearDownAfterClass(): void
36+
public static function tearDownAfterClass(): void
3437
{
3538
parent::tearDownAfterClass();
3639

40+
self::uninstall_ext('foo/bar');
41+
self::uninstall_ext('foo/foo');
3742
self::$helper->restore_original_ext_dir();
3843
}
3944

@@ -44,18 +49,6 @@ protected function setUp(): void
4449
$this->purge_cache();
4550
}
4651

47-
protected function tearDown(): void
48-
{
49-
$this->uninstall_ext('foo/bar');
50-
$this->uninstall_ext('foo/foo');
51-
52-
parent::tearDown();
53-
}
54-
55-
protected static function setup_extensions()
56-
{
57-
return ['foo/bar', 'foo/foo'];
58-
}
5952

6053
/**
6154
* Check extensions template event listener prioritizing
@@ -84,7 +77,7 @@ public function test_different_template_event_priority()
8477
$crawler = self::request('GET', 'index.php');
8578
$quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0);
8679
$quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count();
87-
// Ensure foo/foo template event goes before foo/bar one
80+
// Ensure foo/bar template event goes before foo/foo one
8881
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text());
8982
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text());
9083
}

tests/functional/feed_test.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,8 +1450,6 @@ protected function assert_feed($params, $data)
14501450

14511451
protected function load_ids($data)
14521452
{
1453-
$this->db = $this->get_db();
1454-
14551453
if (!empty($data['forums']))
14561454
{
14571455
$sql = 'SELECT *

tests/functional/forum_style_test.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ public function test_default_forum_style()
3030

3131
public function test_custom_forum_style()
3232
{
33-
$db = $this->get_db();
3433
$this->add_style(2, 'test_style');
35-
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2');
34+
$this->db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2');
3635

3736
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
3837
$this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
@@ -43,7 +42,7 @@ public function test_custom_forum_style()
4342
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
4443
$this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
4544

46-
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2');
45+
$this->db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2');
4746
$this->delete_style(2, 'test_style');
4847
}
4948
}

tests/functional/mcp/mcp_main_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function test_create_topic_with_replies()
208208
// Create replies. Flood control was disabled above
209209
for ($i = 1; $i <= 15; $i++)
210210
{
211-
sleep(1);
211+
usleep(100000);
212212
$post_text = "This is reply number $i to the Test Topic 4 to test moderation actions from MCP/View topic page.";
213213
$post[$i] = $this->create_post(2, $post[0]['topic_id'], 'Re: Test Topic 4', $post_text);
214214
$crawler = self::request('GET', "viewtopic.php?p={$post[$i]['post_id']}&sid={$this->sid}#p{$post[$i]['post_id']}");

0 commit comments

Comments
 (0)