You are here

public function NavigationalStructureTest::entityDelete in Entity Construction Kit (ECK) 8

Tests entity deletion.

@test

Throws

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Functional/NavigationalStructureTest.php, line 555

Class

NavigationalStructureTest
Test Entity Construction Kit's navigational structure.

Namespace

Drupal\Tests\eck\Functional

Code

public function entityDelete() {
  $entityTitle = $this
    ->randomString();
  $entity_type_label = strtolower($this->entityTypeLabel);
  $entity = $this
    ->getEntityStorageHandler()
    ->create([
    'type' => $this->entityBundleMachineName,
    'title' => $entityTitle,
  ]);
  $entity
    ->save();
  $route = "entity.{$this->entityTypeMachineName}.delete_form";
  $routeArguments = [
    $this->entityTypeMachineName => $entity
      ->id(),
  ];
  $expectedUrl = "{$this->entityTypeMachineName}/{$entity->id()}/delete";
  $expectedTitle = "Are you sure you want to delete the {$entity_type_label} {$entityTitle}?";
  $this->baseCrumbs = [
    'Home',
  ];
  $crumbs = [
    $entityTitle,
  ];
  $this
    ->assertCorrectPageOnRoute($route, $routeArguments, $expectedUrl, $expectedTitle, $crumbs);
}