You are here

protected function PageManagerRoutingTest::setUp in Page Manager 8

Same name and namespace in other branches
  1. 8.4 tests/src/Kernel/PageManagerRoutingTest.php \Drupal\Tests\page_manager\Kernel\PageManagerRoutingTest::setUp()

Overrides EntityKernelTestBase::setUp

File

tests/src/Kernel/PageManagerRoutingTest.php, line 27

Class

PageManagerRoutingTest
Integration test for Page Manager routing.

Namespace

Drupal\Tests\page_manager\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this->container
    ->get('current_user')
    ->setAccount($this
    ->createUser([], [
    'view test entity',
  ]));
  EntityTest::create()
    ->save();
  Page::create([
    'id' => 'entity_test_view',
    'path' => '/entity_test/{entity_test}',
  ])
    ->save();
  PageVariant::create([
    'id' => 'entity_test_view_variant',
    'variant' => 'simple_page',
    'page' => 'entity_test_view',
  ])
    ->save();
  Page::create([
    'id' => 'custom_entity_test_view',
    'path' => '/custom/entity_test/{entity_test}',
    'parameters' => [
      'entity_test' => [
        'type' => 'entity:entity_test',
      ],
    ],
  ])
    ->save();
  $variant = PageVariant::create([
    'id' => 'custom_entity_test_view_variant',
    'variant' => 'simple_page',
    'page' => 'custom_entity_test_view',
  ]);
  $variant
    ->addSelectionCondition([
    'id' => 'page_manager_routing_test__entity_test',
  ]);
  $variant
    ->getPluginCollections();
  $variant
    ->save();
  Page::create([
    'id' => 'entity_test_edit',
    'path' => '/entity_test/manage/{entity_test}/edit',
  ])
    ->save();
  PageVariant::create([
    'id' => 'entity_test_edit_variant',
    'variant' => 'simple_page',
    'page' => 'entity_test_edit',
    // Add a selection condition that will never pass.
    'selection_criteria' => [
      'request_path' => [
        'id' => 'request_path',
        'pages' => 'invalid',
      ],
    ],
  ])
    ->save();
  Page::create([
    'id' => 'entity_test_delete',
    'path' => '/entity_test/delete/entity_test/{entity_test}',
    // Add an access condition that will never pass.
    'access_conditions' => [
      'request_path' => [
        'id' => 'request_path',
        'pages' => 'invalid',
      ],
    ],
  ])
    ->save();
  PageVariant::create([
    'id' => 'entity_test_delete_variant',
    'variant' => 'simple_page',
    'page' => 'entity_test_delete',
  ])
    ->save();
}