ModulesWeightAdminSettingsTest.php in Modules weight 8.2
File
tests/src/Functional/ModulesWeightAdminSettingsTest.php
View source
<?php
namespace Drupal\Tests\modules_weight\Functional;
use Drupal\Tests\BrowserTestBase;
class ModulesWeightAdminSettingsTest extends BrowserTestBase {
protected static $modules = [
'modules_weight',
];
public function testConfigurationForm() {
$this
->drupalGet('/admin/config/system/modules-weight/configuration');
$this
->assertSession()
->statusCodeEquals(403);
$account = $this
->drupalCreateUser([
'administer modules weight',
'access administration pages',
]);
$this
->drupalLogin($account);
$this
->drupalGet('/admin/config/system');
$this
->assertSession()
->linkByHrefExists('/admin/config/system/modules-weight');
$this
->drupalGet('/admin/config/system/modules-weight/configuration');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'h1', 'Modules Weight Settings');
$this
->assertSession()
->checkboxNotChecked('show_system_modules');
$edit = [
'show_system_modules' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'op');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$config_factory = $this->container
->get('config.factory');
$show_system_modules = $config_factory
->get('modules_weight.settings')
->get('show_system_modules');
$this
->assertTrue($show_system_modules, 'The configuration value for show_system_modules should be TRUE.');
$edit = [
'show_system_modules' => 0,
];
$this
->drupalPostForm(NULL, $edit, 'op');
$show_system_modules = $config_factory
->get('modules_weight.settings')
->get('show_system_modules');
$this
->assertFalse($show_system_modules, 'The configuration value for show_system_modules should be FALSE.');
}
}