You are here

public function FieldEncryptProcessEntitiesTest::encyptDecryptEntityDataProvider in Field Encryption 8.2

Data provider for testEncyptDecryptEntity method.

Return value

array An array with data for the test method.

File

tests/src/Unit/FieldEncryptProcessEntitiesTest.php, line 325
Contains \Drupal\Tests\field_encrypt\Unit\FieldEncryptProcessEntitiesTest.

Class

FieldEncryptProcessEntitiesTest
Unit Tests for the FieldEncryptProcessEntities service.

Namespace

Drupal\Tests\field_encrypt\Unit

Code

public function encyptDecryptEntityDataProvider() {
  return [
    'encrypted_string' => [
      'string',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
          'settings' => [
            'case_sensitive' => FALSE,
          ],
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => 'unencrypted text',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_string_long' => [
      'string_long',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
          'settings' => [
            'case_sensitive' => FALSE,
          ],
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => 'unencrypted text',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_text' => [
      'text',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
        ]),
        'format' => new DataDefinition([
          'type' => 'filter_format',
        ]),
        'processed' => new DataDefinition([
          'type' => 'string',
          'computed' => TRUE,
          'class' => '\\Drupal\\text\\TextProcessed',
          'settings' => [
            'text source' => 'value',
          ],
        ]),
      ],
      [
        'value' => 'value',
        'format' => 'format',
      ],
      [
        [
          'value' => '<p>unencrypted text</p>',
          'format' => 'basic_html',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
          'format' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_text_long' => [
      'text_long',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
        ]),
        'format' => new DataDefinition([
          'type' => 'filter_format',
        ]),
        'processed' => new DataDefinition([
          'type' => 'string',
          'computed' => TRUE,
          'class' => '\\Drupal\\text\\TextProcessed',
          'settings' => [
            'text source' => 'value',
          ],
        ]),
      ],
      [
        'value' => 'value',
        'format' => 'format',
      ],
      [
        [
          'value' => '<p>unencrypted text</p>',
          'format' => 'basic_html',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
          'format' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_text_with_summary' => [
      'text_with_summary',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
        ]),
        'format' => new DataDefinition([
          'type' => 'filter_format',
        ]),
        'processed' => new DataDefinition([
          'type' => 'string',
          'computed' => TRUE,
          'class' => '\\Drupal\\text\\TextProcessed',
          'settings' => [
            'text source' => 'value',
          ],
        ]),
        'summary' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
        ]),
        'summary_processed' => new DataDefinition([
          'type' => 'string',
          'computed' => TRUE,
          'class' => '\\Drupal\\text\\TextProcessed',
          'settings' => [
            'text source' => 'summarys',
          ],
        ]),
      ],
      [
        'value' => 'value',
        'summary' => 'summary',
        'format' => 'format',
      ],
      [
        [
          'value' => '<p>unencrypted text</p>',
          'summary' => 'summary',
          'format' => 'basic_html',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
          'summary' => '[ENCRYPTED]',
          'format' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_list_string' => [
      'list_string',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
          'constraints' => [
            'Length' => [
              'max' => 255,
            ],
          ],
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => 'value1',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_email' => [
      'email',
      [
        'value' => new DataDefinition([
          'type' => 'email',
          'required' => TRUE,
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => 'test@example.com',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_date' => [
      'datetime',
      [
        'value' => new DataDefinition([
          'type' => 'datetime_iso8601',
          'required' => TRUE,
        ]),
        'date' => new DataDefinition([
          'type' => 'any',
          'computed' => TRUE,
          'class' => '\\Drupal\\datetime\\DateTimeComputed',
          'settings' => [
            'date source' => 'value',
          ],
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => '1984-10-04T00:00:00',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_link' => [
      'link',
      [
        'uri' => new DataDefinition([
          'type' => 'uri',
        ]),
        'title' => new DataDefinition([
          'type' => 'string',
        ]),
        'options' => new DataDefinition([
          'type' => 'map',
        ]),
      ],
      [
        'uri' => 'uri',
        'title' => 'title',
      ],
      [
        [
          'title' => 'Drupal.org',
          'attributes' => [],
          'options' => [],
          'uri' => 'https://drupal.org',
        ],
      ],
      [
        [
          'title' => '[ENCRYPTED]',
          'uri' => '[ENCRYPTED]',
          'options' => [],
          'attributes' => [],
        ],
      ],
      TRUE,
    ],
    'encrypted_int' => [
      'integer',
      [
        'value' => new DataDefinition([
          'type' => 'integer',
          'required' => TRUE,
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => '42',
        ],
      ],
      [
        [
          'value' => 0,
        ],
      ],
      TRUE,
    ],
    'encrypted_float' => [
      'float',
      [
        'value' => new DataDefinition([
          'type' => 'float',
          'required' => TRUE,
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => '3.14',
        ],
      ],
      [
        [
          'value' => 0,
        ],
      ],
      TRUE,
    ],
    'encrypted_decimal' => [
      'decimal',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => '3.14',
        ],
      ],
      [
        [
          'value' => 0,
        ],
      ],
      TRUE,
    ],
    'encrypted_boolean' => [
      'boolean',
      [
        'value' => new DataDefinition([
          'type' => 'boolean',
          'required' => TRUE,
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => 1,
        ],
      ],
      [
        [
          'value' => 0,
        ],
      ],
      TRUE,
    ],
    'encrypted_telephone' => [
      'telephone',
      [
        'value' => new DataDefinition([
          'type' => 'string',
          'required' => TRUE,
        ]),
      ],
      [
        'value' => 'value',
      ],
      [
        [
          'value' => '+1-202-555-0161',
        ],
      ],
      [
        [
          'value' => '[ENCRYPTED]',
        ],
      ],
      TRUE,
    ],
    'encrypted_entity_reference' => [
      'entity_reference',
      [
        'target_id' => new DataDefinition([
          'type' => 'integer',
          'settings' => [
            'unsigned' => TRUE,
          ],
          'required' => TRUE,
        ]),
        'entity' => new DataDefinition([
          'type' => 'entity_reference',
          'computed' => TRUE,
          'read-only' => FALSE,
          'constraints' => [
            'EntityType' => 'user',
          ],
        ]),
      ],
      [
        'target_id' => 'target_id',
      ],
      [
        [
          'target_id' => 1,
        ],
      ],
      [
        [
          'target_id' => 0,
        ],
      ],
      TRUE,
    ],
    'not_encrypted' => [
      'text',
      [],
      [],
      'unencrypted text',
      NULL,
      FALSE,
    ],
  ];
}