You are here

public function ConfigEntityStorageTest::testSaveDuplicate 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::testSaveDuplicate()

@covers ::save @covers ::doSave

@expectedException \Drupal\Core\Entity\EntityStorageException

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php, line 496
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 testSaveDuplicate() {
  $config_object = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $config_object
    ->expects($this
    ->atLeastOnce())
    ->method('isNew')
    ->will($this
    ->returnValue(FALSE));
  $config_object
    ->expects($this
    ->never())
    ->method('set');
  $config_object
    ->expects($this
    ->never())
    ->method('save');
  $this->cacheTagsInvalidator
    ->expects($this
    ->never())
    ->method('invalidateTags');
  $this->configFactory
    ->expects($this
    ->once())
    ->method('get')
    ->with('the_config_prefix.foo')
    ->will($this
    ->returnValue($config_object));
  $entity = $this
    ->getMockEntity(array(
    'id' => 'foo',
  ));
  $entity
    ->enforceIsNew();
  $this->entityStorage
    ->save($entity);
}