You are here

public function ConfigEntityStorageTest::testDelete in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testDelete()

@covers ::delete @covers ::doDelete

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 856
Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest.

Class

ConfigEntityStorageTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testDelete() {

  // Dependencies are tested in \Drupal\config\Tests\ConfigDependencyTest.
  $this->configManager
    ->expects($this
    ->any())
    ->method('getConfigEntitiesToChangeOnDependencyRemoval')
    ->willReturn([
    'update' => [],
    'delete' => [],
    'unchanged' => [],
  ]);
  $entities = array();
  $configs = array();
  $config_map = array();
  foreach (array(
    'foo',
    'bar',
  ) as $id) {
    $entity = $this
      ->getMockEntity(array(
      'id' => $id,
    ));
    $entities[] = $entity;
    $config_object = $this
      ->getMockBuilder('Drupal\\Core\\Config\\Config')
      ->disableOriginalConstructor()
      ->getMock();
    $config_object
      ->expects($this
      ->once())
      ->method('delete');
    $configs[] = $config_object;
    $config_map[] = array(
      "the_config_prefix.{$id}",
      $config_object,
    );
  }
  $this->cacheTagsInvalidator
    ->expects($this
    ->once())
    ->method('invalidateTags')
    ->with(array(
    // List cache tag only; the own cache tag is invalidated by the config
    // system.
    $this->entityTypeId . '_list',
  ));
  $this->configFactory
    ->expects($this
    ->exactly(2))
    ->method('getEditable')
    ->will($this
    ->returnValueMap($config_map));
  $this->moduleHandler
    ->expects($this
    ->at(0))
    ->method('invokeAll')
    ->with('test_entity_type_predelete');
  $this->moduleHandler
    ->expects($this
    ->at(1))
    ->method('invokeAll')
    ->with('entity_predelete');
  $this->moduleHandler
    ->expects($this
    ->at(2))
    ->method('invokeAll')
    ->with('test_entity_type_predelete');
  $this->moduleHandler
    ->expects($this
    ->at(3))
    ->method('invokeAll')
    ->with('entity_predelete');
  $this->moduleHandler
    ->expects($this
    ->at(4))
    ->method('invokeAll')
    ->with('test_entity_type_delete');
  $this->moduleHandler
    ->expects($this
    ->at(5))
    ->method('invokeAll')
    ->with('entity_delete');
  $this->moduleHandler
    ->expects($this
    ->at(6))
    ->method('invokeAll')
    ->with('test_entity_type_delete');
  $this->moduleHandler
    ->expects($this
    ->at(7))
    ->method('invokeAll')
    ->with('entity_delete');
  $this->entityStorage
    ->delete($entities);
}