function DevelControllerTest::setUp

Same name in other branches
  1. 8.x-1.x tests/src/Functional/DevelControllerTest.php \Drupal\Tests\devel\Functional\DevelControllerTest::setUp()
  2. 4.x tests/src/Functional/DevelControllerTest.php \Drupal\Tests\devel\Functional\DevelControllerTest::setUp()

Overrides DevelBrowserTestBase::setUp

File

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

Class

DevelControllerTest
Tests Devel controller.

Namespace

Drupal\Tests\devel\Functional

Code

protected function setUp() : void {
    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->entityCanonical = $entity_type_manager->getStorage('devel_entity_test_canonical')
        ->create($data);
    $this->entityCanonical
        ->save();
    // Create a test entity with only edit route.
    $random_label = $this->randomMachineName();
    $data = [
        'type' => 'devel_entity_test_edit',
        'name' => $random_label,
    ];
    $this->entityEdit = $entity_type_manager->getStorage('devel_entity_test_edit')
        ->create($data);
    $this->entityEdit
        ->save();
    // Create a test entity with no routes.
    $random_label = $this->randomMachineName();
    $data = [
        'type' => 'devel_entity_test_no_links',
        'name' => $random_label,
    ];
    $this->entityNoLinks = $entity_type_manager->getStorage('devel_entity_test_no_links')
        ->create($data);
    $this->entityNoLinks
        ->save();
    $this->drupalPlaceBlock('local_tasks_block');
    $web_user = $this->drupalCreateUser([
        'view test entity',
        'administer entity_test content',
        'access devel information',
    ]);
    $this->drupalLogin($web_user);
}