3 namespace Drupal\Tests\metatag_views\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Confirm the defaults functionality works.
12 class MetatagViewsBasicsTest extends BrowserTestBase {
14 // Contains helper methods.
15 use \Drupal\Tests\metatag\Functional\MetatagHelperTrait;
20 public static $modules = [
21 // Modules for core functionality.
29 // Views. Duh. Enable the Views UI so it can be fully tested.
33 // Contrib dependencies.
44 protected function setUp() {
47 // Enable the Bartik theme and make it the default.
49 \Drupal::service('theme_installer')->install([$theme]);
50 \Drupal::service('theme_handler')->setDefault($theme);
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',
61 * Confirm the site isn't broken.
63 public function testSiteStillWorks() {
64 // Load the front page.
65 $this->drupalGet('<front>');
66 $this->assertResponse(200);
68 // With nothing else configured the front page just has a login form.
69 $this->assertText('Enter your Drupal username.');
74 // Load the main Views admin page.
75 $this->drupalGet('/admin/structure/views');
76 $this->assertResponse(200);
78 // Enable the Archive view. This should be the first such link while the
79 // gallery is the second.
80 $this->clickLink('Enable', 0);
82 // Confirm the archive page works.
83 $this->drupalGet('/archive');
84 $this->assertResponse(200);
86 // Confirm what the page title looks like by default.
87 $this->assertTitle('Monthly archive | Drupal');
89 // Load the Arcive view.
90 $this->drupalGet('/admin/structure/views/view/archive');
91 $this->assertResponse(200);
93 // Confirm that the Metatag options are present.
94 $this->assertText('Meta tags:');
96 // Confirm that the page is currently using defaults.
97 $this->assertText('Using defaults');
99 // Open the 'page' configuration.
100 $this->clickLink('Page');
102 // Confirm that no changes have been made yet.
103 $this->assertNoText('Overridden');
105 // Open the settings dialog.
106 $this->clickLink('Using defaults');
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');
114 'title' => 'Metatag title',
115 'description' => 'Metatag description.',
117 $this->drupalPostForm(NULL, $edit, 'Apply');
119 // Confirm the Metatag settings are now overridden.
120 $this->assertText('Overridden');
122 // @todo Confirm there's now a "save" button.
125 $this->drupalPostForm(NULL, $edit, 'Save');
127 // @todo Confirm the page saved.
128 // Load the archives page again.
129 $this->drupalGet('/archive');
130 $this->assertResponse(200);
132 // Confirm what the page title looks like now.
133 $this->assertTitle('Metatag title');
135 // Load the Metatag admin page to confirm it still works.
136 $this->drupalGet('admin/config/search/metatag');
137 $this->assertResponse(200);
138 $this->assertText('Add default meta tags');