3415896930680533c3f105018fc8ab5b82084c21
[yaffs-website] / web / modules / contrib / metatag / metatag_views / tests / src / Functional / MetatagViewsBasicsTest.php
1 <?php
2
3 namespace Drupal\Tests\metatag_views\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\Tests\metatag\Functional\MetatagHelperTrait;
7
8 /**
9  * Confirm the defaults functionality works.
10  *
11  * @group panelizer
12  */
13 class MetatagViewsBasicsTest extends BrowserTestBase {
14
15   use MetatagHelperTrait;
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = [
21     // Modules for core functionality.
22     'block',
23     'field',
24     'field_ui',
25     'help',
26     'node',
27     'user',
28
29     // Views. Duh. Enable the Views UI so it can be fully tested.
30     'views',
31     'views_ui',
32
33     // Contrib dependencies.
34     'token',
35     'metatag',
36
37     // This module.
38     'metatag_views',
39   ];
40
41   /**
42    * {@inheritdoc}
43    */
44   protected function setUp() {
45     parent::setUp();
46
47     // Enable the Bartik theme and make it the default.
48     $theme = 'bartik';
49     \Drupal::service('theme_installer')->install([$theme]);
50     \Drupal::service('theme_handler')->setDefault($theme);
51
52     // Place the local actions block in the theme so that we can assert the
53     // presence of local actions and such.
54     $this->drupalPlaceBlock('local_actions_block', [
55       'region' => 'content',
56       'theme' => $theme,
57     ]);
58   }
59
60   /**
61    * Confirm the site isn't broken.
62    */
63   public function testSiteStillWorks() {
64     // Load the front page.
65     $this->drupalGet('<front>');
66     $this->assertResponse(200);
67
68     // With nothing else configured the front page just has a login form.
69     $this->assertText('Enter your Drupal username.');
70
71     // Log in as user 1.
72     $this->loginUser1();
73
74     // Load the main Views admin page.
75     $this->drupalGet('/admin/structure/views');
76     $this->assertResponse(200);
77
78     // Enable the Archive view. This should be the first such link while the
79     // gallery is the second.
80     $this->clickLink('Enable', 0);
81
82     // Confirm the archive page works.
83     $this->drupalGet('/archive');
84     $this->assertResponse(200);
85
86     // Confirm what the page title looks like by default.
87     $this->assertTitle('Monthly archive | Drupal');
88
89     // Load the Arcive view.
90     $this->drupalGet('/admin/structure/views/view/archive');
91     $this->assertResponse(200);
92
93     // Confirm that the Metatag options are present.
94     $this->assertText('Meta tags:');
95
96     // Confirm that the page is currently using defaults.
97     $this->assertText('Using defaults');
98
99     // Open the 'page' configuration.
100     $this->clickLink('Page');
101
102     // Confirm that no changes have been made yet.
103     $this->assertNoText('Overridden');
104
105     // Open the settings dialog.
106     $this->clickLink('Using defaults');
107
108     // Confirm the settings opened and it has some basic fields.
109     $this->assertText('Configure the meta tags below.');
110     $this->assertFieldByName('title');
111     $this->assertFieldByName('description');
112     $this->assertFieldByName('op');//, 'Apply');
113     $edit = [
114       'title' => 'Metatag title',
115       'description' => 'Metatag description.',
116     ];
117     $this->drupalPostForm(NULL, $edit, 'Apply');
118
119     // Confirm the Metatag settings are now overridden.
120     $this->assertText('Overridden');
121
122     // @todo Confirm there's now a "save" button.
123     // $this->assertFieldByName('op');//, 'Save');
124
125     // Save the changes.
126     $edit = [];
127     $this->drupalPostForm(NULL, $edit, 'Save');
128
129     // @todo Confirm the page saved.
130
131     // Load the archives page again.
132     $this->drupalGet('/archive');
133     $this->assertResponse(200);
134
135     // Confirm what the page title looks like now.
136     $this->assertTitle('Metatag title');
137   }
138
139 }