Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 97 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_extension_module_test | |
0.00% |
0 / 97 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
| setUpBeforeClass | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| tearDownAfterClass | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| test_acp | |
0.00% |
0 / 77 |
|
0.00% |
0 / 1 |
2 | |||
| test_ucp | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_mcp | |
0.00% |
0 / 7 |
|
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 | require_once __DIR__ . '/../../phpBB/includes/acp/acp_modules.php'; |
| 14 | |
| 15 | /** |
| 16 | * @group functional |
| 17 | */ |
| 18 | class phpbb_functional_extension_module_test extends phpbb_functional_test_case |
| 19 | { |
| 20 | private static $helper; |
| 21 | |
| 22 | protected static $fixtures = array( |
| 23 | './', |
| 24 | ); |
| 25 | |
| 26 | public static function setUpBeforeClass(): void |
| 27 | { |
| 28 | parent::setUpBeforeClass(); |
| 29 | |
| 30 | self::$helper = new phpbb_test_case_helpers(__CLASS__); |
| 31 | self::$helper->copy_ext_fixtures(__DIR__ . '/fixtures/ext/', self::$fixtures); |
| 32 | |
| 33 | self::install_ext('foo/bar'); |
| 34 | } |
| 35 | |
| 36 | public static function tearDownAfterClass(): void |
| 37 | { |
| 38 | parent::tearDownAfterClass(); |
| 39 | |
| 40 | self::uninstall_ext('foo/bar'); |
| 41 | self::$helper->restore_original_ext_dir(); |
| 42 | } |
| 43 | |
| 44 | public function test_acp() |
| 45 | { |
| 46 | $this->add_lang('common'); |
| 47 | $this->login(); |
| 48 | $this->admin_login(); |
| 49 | |
| 50 | $crawler = self::request('GET', 'adm/index.php?i=-foo-bar-acp-main_module&mode=mode&sid=' . $this->sid); |
| 51 | $this->assertStringContainsString('ACP_FOOBAR_SETTINGS', $crawler->filter('#main')->text()); |
| 52 | $this->assertContainsLang('GENERAL_SETTINGS', $crawler->filter('fieldset')->text()); |
| 53 | |
| 54 | $this->assertStringContainsString('SETTING_0', $crawler->filter('dl')->eq(0)->filter('dt > label[for="setting_0"]')->text()); |
| 55 | $this->assertStringContainsString('SETTING_0_EXPLAIN', $crawler->filter('dl')->eq(0)->filter('dt > span')->text()); |
| 56 | $this->assertEquals(2, $crawler->filter('dl')->eq(0)->filter('dd > input[type="number"]')->count()); |
| 57 | $this->assertEquals(1, $crawler->filter('dl')->eq(0)->filter('dd > input[type="number"]')->eq(0)->attr('value')); |
| 58 | $this->assertEquals(17, $crawler->filter('dl')->eq(0)->filter('dd > input[type="number"]')->eq(1)->attr('value')); |
| 59 | |
| 60 | $this->assertStringContainsString('SETTING_1', $crawler->filter('dl')->eq(1)->filter('dt > label[for="setting_1"]')->text()); |
| 61 | $this->assertStringContainsString('CUSTOM_LANG_EXPLAIN', $crawler->filter('dl')->eq(1)->filter('dt > span')->text()); |
| 62 | $this->assertEquals(1, $crawler->filter('dl')->eq(1)->filter('dd > input[type="submit"]')->count()); |
| 63 | $this->assertEquals('Test submit button', $crawler->filter('dl')->eq(1)->filter('dd > input[type="submit"]')->attr('value')); |
| 64 | |
| 65 | $this->assertStringContainsString('SETTING_2', $crawler->filter('dl')->eq(2)->filter('dt > label[for="setting_2"]')->text()); |
| 66 | $this->assertEquals(0, $crawler->filter('dl')->eq(2)->filter('dt > span')->count()); |
| 67 | $this->assertEquals(2, $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->count()); |
| 68 | $this->assertContainsLang('YES', $crawler->filter('dl')->eq(2)->filter('dd > label')->eq(0)->text()); |
| 69 | $this->assertEquals(1, $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value')); |
| 70 | $this->assertEquals('checked', $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->eq(0)->attr('checked')); |
| 71 | $this->assertContainsLang('NO', $crawler->filter('dl')->eq(2)->filter('dd > label')->eq(1)->text()); |
| 72 | $this->assertEquals(0, $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value')); |
| 73 | |
| 74 | $this->assertStringContainsString('SETTING_3', $crawler->filter('dl')->eq(3)->filter('dt > label[for="setting_3"]')->text()); |
| 75 | $this->assertStringContainsString('SETTING_3_EXPLAIN', $crawler->filter('dl')->eq(3)->filter('dt > span')->text()); |
| 76 | $this->assertEquals(1, $crawler->filter('dl')->eq(3)->filter('dd > input[type="number"]')->count()); |
| 77 | $this->assertEquals(15, $crawler->filter('dl')->eq(3)->filter('dd > input[type="number"]')->attr('value')); |
| 78 | |
| 79 | $this->assertStringContainsString('SETTING_4', $crawler->filter('dl')->eq(4)->filter('dt > label[for="setting_4"]')->text()); |
| 80 | $this->assertStringContainsString('SETTING_4_EXPLAIN', $crawler->filter('dl')->eq(4)->filter('dt > span')->text()); |
| 81 | $this->assertEquals(1, $crawler->filter('dl')->eq(4)->filter('dd > select[id="setting_4"]')->count()); |
| 82 | $this->assertEquals(3, $crawler->filter('dl')->eq(4)->filter('dd > select > option')->count()); |
| 83 | $this->assertEquals(2, $crawler->filter('dl')->eq(4)->filter('dd > select > option')->eq(1)->attr('value')); |
| 84 | $this->assertEquals('selected', $crawler->filter('dl')->eq(4)->filter('dd > select > option')->eq(1)->attr('selected')); |
| 85 | |
| 86 | $this->assertStringContainsString('SETTING_5', $crawler->filter('dl')->eq(5)->filter('dt > label[for="setting_5"]')->text()); |
| 87 | $this->assertStringContainsString('SETTING_5_EXPLAIN', $crawler->filter('dl')->eq(5)->filter('dt > span')->text()); |
| 88 | $this->assertEquals(1, $crawler->filter('dl')->eq(5)->filter('dd > input[type="text"]')->count()); |
| 89 | $this->assertEquals('Setting 5', $crawler->filter('dl')->eq(5)->filter('dd > input[type="text"]')->attr('value')); |
| 90 | |
| 91 | $this->assertStringContainsString('SETTING_6', $crawler->filter('dl')->eq(6)->filter('dt > label[for="setting_6"]')->text()); |
| 92 | $this->assertStringContainsString('SETTING_6_EXPLAIN', $crawler->filter('dl')->eq(6)->filter('dt > span')->text()); |
| 93 | $this->assertEquals(1, $crawler->filter('dl')->eq(6)->filter('dd > input[type="password"]')->count()); |
| 94 | $this->assertEquals('********', $crawler->filter('dl')->eq(6)->filter('dd > input[type="password"]')->attr('value')); |
| 95 | |
| 96 | $this->assertStringContainsString('SETTING_7', $crawler->filter('dl')->eq(7)->filter('dt > label[for="setting_7"]')->text()); |
| 97 | $this->assertStringContainsString('SETTING_7_EXPLAIN', $crawler->filter('dl')->eq(7)->filter('dt > span')->text()); |
| 98 | $this->assertEquals(1, $crawler->filter('dl')->eq(7)->filter('dd > input[type="email"]')->count()); |
| 99 | $this->assertEquals('test@example.dom', $crawler->filter('dl')->eq(7)->filter('dd > input[type="email"]')->attr('value')); |
| 100 | |
| 101 | $this->assertStringContainsString('SETTING_8', $crawler->filter('dl')->eq(8)->filter('dt > label[for="setting_8"]')->text()); |
| 102 | $this->assertStringContainsString('SETTING_8_EXPLAIN', $crawler->filter('dl')->eq(8)->filter('dt > span')->text()); |
| 103 | $this->assertEquals(1, $crawler->filter('dl')->eq(8)->filter('dd > textarea[name="config[setting_8]"]')->count()); |
| 104 | $this->assertEquals('Textarea', $crawler->filter('dl')->eq(8)->filter('dd > textarea[name="config[setting_8]"]')->text()); |
| 105 | |
| 106 | $this->assertStringContainsString('SETTING_9', $crawler->filter('dl')->eq(9)->filter('dt > label[for="setting_9"]')->text()); |
| 107 | $this->assertStringContainsString('SETTING_9_EXPLAIN', $crawler->filter('dl')->eq(9)->filter('dt > span')->text()); |
| 108 | $this->assertEquals(2, $crawler->filter('dl')->eq(9)->filter('dd > label > input[type="radio"]')->count()); |
| 109 | $this->assertEquals('checked', $crawler->filter('dl')->eq(9)->filter('dd > label > input[type="radio"]')->eq(0)->attr('checked')); |
| 110 | |
| 111 | $this->assertStringContainsString('SETTING_10', $crawler->filter('dl')->eq(10)->filter('dt > label[for="setting_10"]')->text()); |
| 112 | $this->assertStringContainsString('SETTING_10_EXPLAIN', $crawler->filter('dl')->eq(10)->filter('dt > span')->text()); |
| 113 | $this->assertEquals(3, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->count()); |
| 114 | $this->assertEquals(1, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value')); |
| 115 | $this->assertStringContainsString('LABEL_1', $crawler->filter('dl')->eq(10)->filter('dd > label')->eq(0)->text()); |
| 116 | $this->assertEquals(3, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value')); |
| 117 | $this->assertEquals('checked', $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(1)->attr('checked')); |
| 118 | $this->assertStringContainsString('LABEL_3', $crawler->filter('dl')->eq(10)->filter('dd > label')->eq(1)->text()); |
| 119 | $this->assertEquals(2, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(2)->attr('value')); |
| 120 | $this->assertStringContainsString('LABEL_2', $crawler->filter('dl')->eq(10)->filter('dd > label')->eq(2)->text()); |
| 121 | |
| 122 | $this->assertStringContainsString('SETTING_11', $crawler->filter('dl')->eq(11)->filter('dt > label[for="setting_11"]')->text()); |
| 123 | $this->assertStringContainsString('SETTING_11_EXPLAIN', $crawler->filter('dl')->eq(11)->filter('dt > span')->text()); |
| 124 | $this->assertEquals('1', $crawler->filter('dl')->eq(11)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value')); |
| 125 | $this->assertEquals('0', $crawler->filter('dl')->eq(11)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value')); |
| 126 | $this->assertEquals('checked', $crawler->filter('dl')->eq(11)->filter('dd > label > input[type="radio"]')->eq(1)->attr('checked')); |
| 127 | $this->assertContainsLang('YES', $crawler->filter('dl')->eq(11)->filter('dd > label')->eq(0)->text()); |
| 128 | $this->assertContainsLang('NO', $crawler->filter('dl')->eq(11)->filter('dd > label')->eq(1)->text()); |
| 129 | |
| 130 | $this->assertStringContainsString('SETTING_12', $crawler->filter('dl')->eq(12)->filter('dt > label[for="setting_12"]')->text()); |
| 131 | $this->assertStringContainsString('SETTING_12_EXPLAIN', $crawler->filter('dl')->eq(12)->filter('dt > span')->text()); |
| 132 | $this->assertContainsLang('ENABLED', $crawler->filter('dl')->eq(12)->filter('dd > label')->eq(0)->text()); |
| 133 | $this->assertEquals(1, $crawler->filter('dl')->eq(12)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value')); |
| 134 | $this->assertContainsLang('DISABLED', $crawler->filter('dl')->eq(12)->filter('dd > label')->eq(1)->text()); |
| 135 | $this->assertEquals(0, $crawler->filter('dl')->eq(12)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value')); |
| 136 | $this->assertEquals('checked', $crawler->filter('dl')->eq(12)->filter('dd > label > input[type="radio"]')->eq(1)->attr('checked')); |
| 137 | } |
| 138 | |
| 139 | public function test_ucp() |
| 140 | { |
| 141 | $this->login(); |
| 142 | |
| 143 | $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid); |
| 144 | $this->assertStringContainsString('UCP_FOOBAR', $crawler->filter('#navigation')->text()); |
| 145 | |
| 146 | $link = $crawler->selectLink('UCP_FOOBAR')->link()->getUri(); |
| 147 | $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); |
| 148 | $this->assertStringContainsString('UCP Extension Template Test Passed!', $crawler->filter('#content')->text()); |
| 149 | } |
| 150 | |
| 151 | public function test_mcp() |
| 152 | { |
| 153 | $this->login(); |
| 154 | $this->admin_login(); |
| 155 | |
| 156 | $crawler = self::request('GET', 'mcp.php?sid=' . $this->sid); |
| 157 | $this->assertStringContainsString('MCP_FOOBAR', $crawler->filter('#navigation')->text()); |
| 158 | |
| 159 | $link = $crawler->selectLink('MCP_FOOBAR')->link()->getUri(); |
| 160 | $crawler = self::request('GET', substr($link, strpos($link, 'mcp.'))); |
| 161 | $this->assertStringContainsString('MCP Extension Template Test Passed!', $crawler->filter('#content')->text()); |
| 162 | } |
| 163 | } |