You are here

public function KeyValueEntityStorageTest::testSaveDuplicate in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveDuplicate()

@covers ::save @covers ::doSave

@expectedException \Drupal\Core\Entity\EntityStorageException @expectedExceptionMessage 'test_entity_type' entity with ID 'foo' already exists

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 471
Contains \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest.

Class

KeyValueEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function testSaveDuplicate() {
  $this
    ->setUpKeyValueEntityStorage();
  $entity = $this
    ->getMockEntity('Drupal\\Core\\Entity\\Entity', array(
    array(
      'id' => 'foo',
    ),
  ));
  $entity
    ->enforceIsNew();
  $this->keyValueStore
    ->expects($this
    ->once())
    ->method('has')
    ->will($this
    ->returnValue(TRUE));
  $this->keyValueStore
    ->expects($this
    ->never())
    ->method('set');
  $this->keyValueStore
    ->expects($this
    ->never())
    ->method('delete');
  $this->entityStorage
    ->save($entity);
}