You are here

protected function DevelControllerTest::setUp in Devel 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelControllerTest.php \Drupal\Tests\devel\Functional\DevelControllerTest::setUp()
  2. 8 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 30

Class

DevelControllerTest
Tests Devel controller.

Namespace

Drupal\Tests\devel\Functional

Code

protected function setUp() {
  parent::setUp();
  $entity_type_manager = $this->container
    ->get('entity_type.manager');

  // Create a test entity.
  $random_label = $this
    ->randomMachineName();
  $data = [
    'type' => 'entity_test',
    'name' => $random_label,
  ];
  $this->entity = $entity_type_manager
    ->getStorage('entity_test')
    ->create($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_type_manager
    ->getStorage('devel_entity_test_canonical')
    ->create($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_type_manager
    ->getStorage('devel_entity_test_edit')
    ->create($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_type_manager
    ->getStorage('devel_entity_test_no_links')
    ->create($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);
}