function KeyValueEntityStorageTest::testSaveInvalid

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveInvalid()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveInvalid()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveInvalid()

@covers ::save @covers ::doSave

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function testSaveInvalid() : void {
    $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);
}

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