Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / pathologic / src / Tests / PathologicUITest.php
1 <?php
2
3 namespace Drupal\pathologic\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Tests for the Pathologic UI.
9  *
10  * @group pathologic
11  */
12 class PathologicUITest extends WebTestBase {
13
14   public static $modules = ['pathologic', 'node'];
15
16   /**
17    * {@inheritdoc}
18    */
19   protected function setUp() {
20     parent::setUp();
21
22     $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
23     $this->drupalLogin($this->drupalCreateUser(['administer filters', 'create page content']));
24   }
25
26   /**
27    * Tests for the Pathologic UI.
28    */
29   public function testPathologicUi() {
30     $this->doTestSettingsForm();
31     $this->doTestFormatsOptions();
32     $this->doTestFixUrl();
33   }
34
35   /**
36    * Test settings form.
37    */
38   public function doTestSettingsForm() {
39     $this->drupalGet('admin/config/content/pathologic');
40     $this->assertText('Pathologic configuration');
41
42     // Test submit form.
43     $this->assertNoFieldChecked('edit-protocol-style-proto-rel');
44     $edit = [
45       'protocol_style' => 'proto-rel',
46       'local_paths' => 'http://example.com/',
47     ];
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);
54   }
55
56   /**
57    * Test text formats and editors options with pathologic.
58    */
59   public function doTestFormatsOptions() {
60
61     // Test plain text with pathologic configuration.
62     $this->drupalGet('/admin/config/content/formats/manage/plain_text');
63
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'));
71
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 &ldquo;Filter processing order&rdquo; 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'));
80
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');
85   }
86
87   /**
88    * Test that a url is fixed with pathologic.
89    */
90   public function doTestFixUrl() {
91     $this->drupalGet('node/add/page');
92     $edit = [
93       'title[0][value]' => 'Test pathologic',
94       'body[0][value]' => '<a href="node/1">Test link</a>',
95     ];
96     $this->drupalPostForm('node/add/page', $edit, t('Save'));
97
98     // Assert that the link is processed with Pathologic.
99     $this->clickLink('Test link');
100     $this->assertTitle('Test pathologic | Drupal');
101   }
102
103 }