You are here

protected function EncryptingExistingDataTest::assertBaseFieldEncrypted in Field Encryption 3.0.x

Asserts that base fields are encrypted as expected.

Parameters

int $node_id: The node ID to check.

1 call to EncryptingExistingDataTest::assertBaseFieldEncrypted()
EncryptingExistingDataTest::testEncryptingExistingData in tests/src/Functional/EncryptingExistingDataTest.php
Tests that existing entities can be encrypted.

File

tests/src/Functional/EncryptingExistingDataTest.php, line 161

Class

EncryptingExistingDataTest
Tests encrypting fields on entities that already exist.

Namespace

Drupal\Tests\field_encrypt\Functional

Code

protected function assertBaseFieldEncrypted($node_id) {
  $result = \Drupal::database()
    ->query("SELECT title FROM {node_field_data} WHERE nid = :entity_id", [
    ':entity_id' => $node_id,
  ])
    ->fetchField();
  $this
    ->assertEquals(ProcessEntities::ENCRYPTED_VALUE, $result);

  // Revisions.
  $result = \Drupal::database()
    ->query("SELECT title FROM {node_field_revision} WHERE nid = :entity_id", [
    ':entity_id' => $node_id,
  ])
    ->fetchAll();
  foreach ($result as $record) {
    $this
      ->assertEquals(ProcessEntities::ENCRYPTED_VALUE, $record->title);
  }
}