function ConfigEntityStorageTest::testSaveDuplicate

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

@covers ::save @covers ::doSave

File

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

Class

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

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testSaveDuplicate() : void {
    $config_object = $this->prophesize(ImmutableConfig::class);
    $config_object->isNew()
        ->willReturn(FALSE);
    $this->cacheTagsInvalidator
        ->invalidateTags(Argument::cetera())
        ->shouldNotBeCalled();
    $this->configFactory
        ->get('the_provider.the_config_prefix.foo')
        ->willReturn($config_object->reveal());
    $entity = $this->getMockEntity([
        'id' => 'foo',
    ]);
    $entity->enforceIsNew();
    $this->expectException(EntityStorageException::class);
    $this->entityStorage
        ->save($entity);
}

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