public function FieldEncryptProcessEntitiesTest::testEntityHasEncryptedFields in Field Encryption 8.2
Test method entityHasEncryptedFields().
@covers ::__construct @covers ::entityHasEncryptedFields @covers ::checkField
@dataProvider entityHasEncryptedFieldsDataProvider
File
- tests/
src/ Unit/ FieldEncryptProcessEntitiesTest.php, line 165 - Contains \Drupal\Tests\field_encrypt\Unit\FieldEncryptProcessEntitiesTest.
Class
- FieldEncryptProcessEntitiesTest
- Unit Tests for the FieldEncryptProcessEntities service.
Namespace
Drupal\Tests\field_encrypt\UnitCode
public function testEntityHasEncryptedFields($encrypted, $expected) {
$definition = $this
->getMockBuilder('\\Drupal\\Core\\Field\\BaseFieldDefinition')
->setMethods([
'get',
])
->disableOriginalConstructor()
->getMock();
$storage = $this
->getMockBuilder('\\Drupal\\Core\\Field\\FieldConfigStorageBase')
->setMethods([
'getThirdPartySetting',
])
->disableOriginalConstructor()
->getMock();
// Set up expectations for storage.
$storage
->expects($this
->once())
->method('getThirdPartySetting')
->will($this
->returnValue($encrypted));
// Set up expectations for definition.
$definition
->expects($this
->once())
->method('get')
->will($this
->returnValue($storage));
// Set up expectations for field.
$this->field
->expects($this
->once())
->method('getFieldDefinition')
->will($this
->returnValue($definition));
// Set up expectations for entity.
$this->entity
->expects($this
->once())
->method('getFields')
->will($this
->returnValue([
$this->field,
]));
$service = new FieldEncryptProcessEntities($this->entityManager, $this->encryptService, $this->encryptionProfileManager, $this->encryptedFieldValueManager);
$return = $service
->entityHasEncryptedFields($this->entity);
$this
->assertEquals($expected, $return);
}