ModulesListFormWebTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Form;
use Drupal\Tests\BrowserTestBase;
class ModulesListFormWebTest extends BrowserTestBase {
public static $modules = [
'system_test',
'help',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
\Drupal::state()
->set('system_test.module_hidden', FALSE);
$this
->drupalLogin($this
->drupalCreateUser([
'administer modules',
'administer permissions',
]));
}
public function testModuleListForm() {
$this
->drupalGet('admin/modules');
$this
->assertFieldByXPath("//a[contains(@href, '/system-test/configure/bar') and text()='Configure ']/span[contains(@class, 'visually-hidden') and text()='the System test module']");
$this
->assertFieldByXPath("//a[contains(@href, '/admin/people/permissions#module-system_test') and @title='Configure permissions']");
$this
->assertFieldByXPath("//a[contains(@href, '/admin/help/system_test') and @title='Help']");
$this
->assertText('simpletest');
}
public function testModulesListFormWithInvalidInfoFile() {
$broken_info_yml = <<<BROKEN
name: Module With Broken Info file
type: module
BROKEN;
$path = \Drupal::service('site.path') . "/modules/broken";
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/broken.info.yml", $broken_info_yml);
$this
->drupalGet('admin/modules');
$this
->assertSession()
->pageTextContains("The 'core' or the 'core_version_requirement' key must be present in " . $path . '/broken.info.yml');
$this
->assertSession()
->elementExists('xpath', '//input[@name="text"]');
}
public function testRequiredByThemeMessage() {
$this
->drupalGet('admin/modules');
$module_theme_depends_on_description = $this
->getSession()
->getPage()
->findAll('css', '#edit-modules-test-module-required-by-theme-enable-description .admin-requirements li:contains("Test Theme Depending on Modules (theme) (disabled)")');
$this
->assertCount(1, $module_theme_depends_on_description);
$this
->assertSession()
->pageTextContains('Test Theme Depending on Modules (Theme) (Disabled)');
}
}