function EntityTestTextItemNormalizerTest::createEntity

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestTextItemNormalizerTest::createEntity()
  2. 8.9.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestTextItemNormalizerTest::createEntity()
  3. 11.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestTextItemNormalizerTest::createEntity()

Overrides EntityTestResourceTestBase::createEntity

File

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

Class

EntityTestTextItemNormalizerTest
@group rest @group #slow

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.