diff --git a/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php b/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php index 9e2e700..2801675 100644 --- a/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php +++ b/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\metatag_views\Functional; +use Drupal\user\Entity\User; use Drupal\Tests\BrowserTestBase; /** @@ -64,6 +65,89 @@ public function testSiteStillWorks() { // With nothing else configured the front page just has a login form. $this->assertText('Enter your Drupal username.'); + + // Log in as user 1. + $this->loginUser1(); + + // Load the main Views admin page. + $this->drupalGet('/admin/structure/views'); + $this->assertResponse(200); + + // Enable the Archive view. This should be the first such link while the + // gallery is the second. + $this->clickLink('Enable', 0); + + // Confirm the archive page works. + $this->drupalGet('/archive'); + $this->assertResponse(200); + + // Confirm what the page title looks like by default. + $this->assertTitle('Monthly archive | Drupal'); + + // Load the Arcive view. + $this->drupalGet('/admin/structure/views/view/archive'); + $this->assertResponse(200); + + // Confirm that the Metatag options are present. + $this->assertText('Meta tags:'); + + // Confirm that the page is currently using defaults. + $this->assertText('Using defaults'); + + // Open the 'page' configuration. + $this->clickLink('Page'); + + // Confirm that no changes have been made yet. + $this->assertNoText('Overridden'); + + // Open the settings dialog. + $this->clickLink('Using defaults'); + + // Confirm the settings opened and it has some basic fields. + $this->assertText('Configure the meta tags below.'); + $this->assertFieldByName('title'); + $this->assertFieldByName('description'); + $this->assertFieldByName('op');//, 'Apply'); + $edit = [ + 'title' => 'Metatag title', + 'description' => 'Metatag description.', + ]; + $this->drupalPostForm(NULL, $edit, 'Apply'); + + // Confirm the Metatag settings are now overridden. + $this->assertText('Overridden'); + + // @todo Confirm there's now a "save" button. + // $this->assertFieldByName('op');//, 'Save'); + + // Save the changes. + $edit = []; + $this->drupalPostForm(NULL, $edit, 'Save'); + + // @todo Confirm the page saved. + + // Load the archives page again. + $this->drupalGet('/archive'); + $this->assertResponse(200); + + // Confirm what the page title looks like now. + $this->assertNoTitle('Monthly archive | Drupal'); + $this->assertTitle('Metatag title | Drupal'); + } + + /** + * Log in as user 1. + */ + protected function loginUser1() { + // Log in as user 1. + /* @var \Drupal\user\Entity\User $account */ + $account = User::load(1); + $password = 'foo'; + $account->setPassword($password)->save(); + // Support old and new tests. + $account->passRaw = $password; + $account->pass_raw = $password; + $this->drupalLogin($account); } }