You are here

public function DynamicEntityHooksTest::testDynamicFunctionRegistration in Field Encryption 3.0.x

Tests _field_encrypt_define_entity_hooks().

File

tests/src/Kernel/DynamicEntityHooksTest.php, line 32

Class

DynamicEntityHooksTest
Tests dynamic entity hook creation.

Namespace

Drupal\Tests\field_encrypt\Kernel

Code

public function testDynamicFunctionRegistration() {
  if (!_field_encrypt_can_eval()) {
    $this
      ->markTestSkipped('eval() not available');
  }
  $this
    ->assertFalse(function_exists('field_encrypt_test1_insert'));
  $this
    ->assertFalse(function_exists('field_encrypt_test1_update'));
  $this
    ->assertFalse(function_exists('field_encrypt_test2_insert'));
  $this
    ->assertFalse(function_exists('field_encrypt_test2_update'));
  $this->container
    ->get('state')
    ->set('field_encrypt.entity_types', [
    'test1',
    'test2',
  ]);
  _field_encrypt_define_entity_hooks();
  $this
    ->assertTrue(function_exists('field_encrypt_test1_insert'));
  $this
    ->assertTrue(function_exists('field_encrypt_test1_update'));
  $this
    ->assertTrue(function_exists('field_encrypt_test2_insert'));
  $this
    ->assertTrue(function_exists('field_encrypt_test2_update'));
}