You are here

public function EntityLegacyTest::testEntityDeleteMultiple in Drupal 8

Tests that entity_delete_multiple triggers an error.

@expectedDeprecation entity_delete_multiple is deprecated in drupal:8.0.0 and will be removed in drupal:9.0.0. Use the entity storage's delete() method to delete multiple entities.

Throws

\Drupal\Core\Entity\EntityStorageException

See also

https://www.drupal.org/node/3051072

File

core/tests/Drupal/KernelTests/Core/Entity/EntityLegacyTest.php, line 44

Class

EntityLegacyTest
Tests legacy entity functions.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testEntityDeleteMultiple() {
  EntityTest::create([
    'name' => 'published entity',
  ])
    ->save();
  EntityTest::create([
    'name' => 'published entity',
  ])
    ->save();
  $this
    ->assertCount(2, \Drupal::entityTypeManager()
    ->getStorage('entity_test')
    ->loadMultiple());
  entity_delete_multiple('entity_test', [
    1,
    2,
  ]);
  $this
    ->assertCount(0, \Drupal::entityTypeManager()
    ->getStorage('entity_test')
    ->loadMultiple());
}