PathologicUITest.php in Pathologic 8
File
tests/src/Functional/PathologicUITest.php
View source
<?php
namespace Drupal\Tests\pathologic\Functional;
use Drupal\Tests\BrowserTestBase;
class PathologicUITest extends BrowserTestBase {
protected static $modules = [
'pathologic',
'node',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
$this
->drupalLogin($this
->drupalCreateUser([
'administer filters',
'create page content',
]));
}
public function testPathologicUi() {
$this
->doTestSettingsForm();
$this
->doTestFormatsOptions();
$this
->doTestFixUrl();
}
public function doTestSettingsForm() {
$this
->drupalGet('admin/config/content/pathologic');
$this
->assertText('Pathologic configuration');
$this
->assertNoFieldChecked('edit-protocol-style-proto-rel');
$edit = [
'protocol_style' => 'proto-rel',
'local_paths' => 'http://example.com/',
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
$this
->assertText('The configuration options have been saved.');
$this
->assertFieldChecked('edit-protocol-style-proto-rel');
$this
->assertText('http://example.com/');
$this
->clickLink('Pathologic’s documentation');
$this
->assertResponse(200);
}
public function doTestFormatsOptions() {
$this
->drupalGet('/admin/config/content/formats/manage/plain_text');
$this
->assertText('Correct URLs with Pathologic');
$this
->assertNoFieldChecked('edit-filters-filter-pathologic-status');
$this
->drupalPostForm(NULL, [
'filters[filter_html_escape][status]' => FALSE,
'filters[filter_pathologic][status]' => '1',
], t('Save configuration'));
$this
->drupalGet('/admin/config/content/formats/manage/plain_text');
$this
->assertRaw('In most cases, Pathologic should be the <em>last</em> filter in the “Filter processing order” list.');
$this
->assertText('Select whether Pathologic should use the global Pathologic settings');
$this
->assertFieldChecked('edit-filters-filter-pathologic-status');
$this
->drupalPostForm(NULL, [
'filters[filter_pathologic][settings][settings_source]' => 'local',
'filters[filter_pathologic][settings][local_settings][protocol_style]' => 'full',
], t('Save configuration'));
$this
->drupalGet('/admin/config/content/formats/manage/plain_text');
$this
->assertFieldChecked('edit-filters-filter-pathologic-settings-settings-source-local');
$this
->assertFieldChecked('edit-filters-filter-pathologic-settings-local-settings-protocol-style-full');
$this
->assertText('Custom settings for this text format');
}
public function doTestFixUrl() {
$this
->drupalGet('node/add/page');
$edit = [
'title[0][value]' => 'Test pathologic',
'body[0][value]' => '<a href="node/1">Test link</a>',
];
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
$this
->clickLink('Test link');
$this
->assertTitle('Test pathologic | Drupal');
}
}