You are here

protected function FieldEncryptTestBase::setFieldStorageSettings in Field Encryption 8.2

Same name and namespace in other branches
  1. 3.0.x tests/src/Functional/FieldEncryptTestBase.php \Drupal\Tests\field_encrypt\Functional\FieldEncryptTestBase::setFieldStorageSettings()

Set up storage settings for test fields.

3 calls to FieldEncryptTestBase::setFieldStorageSettings()
FieldEncryptTest::testEncryptField in tests/src/Functional/FieldEncryptTest.php
Test encrypting fields.
FieldEncryptTest::testEncryptFieldRevision in tests/src/Functional/FieldEncryptTest.php
Test encrypting fields with revisions.
FieldEncryptTest::testEncryptFieldTranslation in tests/src/Functional/FieldEncryptTest.php
Test encrypting fields with translations.
1 method overrides FieldEncryptTestBase::setFieldStorageSettings()
FieldEncryptCacheTest::setFieldStorageSettings in tests/src/Functional/FieldEncryptCacheTest.php
Set up storage settings for test fields.

File

tests/src/Functional/FieldEncryptTestBase.php, line 148

Class

FieldEncryptTestBase
Base test class for field_encrypt.

Namespace

Drupal\Tests\field_encrypt\Functional

Code

protected function setFieldStorageSettings($encryption = TRUE, $alternate = FALSE, $uncacheable = TRUE) {

  // Set up storage settings for first field.
  $this
    ->drupalGet('admin/structure/types/manage/page/fields/node.page.field_test_single/storage');

  // Encrypt field found.
  $this
    ->assertFieldByName('field_encrypt[encrypt]', NULL);

  // Encryption profile field found.
  $this
    ->assertFieldByName('field_encrypt[encryption_profile]', NULL);
  $profile_id = $alternate == TRUE ? 'encryption_profile_2' : 'encryption_profile_1';
  $edit = [
    'field_encrypt[encrypt]' => $encryption,
    'field_encrypt[properties][value]' => 'value',
    'field_encrypt[properties][summary]' => 'summary',
    'field_encrypt[encryption_profile]' => $profile_id,
    'field_encrypt[uncacheable]' => $uncacheable,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save field settings');
  $this
    ->assertText('Updated field Single field field settings.');

  // Set up storage settings for second field.
  $this
    ->drupalGet('admin/structure/types/manage/page/fields/node.page.field_test_multi/storage');

  // Encrypt field found.
  $this
    ->assertFieldByName('field_encrypt[encrypt]', NULL);

  // Encryption profile field found.
  $this
    ->assertFieldByName('field_encrypt[encryption_profile]', NULL);
  $profile_id = $alternate == TRUE ? 'encryption_profile_1' : 'encryption_profile_2';
  $edit = [
    'field_encrypt[encrypt]' => $encryption,
    'field_encrypt[properties][value]' => 'value',
    'field_encrypt[encryption_profile]' => $profile_id,
    'field_encrypt[uncacheable]' => $uncacheable,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save field settings');
  $this
    ->assertText('Updated field Multi field field settings.');
}