You are here

protected function DevelControllerTest::setUp in Devel 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelControllerTest.php \Drupal\Tests\devel\Functional\DevelControllerTest::setUp()
  2. 8.2 tests/src/Functional/DevelControllerTest.php \Drupal\Tests\devel\Functional\DevelControllerTest::setUp()
  3. 4.x tests/src/Functional/DevelControllerTest.php \Drupal\Tests\devel\Functional\DevelControllerTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/DevelControllerTest.php, line 24

Class

DevelControllerTest
Tests Devel controller.

Namespace

Drupal\Tests\devel\Functional

Code

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

  // Create a test entity.
  $random_label = $this
    ->randomMachineName();
  $data = [
    'type' => 'entity_test',
    'name' => $random_label,
  ];
  $this->entity = entity_create('entity_test', $data);
  $this->entity
    ->save();

  // Create a test entity with only canonical route.
  $random_label = $this
    ->randomMachineName();
  $data = [
    'type' => 'devel_entity_test_canonical',
    'name' => $random_label,
  ];
  $this->entity_canonical = entity_create('devel_entity_test_canonical', $data);
  $this->entity_canonical
    ->save();

  // Create a test entity with only edit route.
  $random_label = $this
    ->randomMachineName();
  $data = [
    'type' => 'devel_entity_test_edit',
    'name' => $random_label,
  ];
  $this->entity_edit = entity_create('devel_entity_test_edit', $data);
  $this->entity_edit
    ->save();

  // Create a test entity with no routes.
  $random_label = $this
    ->randomMachineName();
  $data = [
    'type' => 'devel_entity_test_no_links',
    'name' => $random_label,
  ];
  $this->entity_no_links = entity_create('devel_entity_test_no_links', $data);
  $this->entity_no_links
    ->save();
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $web_user = $this
    ->drupalCreateUser([
    'view test entity',
    'administer entity_test content',
    'access devel information',
  ]);
  $this
    ->drupalLogin($web_user);
}