You are here

public function ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile()
  2. 9 core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormWithInvalidInfoFile()

Tests the module form with a module with an invalid info.yml file.

File

core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php, line 94

Class

ModulesListFormWebTest
Tests \Drupal\system\Form\ModulesListForm.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testModulesListFormWithInvalidInfoFile() {
  $path = \Drupal::getContainer()
    ->getParameter('site.path') . "/modules/broken";
  mkdir($path, 0777, TRUE);
  $file_path = "{$path}/broken.info.yml";
  $yml = <<<BROKEN
name: Module with no core_version_requirement
type: module
BROKEN;
  file_put_contents($file_path, $yml);
  $this
    ->drupalGet('admin/modules');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains("Modules could not be listed due to an error: The 'core_version_requirement' key must be present in {$file_path}");

  // 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');
}