MetatagViewsBasicsTest.php in Metatag 8
File
metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php
View source
<?php
namespace Drupal\Tests\metatag_views\Functional;
use Drupal\Tests\BrowserTestBase;
class MetatagViewsBasicsTest extends BrowserTestBase {
use \Drupal\Tests\metatag\Functional\MetatagHelperTrait;
protected static $modules = [
'block',
'field',
'field_ui',
'help',
'node',
'user',
'views',
'views_ui',
'token',
'metatag',
'metatag_views',
];
protected $defaultTheme = 'bartik';
protected function setUp() {
parent::setUp();
$theme = 'bartik';
\Drupal::service('theme_installer')
->install([
$theme,
]);
$this
->config('system.theme')
->set('default', $theme);
$this
->drupalPlaceBlock('local_actions_block', [
'region' => 'content',
'theme' => $theme,
]);
}
public function testViewsUi() {
$this
->drupalGet('<front>');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Enter your Drupal username.');
$this
->loginUser1();
$this
->drupalGet('/admin/structure/views');
$this
->assertSession()
->statusCodeEquals(200);
$this
->clickLink('Enable', 0);
$this
->drupalGet('/archive');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->titleEquals('Monthly archive | Drupal');
$this
->drupalGet('/admin/structure/views/view/archive');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Meta tags:');
$this
->assertSession()
->pageTextContains('Using defaults');
$this
->clickLink('Page');
$this
->assertNoText('Overridden');
$this
->clickLink('Using defaults');
$this
->assertSession()
->pageTextContains('Configure the meta tags below.');
$this
->assertFieldByName('title');
$this
->assertFieldByName('description');
$this
->assertFieldByName('op');
$edit = [
'title' => 'Metatag title',
'description' => 'Metatag description.',
];
$this
->drupalPostForm(NULL, $edit, 'Apply');
$this
->assertSession()
->pageTextContains('Overridden');
$edit = [];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->drupalGet('/archive');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->titleEquals('Metatag title');
$this
->drupalGet('admin/config/search/metatag');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertLinkByHref('/admin/config/search/metatag/global');
$this
->assertLinkByHref('/admin/config/search/metatag/front');
$this
->assertLinkByHref('/admin/config/search/metatag/403');
$this
->assertLinkByHref('/admin/config/search/metatag/404');
$this
->assertLinkByHref('/admin/config/search/metatag/node');
$this
->assertLinkByHref('/admin/config/search/metatag/taxonomy_term');
$this
->assertLinkByHref('/admin/config/search/metatag/user');
}
}