You are here

protected function PageManagerRoutingTest::setUp in Page Manager 8.4

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

Overrides EntityKernelTestBase::setUp

File

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

Class

PageManagerRoutingTest
Integration test for Page Manager routing.

Namespace

Drupal\Tests\page_manager\Kernel

Code

protected function setUp() {
  parent::setUp();

  // If we are on Drupal 8.8 or later, we need to install the path_alias
  // module in order to properly resolve the routes.
  if (version_compare(\Drupal::VERSION, '8.8.0', '>=')) {
    $this
      ->installEntitySchema('path_alias');
  }
  $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();
}