protected function FieldEncryptTestBase::setUp in Field Encryption 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/FieldEncryptTestBase.php \Drupal\Tests\field_encrypt\Functional\FieldEncryptTestBase::setUp()
@TODO: Simplify setUp() by extending EncryptTestBase when https://www.drupal.org/node/2692387 lands.
1 call to FieldEncryptTestBase::setUp()
- CacheTest::setUp in tests/
src/ Functional/ CacheTest.php - @TODO: Simplify setUp() by extending EncryptTestBase when https://www.drupal.org/node/2692387 lands.
1 method overrides FieldEncryptTestBase::setUp()
- CacheTest::setUp in tests/
src/ Functional/ CacheTest.php - @TODO: Simplify setUp() by extending EncryptTestBase when https://www.drupal.org/node/2692387 lands.
File
- tests/
src/ Functional/ FieldEncryptTestBase.php, line 60
Class
- FieldEncryptTestBase
- Base test class for field_encrypt.
Namespace
Drupal\Tests\field_encrypt\FunctionalCode
protected function setUp() {
parent::setUp();
// Create an admin user.
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'administer encrypt',
'administer keys',
'administer field encryption',
], NULL, TRUE);
$this
->drupalLogin($this->adminUser);
$this->entityTypeManager = $this->container
->get('entity_type.manager');
// Create content type to test.
$this->nodeType = $this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
// Create test fields.
$single_field_storage = FieldStorageConfig::create([
'field_name' => 'field_test_single',
'entity_type' => 'node',
'type' => 'text_with_summary',
'cardinality' => 1,
]);
$single_field_storage
->save();
$single_field = FieldConfig::create([
'field_storage' => $single_field_storage,
'bundle' => 'page',
'label' => 'Single field',
]);
$single_field
->save();
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$display_repository
->getFormDisplay('node', 'page', 'default')
->setComponent('field_test_single')
->save();
$display_repository
->getViewDisplay('node', 'page', 'default')
->setComponent('field_test_single', [
'type' => 'text_default',
])
->save();
$multi_field_storage = FieldStorageConfig::create([
'field_name' => 'field_test_multi',
'entity_type' => 'node',
'type' => 'string',
'cardinality' => 3,
]);
$multi_field_storage
->save();
$multi_field = FieldConfig::create([
'field_storage' => $multi_field_storage,
'bundle' => 'page',
'label' => 'Multi field',
]);
$multi_field
->save();
$display_repository
->getFormDisplay('node', 'page', 'default')
->setComponent('field_test_multi')
->save();
$display_repository
->getViewDisplay('node', 'page', 'default')
->setComponent('field_test_multi', [
'type' => 'string',
])
->save();
$this
->config('field_encrypt.settings')
->set('encryption_profile', 'encryption_profile_1')
->save();
}