ConfigFormTest.php in HTML Title 8
File
tests/src/Functional/ConfigFormTest.php
View source
<?php
namespace Drupal\Tests\html_title\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class ConfigFormTest extends BrowserTestBase {
protected static $modules = [
'html_title',
];
protected $defaultTheme = 'stark';
protected $adminUser;
protected $webUser;
protected function setUp() : void {
parent::setUp();
$this->webUser = $this
->createUser();
$this->adminUser = $this
->createUser([
'administer html title settings',
]);
}
public function testHtmlTitleConfigForm() {
$config = $this
->config('html_title.settings');
$this
->assertEquals('<br> <sub> <sup>', $config
->get('allow_html_tags'));
$this
->drupalGet(Url::fromRoute('html_title.settings'));
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalLogin($this->webUser);
$this
->drupalGet(Url::fromRoute('html_title.settings'));
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet(Url::fromRoute('html_title.settings'));
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([
'allow_html_tags' => '<br>',
], 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$config = $this
->config('html_title.settings');
$this
->assertEquals('<br>', $config
->get('allow_html_tags'));
}
}