Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 210 |
|
0.00% |
0 / 14 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_extension_acp_test | |
0.00% |
0 / 210 |
|
0.00% |
0 / 14 |
552 | |
0.00% |
0 / 1 |
| setUpBeforeClass | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| tearDownAfterClass | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| setUp | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
2 | |||
| mock_extensions_catalog_cache | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| test_list | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
2 | |||
| test_details | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
30 | |||
| test_enable_pre | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
| test_disable_pre | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_delete_data_pre | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| test_actions | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
2 | |||
| test_extensions_catalog | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 | |||
| test_extensions_catalog_installing_extension | |
0.00% |
0 / 32 |
|
0.00% |
0 / 1 |
42 | |||
| test_extensions_catalog_updating_extension | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
2 | |||
| test_extensions_catalog_removing_extension | |
0.00% |
0 / 12 |
|
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_acp_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | private static $helper; |
| 20 | |
| 21 | protected static $fixtures = array( |
| 22 | './', |
| 23 | ); |
| 24 | |
| 25 | static public function setUpBeforeClass(): void |
| 26 | { |
| 27 | parent::setUpBeforeClass(); |
| 28 | |
| 29 | self::$helper = new phpbb_test_case_helpers(__CLASS__); |
| 30 | self::$helper->copy_ext_fixtures(__DIR__ . '/../extension/ext/', self::$fixtures); |
| 31 | } |
| 32 | |
| 33 | static public function tearDownAfterClass(): void |
| 34 | { |
| 35 | parent::tearDownAfterClass(); |
| 36 | |
| 37 | self::$helper->restore_original_ext_dir(); |
| 38 | } |
| 39 | |
| 40 | protected function setUp(): void |
| 41 | { |
| 42 | parent::setUp(); |
| 43 | |
| 44 | $this->purge_cache(); |
| 45 | |
| 46 | // Clear the phpbb_ext table |
| 47 | $this->db->sql_query('DELETE FROM phpbb_ext'); |
| 48 | |
| 49 | // Insert our base data |
| 50 | $insert_rows = array( |
| 51 | array( |
| 52 | 'ext_name' => 'vendor2/foo', |
| 53 | 'ext_active' => true, |
| 54 | 'ext_state' => 'b:0;', |
| 55 | ), |
| 56 | array( |
| 57 | 'ext_name' => 'vendor/moo', |
| 58 | 'ext_active' => false, |
| 59 | 'ext_state' => 'b:0;', |
| 60 | ), |
| 61 | |
| 62 | // do not exist |
| 63 | array( |
| 64 | 'ext_name' => 'vendor/test2', |
| 65 | 'ext_active' => true, |
| 66 | 'ext_state' => 'b:0;', |
| 67 | ), |
| 68 | array( |
| 69 | 'ext_name' => 'vendor/test3', |
| 70 | 'ext_active' => false, |
| 71 | 'ext_state' => 'b:0;', |
| 72 | ), |
| 73 | ); |
| 74 | $this->db->sql_multi_insert('phpbb_ext', $insert_rows); |
| 75 | |
| 76 | $this->login(); |
| 77 | $this->admin_login(); |
| 78 | |
| 79 | $this->add_lang(['acp/common', 'acp/extensions']); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Mocks the extensions catalog cache used in phpBB/phpbb/composer/manager.php |
| 84 | * with a predefined fixture so no external calls are made. |
| 85 | */ |
| 86 | protected function mock_extensions_catalog_cache():void { |
| 87 | $fixture_file = __DIR__ . '/fixtures/files/extensions_catalog.json'; |
| 88 | $package_type = 'phpbb-extension'; |
| 89 | |
| 90 | $available_extensions = json_decode(file_get_contents($fixture_file), true); |
| 91 | $this->cache->put('_composer_' . $package_type . '_available', $available_extensions, 24*60*60); |
| 92 | } |
| 93 | |
| 94 | public function test_list() |
| 95 | { |
| 96 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 97 | |
| 98 | $this->assertCount(1, $crawler->filter('.ext_enabled')); |
| 99 | $this->assertCount(3, $crawler->filter('.ext_disabled')); |
| 100 | $this->assertCount(4, $crawler->filter('.ext_not_installed')); |
| 101 | |
| 102 | $this->assertStringContainsString('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); |
| 103 | $this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); |
| 104 | |
| 105 | $this->assertStringContainsString('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); |
| 106 | $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); |
| 107 | $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); |
| 108 | $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text()); |
| 109 | |
| 110 | $this->assertStringContainsString('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); |
| 111 | |
| 112 | $this->assertStringContainsString('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); |
| 113 | |
| 114 | $this->assertStringContainsString('phpBB Bar Extension', $crawler->filter('.ext_not_installed')->eq(0)->text()); |
| 115 | $this->assertContainsLang('DETAILS', $crawler->filter('.ext_not_installed')->eq(0)->text()); |
| 116 | $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_not_installed')->eq(0)->text()); |
| 117 | |
| 118 | // Check that invalid extensions are not listed. |
| 119 | $this->assertStringNotContainsString('phpBB BarFoo Extension', $crawler->filter('.table1')->text()); |
| 120 | $this->assertStringNotContainsString('barfoo', $crawler->filter('.table1')->text()); |
| 121 | |
| 122 | $this->assertStringNotContainsString('vendor3/bar', $crawler->filter('.table1')->text()); |
| 123 | } |
| 124 | |
| 125 | public function test_details() |
| 126 | { |
| 127 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=vendor2%2Ffoo&sid=' . $this->sid); |
| 128 | |
| 129 | $validation = array( |
| 130 | 'DISPLAY_NAME' => 'phpBB Foo Extension', |
| 131 | 'CLEAN_NAME' => 'vendor2/foo', |
| 132 | 'TYPE' => 'phpbb-extension', |
| 133 | 'DESCRIPTION' => 'An example/sample extension to be used for testing purposes in phpBB Development.', |
| 134 | 'VERSION' => '1.0.0', |
| 135 | 'TIME' => '2012-02-15 01:01:01', |
| 136 | 'LICENSE' => 'GPL-2.0', |
| 137 | 'PHPBB_VERSION' => '3.1.*@dev', |
| 138 | 'PHP_VERSION' => '>=5.3', |
| 139 | 'AUTHOR_NAME' => 'John Smith', |
| 140 | 'AUTHOR_EMAIL' => 'email@phpbb.com', |
| 141 | 'AUTHOR_HOMEPAGE' => 'http://phpbb.com', |
| 142 | 'AUTHOR_ROLE' => 'N/A', |
| 143 | ); |
| 144 | |
| 145 | for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) |
| 146 | { |
| 147 | $text = trim($crawler->filter('dl')->eq($i)->text()); |
| 148 | |
| 149 | $match = false; |
| 150 | |
| 151 | foreach ($validation as $language_key => $expected) |
| 152 | { |
| 153 | if (strpos($text, $this->lang($language_key)) === 0) |
| 154 | { |
| 155 | $match = true; |
| 156 | |
| 157 | $this->assertStringContainsString($expected, $text); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if (!$match) |
| 162 | { |
| 163 | $this->fail('Unexpected field: "' . $text . '"'); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | public function test_enable_pre() |
| 169 | { |
| 170 | // Foo is already enabled (redirect to list) |
| 171 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); |
| 172 | $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); |
| 173 | $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); |
| 174 | $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); |
| 175 | |
| 176 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 177 | $this->assertStringContainsString($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('#main')->text()); |
| 178 | |
| 179 | // Correctly submit the enable form, default not enableable message |
| 180 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor3%2Ffoo&sid=' . $this->sid); |
| 181 | $this->assertContainsLang('EXTENSION_NOT_ENABLEABLE', $crawler->filter('.errorbox')->text()); |
| 182 | |
| 183 | // Custom reason messages returned by not enableable extension |
| 184 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor5%2Ffoo&sid=' . $this->sid); |
| 185 | $this->assertStringContainsString('Reason 1', $crawler->filter('.errorbox')->text()); |
| 186 | $this->assertStringContainsString('Reason 2', $crawler->filter('.errorbox')->text()); |
| 187 | } |
| 188 | |
| 189 | public function test_disable_pre() |
| 190 | { |
| 191 | // Moo is not enabled (redirect to list) |
| 192 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 193 | $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); |
| 194 | $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); |
| 195 | $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); |
| 196 | |
| 197 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); |
| 198 | $this->assertStringContainsString($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('#main')->text()); |
| 199 | } |
| 200 | |
| 201 | public function test_delete_data_pre() |
| 202 | { |
| 203 | // test2 is not available (error) |
| 204 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid); |
| 205 | $this->assertStringContainsString($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('.errorbox')->text()); |
| 206 | |
| 207 | // foo is not disabled (redirect to list) |
| 208 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); |
| 209 | $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); |
| 210 | $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); |
| 211 | $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); |
| 212 | |
| 213 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 214 | $this->assertStringContainsString('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text()); |
| 215 | } |
| 216 | |
| 217 | public function test_actions() |
| 218 | { |
| 219 | // Access enable page without hash |
| 220 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 221 | $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); |
| 222 | |
| 223 | // Correctly submit the enable form |
| 224 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 225 | $form = $crawler->selectButton('enable')->form(); |
| 226 | $crawler = self::submit($form); |
| 227 | $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text()); |
| 228 | |
| 229 | // Access disable page without hash |
| 230 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 231 | $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); |
| 232 | |
| 233 | // Correctly submit the disable form |
| 234 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 235 | $form = $crawler->selectButton('disable')->form(); |
| 236 | $crawler = self::submit($form); |
| 237 | $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text()); |
| 238 | |
| 239 | // Access delete_data page without hash |
| 240 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 241 | $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); |
| 242 | |
| 243 | // Correctly submit the delete data form |
| 244 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); |
| 245 | $form = $crawler->selectButton('delete_data')->form(); |
| 246 | $crawler = self::submit($form); |
| 247 | $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text()); |
| 248 | |
| 249 | // Attempt to enable invalid extension |
| 250 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=barfoo&sid=' . $this->sid); |
| 251 | $this->assertContainsLang('EXTENSION_DIR_INVALID', $crawler->filter('.errorbox')->text()); |
| 252 | |
| 253 | // Test installing/uninstalling extension altogether |
| 254 | $this->logout(); |
| 255 | $this->install_ext('vendor/moo'); |
| 256 | $this->uninstall_ext('vendor/moo'); |
| 257 | } |
| 258 | |
| 259 | public function test_extensions_catalog() |
| 260 | { |
| 261 | // Access extensions catalog main page |
| 262 | $this->mock_extensions_catalog_cache(); |
| 263 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&sid=' . $this->sid); |
| 264 | $this->assertContainsLang('ACP_EXTENSIONS_CATALOG', $this->get_content()); |
| 265 | |
| 266 | $this->assertContainsLang('BROWSE_EXTENSIONS_DATABASE', $crawler->filter('fieldset[class="quick quick-left"] > span > a')->eq(0)->text()); |
| 267 | $this->assertContainsLang('SETTINGS', $crawler->filter('fieldset[class="quick quick-left"] > span > a')->eq(1)->text()); |
| 268 | |
| 269 | $form = $crawler->selectButton('Submit')->form(); |
| 270 | $form['minimum_stability']->select('dev'); |
| 271 | $form['repositories'] = 'https://satis.phpbb.com/'; |
| 272 | $crawler = self::submit($form); |
| 273 | $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); |
| 274 | |
| 275 | // Revisit extensions catalog main page after configuration change |
| 276 | $this->mock_extensions_catalog_cache(); |
| 277 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&sid=' . $this->sid); |
| 278 | $this->assertContainsLang('ACP_EXTENSIONS_CATALOG', $this->get_content()); |
| 279 | |
| 280 | // Ensure catalog has any records in extensions list |
| 281 | $this->assertGreaterThan(0, $crawler->filter('tbody > tr > td > strong')->count()); |
| 282 | } |
| 283 | |
| 284 | public function test_extensions_catalog_installing_extension() |
| 285 | { |
| 286 | // Let's check the overview, multiple packages should be listed |
| 287 | $this->mock_extensions_catalog_cache(); |
| 288 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&sid=' . $this->sid); |
| 289 | $this->assertContainsLang('ACP_EXTENSIONS_CATALOG', $this->get_content()); |
| 290 | $this->assertGreaterThan(1, $crawler->filter('tr')->count()); |
| 291 | $this->assertGreaterThan(1, $crawler->selectLink($this->lang('INSTALL'))->count()); |
| 292 | |
| 293 | $pages = 1; |
| 294 | $pagination = $crawler->filter('div.pagination li:nth-last-child(2) a'); |
| 295 | if ($pagination->count() > 0) { |
| 296 | $pages = (int) $pagination->first()->text(); |
| 297 | } |
| 298 | |
| 299 | // Get Install links for both extensions |
| 300 | $extension_filter = function($crawler, $extension_name, &$install_link) |
| 301 | { |
| 302 | $extension_filter = $crawler->filter('tr')->reduce( |
| 303 | function ($node, $i) use ($extension_name) |
| 304 | { |
| 305 | return strpos($node->text(), $extension_name) !== false; |
| 306 | } |
| 307 | ); |
| 308 | |
| 309 | if ($extension_filter->count()) |
| 310 | { |
| 311 | $install_link = $extension_filter->selectLink($this->lang('INSTALL'))->link(); |
| 312 | } |
| 313 | }; |
| 314 | |
| 315 | for ($i = 0; $i < $pages; $i++) |
| 316 | { |
| 317 | if ($i != 0) |
| 318 | { |
| 319 | $this->mock_extensions_catalog_cache(); |
| 320 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&start=' . $i * 20 . '&mode=catalog&sid=' . $this->sid); |
| 321 | } |
| 322 | |
| 323 | $extension_filter($crawler, 'VigLink', $viglink_install_link); |
| 324 | } |
| 325 | |
| 326 | if (!isset($viglink_install_link)) |
| 327 | { |
| 328 | $this->fail('Failed acquiring install links for test extensions'); |
| 329 | } |
| 330 | |
| 331 | // Attempt to install phpbb/viglink extension |
| 332 | $crawler = self::$client->click($viglink_install_link); |
| 333 | $this->assertContainsLang('EXTENSIONS_INSTALLED', $crawler->filter('.successbox > p')->text()); |
| 334 | // Assert there's console log output |
| 335 | $this->assertStringContainsString('Locking phpbb/viglink', $crawler->filter('.console-output > pre')->text()); |
| 336 | |
| 337 | // Ensure installed extension appears in available extensions list |
| 338 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 339 | $this->assertStringContainsString('VigLink', $crawler->filter('strong[title="phpbb/viglink"]')->text()); |
| 340 | } |
| 341 | |
| 342 | public function test_extensions_catalog_updating_extension() |
| 343 | { |
| 344 | // Enable 'VigLink' extension installed earlier |
| 345 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 346 | $extension_enable_link = $crawler->filter('tr')->reduce( |
| 347 | function ($node, $i) |
| 348 | { |
| 349 | return (bool) (strpos($node->text(), 'VigLink') !== false); |
| 350 | } |
| 351 | )->selectLink($this->lang('EXTENSION_ENABLE'))->link(); |
| 352 | $crawler = self::$client->click($extension_enable_link); |
| 353 | $form = $crawler->selectButton($this->lang('EXTENSION_ENABLE'))->form(); |
| 354 | $crawler = self::submit($form); |
| 355 | $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text()); |
| 356 | |
| 357 | // Update 'VigLink' enabled extension |
| 358 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 359 | $viglink_update_link = $crawler->filter('tr')->reduce( |
| 360 | function ($node, $i) |
| 361 | { |
| 362 | return (bool) (strpos($node->text(), 'VigLink') !== false); |
| 363 | } |
| 364 | )->selectLink($this->lang('EXTENSION_UPDATE'))->link(); |
| 365 | $crawler = self::$client->click($viglink_update_link); |
| 366 | $this->assertContainsLang('EXTENSIONS_UPDATED', $crawler->filter('.successbox > p')->text()); |
| 367 | // Assert there's console log output |
| 368 | $this->assertStringContainsString('Updating packages', $crawler->filter('.console-output > pre')->text()); |
| 369 | |
| 370 | // Ensure installed extension still appears in available extensions list |
| 371 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 372 | $this->assertStringContainsString('VigLink', $crawler->filter('strong[title="phpbb/viglink"]')->text()); |
| 373 | } |
| 374 | |
| 375 | public function test_extensions_catalog_removing_extension() |
| 376 | { |
| 377 | $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 378 | |
| 379 | // Check if both enabled and disabled extensions have 'Remove' action available |
| 380 | $viglink_remove_link = $crawler->filter('tr')->reduce( |
| 381 | function ($node, $i) |
| 382 | { |
| 383 | return (bool) (strpos($node->text(), 'VigLink') !== false); |
| 384 | } |
| 385 | )->selectLink($this->lang('EXTENSION_REMOVE'))->link(); |
| 386 | |
| 387 | // Test extensions removal |
| 388 | // Remove 'VigLink' enabled extension |
| 389 | $crawler = self::$client->click($viglink_remove_link); |
| 390 | $this->assertContainsLang('EXTENSIONS_REMOVED', $crawler->filter('.successbox > p')->text()); |
| 391 | // Assert there's console log output |
| 392 | $this->assertStringContainsString('Removing phpbb/viglink', $crawler->filter('.console-output > pre')->text()); |
| 393 | |
| 394 | // Ensure removed extensions do not appear in available extensions list |
| 395 | self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); |
| 396 | $this->assertStringNotContainsString('VigLink', $this->get_content()); |
| 397 | } |
| 398 | } |