You are here

public function KeyValueEntityStorageTest::testSaveInvalid in Drupal 8

@covers ::save @covers ::doSave

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 458

Class

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

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function testSaveInvalid() {
  $this
    ->setUpKeyValueEntityStorage();
  $entity = $this
    ->getMockEntity('Drupal\\Core\\Config\\Entity\\ConfigEntityBase');
  $this->keyValueStore
    ->expects($this
    ->never())
    ->method('has');
  $this->keyValueStore
    ->expects($this
    ->never())
    ->method('set');
  $this->keyValueStore
    ->expects($this
    ->never())
    ->method('delete');
  $this
    ->expectException(EntityMalformedException::class);
  $this
    ->expectExceptionMessage('The entity does not have an ID.');
  $this->entityStorage
    ->save($entity);
}