.../EntityTestTextItemNormalizerTest.php | 68 +++++++++++++--------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestTextItemNormalizerTest.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestTextItemNormalizerTest.php index b41ad7f..0857a4e 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestTextItemNormalizerTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestTextItemNormalizerTest.php @@ -32,6 +32,16 @@ class EntityTestTextItemNormalizerTest extends EntityTestResourceTestBase { /** * {@inheritdoc} */ + protected function setUpAuthorization($method) { + parent::setUpAuthorization($method); + if ($method === 'POST') { + $this->grantPermissionsToTestedRole(['use text format my_text_format']); + } + } + + /** + * {@inheritdoc} + */ protected function getExpectedNormalizedEntity() { $expected = parent::getExpectedNormalizedEntity(); $expected['field_test_text'] = [ @@ -49,35 +59,37 @@ protected function getExpectedNormalizedEntity() { */ protected function createEntity() { $entity = parent::createEntity(); - 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, + 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(); + ])->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',