function ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile
Same name in other branches
- 8.9.x core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile()
- 10 core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile()
- 11.x core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile()
Tests the module form with modules with invalid info.yml files.
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ ModulesListFormWebTest.php, line 94
Class
Namespace
Drupal\Tests\system\Functional\FormCode
public function testModulesListFormWithInvalidInfoFile() {
$path = \Drupal::getContainer()->getParameter('site.path') . "/modules/broken";
mkdir($path, 0777, TRUE);
$file_path = "{$path}/broken.info.yml";
$broken_infos = [
[
'yml' => <<<BROKEN
name: Module with no core_version_requirement or core
type: module
BROKEN
,
'expected_error' => "The 'core_version_requirement' key must be present in {$file_path}",
],
[
'yml' => <<<BROKEN
name: Module no core_version_requirement and invalid core
type: module
core: 9.x
BROKEN
,
'expected_error' => "'core: 9.x' is not supported. Use 'core_version_requirement' to specify core compatibility. Only 'core: 8.x' is supported to provide backwards compatibility for Drupal 8 when needed in {$file_path}",
],
[
'yml' => <<<BROKEN
name: Module with core_version_requirement and invalid core
type: module
core: 9.x
core_version_requirement: ^8 || ^9
BROKEN
,
'expected_error' => "'core: 9.x' is not supported. Use 'core_version_requirement' to specify core compatibility. Only 'core: 8.x' is supported to provide backwards compatibility for Drupal 8 when needed in {$file_path}",
],
];
foreach ($broken_infos as $broken_info) {
file_put_contents($file_path, $broken_info['yml']);
$this->drupalGet('admin/modules');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('Modules could not be listed due to an error: ' . $broken_info['expected_error']);
// Check that the module filter text box is available.
$this->assertSession()
->elementExists('xpath', '//input[@name="text"]');
unlink($file_path);
$this->drupalGet('admin/modules');
$this->assertSession()
->statusCodeEquals(200);
// Check that the module filter text box is available.
$this->assertSession()
->elementExists('xpath', '//input[@name="text"]');
$this->assertSession()
->pageTextNotContains('Modules could not be listed due to an error');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.