3 namespace Drupal\pathologic\Tests;
5 use Drupal\simpletest\WebTestBase;
8 * Tests for the Pathologic UI.
12 class PathologicUITest extends WebTestBase {
14 public static $modules = ['pathologic', 'node'];
19 protected function setUp() {
22 $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
23 $this->drupalLogin($this->drupalCreateUser(['administer filters', 'create page content']));
27 * Tests for the Pathologic UI.
29 public function testPathologicUi() {
30 $this->doTestSettingsForm();
31 $this->doTestFormatsOptions();
32 $this->doTestFixUrl();
38 public function doTestSettingsForm() {
39 $this->drupalGet('admin/config/content/pathologic');
40 $this->assertText('Pathologic configuration');
43 $this->assertNoFieldChecked('edit-protocol-style-proto-rel');
45 'protocol_style' => 'proto-rel',
46 'local_paths' => 'http://example.com/',
48 $this->drupalPostForm(NULL, $edit, t('Save configuration'));
49 $this->assertText('The configuration options have been saved.');
50 $this->assertFieldChecked('edit-protocol-style-proto-rel');
51 $this->assertText('http://example.com/');
52 $this->clickLink('Pathologic’s documentation');
53 $this->assertResponse(200);
57 * Test text formats and editors options with pathologic.
59 public function doTestFormatsOptions() {
61 // Test plain text with pathologic configuration.
62 $this->drupalGet('/admin/config/content/formats/manage/plain_text');
64 // Select pathologic option.
65 $this->assertText('Correct URLs with Pathologic');
66 $this->assertNoFieldChecked('edit-filters-filter-pathologic-status');
67 $this->drupalPostForm(NULL, [
68 'filters[filter_html_escape][status]' => FALSE,
69 'filters[filter_pathologic][status]' => '1',
70 ], t('Save configuration'));
72 $this->drupalGet('/admin/config/content/formats/manage/plain_text');
73 $this->assertRaw('In most cases, Pathologic should be the <em>last</em> filter in the “Filter processing order” list.');
74 $this->assertText('Select whether Pathologic should use the global Pathologic settings');
75 $this->assertFieldChecked('edit-filters-filter-pathologic-status');
76 $this->drupalPostForm(NULL, [
77 'filters[filter_pathologic][settings][settings_source]' => 'local',
78 'filters[filter_pathologic][settings][local_settings][protocol_style]' => 'full',
79 ], t('Save configuration'));
81 $this->drupalGet('/admin/config/content/formats/manage/plain_text');
82 $this->assertFieldChecked('edit-filters-filter-pathologic-settings-settings-source-local');
83 $this->assertFieldChecked('edit-filters-filter-pathologic-settings-local-settings-protocol-style-full');
84 $this->assertText('Custom settings for this text format');
88 * Test that a url is fixed with pathologic.
90 public function doTestFixUrl() {
91 $this->drupalGet('node/add/page');
93 'title[0][value]' => 'Test pathologic',
94 'body[0][value]' => '<a href="node/1">Test link</a>',
96 $this->drupalPostForm('node/add/page', $edit, t('Save'));
98 // Assert that the link is processed with Pathologic.
99 $this->clickLink('Test link');
100 $this->assertTitle('Test pathologic | Drupal');