You are here

public function EncryptUserTest::testEncryptFieldNormal in Field Encryption 3.0.x

Test encrypting user fields.

This test covers encrypting non-revisionable entities as well.

File

tests/src/Functional/EncryptUserTest.php, line 86

Class

EncryptUserTest
Tests user field encryption.

Namespace

Drupal\Tests\field_encrypt\Functional

Code

public function testEncryptFieldNormal() {
  $this
    ->setFieldStorageSettings(TRUE);
  $this
    ->drupalGet('admin/config/system/field-encrypt/process-queues');
  $this
    ->assertSession()
    ->pageTextContains('There are 4 entities queued for updating to use the latest field encryption settings.');
  $this
    ->cronRun();
  $this
    ->drupalGet('admin/config/system/field-encrypt/process-queues');
  $this
    ->assertSession()
    ->pageTextContains('There are 0 entities queued for updating to use the latest field encryption settings.');
  $result = \Drupal::database()
    ->query("SELECT init FROM {users_field_data} WHERE uid = :uid", [
    ':uid' => $this->adminUser
      ->id(),
  ])
    ->fetchAll();
  $this
    ->assertCount(1, $result);
  foreach ($result as $record) {
    $this
      ->assertEquals(ProcessEntities::ENCRYPTED_VALUE, $record->init);
  }
}