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