You are here

public function ConfigEntityStorageTest::testSaveNoMismatch in Drupal 9

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

@covers ::save @covers ::doSave

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 466

Class

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

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testSaveNoMismatch() {
  $immutable_config_object = $this
    ->prophesize(ImmutableConfig::class);
  $immutable_config_object
    ->isNew()
    ->willReturn(TRUE);
  $config_object = $this
    ->prophesize(Config::class);
  $config_object
    ->get()
    ->willReturn([]);
  $config_object
    ->setData([
    'id' => 'foo',
    'uuid' => NULL,
    'dependencies' => [],
    'langcode' => 'en',
    'status' => TRUE,
  ])
    ->shouldBeCalled();
  $config_object
    ->save(FALSE)
    ->shouldBeCalled();
  $this->cacheTagsInvalidator
    ->invalidateTags([
    $this->entityTypeId . '_list',
  ])
    ->shouldBeCalled();
  $this->configFactory
    ->get('the_provider.the_config_prefix.baz')
    ->willReturn($immutable_config_object
    ->reveal())
    ->shouldBeCalled();
  $this->configFactory
    ->rename('the_provider.the_config_prefix.baz', 'the_provider.the_config_prefix.foo')
    ->shouldBeCalled();
  $this->configFactory
    ->getEditable('the_provider.the_config_prefix.foo')
    ->willReturn($config_object
    ->reveal())
    ->shouldBeCalled();
  $this->entityQuery
    ->condition('uuid', NULL)
    ->willReturn($this->entityQuery);
  $this->entityQuery
    ->execute()
    ->willReturn([
    'baz',
  ]);
  $entity = $this
    ->getMockEntity([
    'id' => 'foo',
  ]);
  $entity
    ->setOriginalId('baz');
  $entity
    ->enforceIsNew();
  $this->entityStorage
    ->save($entity);
}