public function EncryptedFieldValueManagerTest::testDeleteEntityEncryptedFieldValuesForField in Field Encryption 8.2
Test the deleteEntityEncryptedFieldValuesForField method.
@covers ::__construct @covers ::deleteEntityEncryptedFieldValuesForField @covers ::getEntityRevisionId
File
- tests/
src/ Unit/ EncryptedFieldValueManagerTest.php, line 267 - Contains \Drupal\Tests\field_encrypt\Unit\EncryptedFieldValueManagerTest.
Class
- EncryptedFieldValueManagerTest
- Unit Tests for the EncryptedFieldValueManager service.
Namespace
Drupal\Tests\field_encrypt\UnitCode
public function testDeleteEntityEncryptedFieldValuesForField() {
// Set up expectations for storage.
$this->storage
->expects($this
->once())
->method('loadByProperties')
->will($this
->returnValue([
$this->encryptedFieldValue,
]));
$this->storage
->expects($this
->once())
->method('delete');
// Set up entity type object.
$entity_type = $this
->getMockBuilder('\\Drupal\\Core\\Entity\\EntityTypeInterface')
->disableOriginalConstructor()
->getMock();
// Set up expectations for entity type object.
$entity_type
->expects($this
->once())
->method('hasKey')
->will($this
->returnValue(TRUE));
$this->entity
->expects($this
->any())
->method('getEntityType')
->will($this
->returnValue($entity_type));
$this->entity
->expects($this
->once())
->method('getRevisionId')
->will($this
->returnValue(1));
$this->entity
->expects($this
->never())
->method('id')
->will($this
->returnValue(1));
$service = new EncryptedFieldValueManager($this->entityManager);
$service
->deleteEntityEncryptedFieldValuesForField($this->entity, 'field_test');
}