You are here

protected function EntityTestTextItemNormalizerTest::createEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestTextItemNormalizerTest::createEntity()
  2. 10 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestTextItemNormalizerTest::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityTestResourceTestBase::createEntity

File

core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php, line 65

Class

EntityTestTextItemNormalizerTest
@group rest

Namespace

Drupal\Tests\entity_test\Functional\Rest

Code

protected function createEntity() {
  $entity = parent::createEntity();
  if (!FilterFormat::load('my_text_format')) {
    FilterFormat::create([
      'format' => 'my_text_format',
      'name' => 'My Text Format',
      'filters' => [
        'filter_test_assets' => [
          'weight' => -1,
          'status' => TRUE,
        ],
        'filter_test_cache_tags' => [
          'weight' => 0,
          'status' => TRUE,
        ],
        'filter_test_cache_contexts' => [
          'weight' => 0,
          'status' => TRUE,
        ],
        'filter_test_cache_merge' => [
          'weight' => 0,
          'status' => TRUE,
        ],
        'filter_test_placeholders' => [
          'weight' => 1,
          'status' => TRUE,
        ],
        'filter_autop' => [
          'status' => TRUE,
        ],
      ],
    ])
      ->save();
  }
  $entity->field_test_text = [
    'value' => 'Cádiz is the oldest continuously inhabited city in Spain and a nice place to spend a Sunday with friends.',
    'format' => 'my_text_format',
  ];
  $entity
    ->save();
  return $entity;
}