Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 32 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_extension_template_event_order_test | |
0.00% |
0 / 32 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
| setUpBeforeClass | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| tearDownAfterClass | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| setUp | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| test_different_template_event_priority | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| test_same_template_event_priority | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * @group functional |
| 16 | */ |
| 17 | class phpbb_functional_extension_template_event_order_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | private static $helper; |
| 20 | |
| 21 | protected static $fixtures = [ |
| 22 | './', |
| 23 | ]; |
| 24 | |
| 25 | public static function setUpBeforeClass(): void |
| 26 | { |
| 27 | parent::setUpBeforeClass(); |
| 28 | |
| 29 | self::$helper = new phpbb_test_case_helpers(__CLASS__); |
| 30 | self::$helper->copy_ext_fixtures(__DIR__ . '/fixtures/ext/', self::$fixtures); |
| 31 | |
| 32 | self::install_ext('foo/bar'); |
| 33 | self::install_ext('foo/foo'); |
| 34 | } |
| 35 | |
| 36 | public static function tearDownAfterClass(): void |
| 37 | { |
| 38 | parent::tearDownAfterClass(); |
| 39 | |
| 40 | self::uninstall_ext('foo/bar'); |
| 41 | self::uninstall_ext('foo/foo'); |
| 42 | self::$helper->restore_original_ext_dir(); |
| 43 | } |
| 44 | |
| 45 | protected function setUp(): void |
| 46 | { |
| 47 | parent::setUp(); |
| 48 | |
| 49 | $this->purge_cache(); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | /** |
| 54 | * Check extensions template event listener prioritizing |
| 55 | */ |
| 56 | public function test_different_template_event_priority() |
| 57 | { |
| 58 | global $phpbb_root_path; |
| 59 | |
| 60 | $crawler = self::request('GET', 'index.php'); |
| 61 | $quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0); |
| 62 | $quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count(); |
| 63 | // Ensure foo/foo template event goes before foo/bar one |
| 64 | $this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text()); |
| 65 | $this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text()); |
| 66 | |
| 67 | // Change template events order to default, put foo/bar event before foo/foo one |
| 68 | $this->disable_ext('foo/bar'); |
| 69 | $this->disable_ext('foo/foo'); |
| 70 | |
| 71 | $this->assertTrue(copy(__DIR__ . '/fixtures/ext/foo/bar/event/template_event_order_higher.php', $phpbb_root_path . 'ext/foo/bar/event/template_event_order.php')); |
| 72 | $this->assertTrue(copy(__DIR__ . '/fixtures/ext/foo/foo/event/template_event_order_lower.php', $phpbb_root_path . 'ext/foo/foo/event/template_event_order.php')); |
| 73 | |
| 74 | $this->install_ext('foo/bar'); |
| 75 | $this->install_ext('foo/foo'); |
| 76 | |
| 77 | $crawler = self::request('GET', 'index.php'); |
| 78 | $quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0); |
| 79 | $quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count(); |
| 80 | // Ensure foo/bar template event goes before foo/foo one |
| 81 | $this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text()); |
| 82 | $this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text()); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Check extensions template event listener equal (default - 0) priority rendering |
| 87 | * Should render in the order of reading listener files from the filesystem |
| 88 | */ |
| 89 | public function test_same_template_event_priority() |
| 90 | { |
| 91 | global $phpbb_root_path; |
| 92 | |
| 93 | $crawler = self::request('GET', 'index.php'); |
| 94 | // Ensure foo/bar template event goes before foo/foo one (assuming they have been read from the filesystem in alphabetical order) |
| 95 | $this->assertStringContainsString('FOO_BAR_FORUMLIST_BODY_BEFORE', $crawler->filter('p[id*="forumlist_body_before"]')->eq(0)->text()); |
| 96 | $this->assertStringContainsString('FOO_FOO_FORUMLIST_BODY_BEFORE', $crawler->filter('p[id*="forumlist_body_before"]')->eq(1)->text()); |
| 97 | } |
| 98 | } |