You are here

public function FrontPageTest::testFrontPageTitle in Page Manager 8

Tests the front page title.

File

src/Tests/FrontPageTest.php, line 29

Class

FrontPageTest
Tests a page manager page as front page.

Namespace

Drupal\page_manager\Tests

Code

public function testFrontPageTitle() {

  // Use a block page for frontpage.
  $page = Page::create([
    'label' => 'My frontpage',
    'id' => 'myfront',
    'path' => '/myfront',
  ]);
  $page
    ->save();

  /** @var \Drupal\page_manager\PageVariantInterface $page_variant */
  $page_variant = PageVariant::create([
    'variant' => 'block_display',
    'id' => 'block_page',
    'label' => 'Block page',
    'page' => 'myfront',
  ]);
  $page_variant
    ->save();
  $this
    ->config('system.site')
    ->set('page.front', '/myfront')
    ->save();
  $block = Block::create([
    'id' => $this
      ->randomMachineName(),
    'plugin' => 'system_powered_by_block',
  ]);
  $block
    ->save();
  $page_variant
    ->getVariantPlugin()
    ->setConfiguration([
    'page_title' => '',
    'blocks' => [
      $block
        ->uuid() => [
        'region' => 'top',
        'weight' => 0,
        'id' => $block
          ->id(),
        'uuid' => $block
          ->uuid(),
        'context_mapping' => [],
      ],
    ],
  ]);
  $this
    ->verbose(var_export($page_variant
    ->toArray(), TRUE));
  $this
    ->triggerRouterRebuild();

  // The title should default to "Home" on the front page.
  // @todo This gives 404 :(
  $this
    ->drupalGet('');
  $this
    ->assertTitle('Home | Drupal');
}