function ConfigEntityStorageTest::testSaveMismatch

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveMismatch()
  2. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveMismatch()
  3. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveMismatch()

@covers ::save @covers ::doSave

File

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

Class

ConfigEntityStorageTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21Entity%21ConfigEntityStorage.php/class/ConfigEntityStorage/8.9.x" title="Defines the storage class for configuration entities." class="local">\Drupal\Core\Config\Entity\ConfigEntityStorage</a> @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testSaveMismatch() {
    $config_object = $this->prophesize(ImmutableConfig::class);
    $config_object->isNew()
        ->willReturn(TRUE);
    $this->cacheTagsInvalidator
        ->invalidateTags(Argument::cetera())
        ->shouldNotBeCalled();
    $this->configFactory
        ->get('the_provider.the_config_prefix.foo')
        ->willReturn($config_object->reveal());
    $this->entityQuery
        ->condition('uuid', NULL)
        ->willReturn($this->entityQuery);
    $this->entityQuery
        ->execute()
        ->willReturn([
        'baz',
    ]);
    $entity = $this->getMockEntity([
        'id' => 'foo',
    ]);
    $this->expectException(ConfigDuplicateUUIDException::class);
    $this->expectExceptionMessage('when this UUID is already used for');
    $this->entityStorage
        ->save($entity);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.