protected function FieldEncryptCacheTest::setFieldStorageSettings in Field Encryption 8.2
Set up storage settings for test fields.
Overrides FieldEncryptTestBase::setFieldStorageSettings
3 calls to FieldEncryptCacheTest::setFieldStorageSettings()
- FieldEncryptCacheTest::setUp in tests/
src/ Functional/ FieldEncryptCacheTest.php - @TODO: Simplify setUp() by extending EncryptTestBase when https://www.drupal.org/node/2692387 lands.
- FieldEncryptCacheTest::testDynamicPageCache in tests/
src/ Functional/ FieldEncryptCacheTest.php - Test caching of encrypted fields on response level.
- FieldEncryptCacheTest::testEntityCache in tests/
src/ Functional/ FieldEncryptCacheTest.php - Test caching of encrypted fields on entity level.
File
- tests/
src/ Functional/ FieldEncryptCacheTest.php, line 116
Class
- FieldEncryptCacheTest
- Tests field encryption caching.
Namespace
Drupal\Tests\field_encrypt\FunctionalCode
protected function setFieldStorageSettings($encryption = TRUE, $alternate = FALSE, $uncacheable = TRUE) {
$fields = [
'node.field_test_single' => [
'properties' => [
'value' => 'value',
'summary' => 'summary',
],
'profile' => $alternate == TRUE ? 'encryption_profile_2' : 'encryption_profile_1',
],
'node.field_test_multi' => [
'properties' => [
'value' => 'value',
],
'profile' => $alternate == TRUE ? 'encryption_profile_1' : 'encryption_profile_2',
],
];
foreach ($fields as $field => $settings) {
$field_storage = FieldStorageConfig::load($field);
if ($encryption) {
$field_storage
->setThirdPartySetting('field_encrypt', 'encrypt', TRUE);
$field_storage
->setThirdPartySetting('field_encrypt', 'properties', $settings['properties']);
$field_storage
->setThirdPartySetting('field_encrypt', 'encryption_profile', $settings['profile']);
$field_storage
->setThirdPartySetting('field_encrypt', 'uncacheable', $uncacheable);
}
else {
$field_storage
->unsetThirdPartySetting('field_encrypt', 'encrypt');
$field_storage
->unsetThirdPartySetting('field_encrypt', 'properties');
$field_storage
->unsetThirdPartySetting('field_encrypt', 'encryption_profile');
$field_storage
->unsetThirdPartySetting('field_encrypt', 'uncacheable');
}
$field_storage
->save();
}
}