You are here

protected function MetatagViewsTokenTest::updateView in Metatag 8

Update the view.

Parameters

bool $assert_ui: Also assert the Views UI behaves correctly.

Return value

string

1 call to MetatagViewsTokenTest::updateView()
MetatagViewsTokenTest::testTokenization in metatag_views/tests/src/Functional/MetatagViewsTokenTest.php
Confirm the Views tokenization functionality works, including UI.

File

metatag_views/tests/src/Functional/MetatagViewsTokenTest.php, line 82

Class

MetatagViewsTokenTest
Confirm the tokenization functionality works.

Namespace

Drupal\Tests\metatag_views\Functional

Code

protected function updateView(bool $assert_ui = FALSE) : string {
  $title_prefix = $this
    ->randomMachineName();
  $edit = [
    'title' => $title_prefix . ' {{ title }}',
    'tokenize' => 1,
  ];
  $metatag_settings_path = '/admin/structure/views/nojs/display/test/page_1/metatags';
  $this
    ->drupalGet($metatag_settings_path);
  $this
    ->submitForm($edit, 'Apply');

  // Make sure the UI does not tokenize away {{ title }}.
  if ($assert_ui) {

    // Reload the form
    $this
      ->drupalGet($metatag_settings_path);
    $actual = $this
      ->getSession()
      ->getPage()
      ->find('css', '#edit-title')
      ->getAttribute('value');
    $this
      ->assertSame($edit['title'], $actual);
  }
  $this
    ->drupalGet('/admin/structure/views/view/test');
  $this
    ->submitForm([], 'Save');
  return $title_prefix;
}