tests/src/Kernel/EntityEmbedFilterTest.php | 61 +++++++++++++----------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/tests/src/Kernel/EntityEmbedFilterTest.php b/tests/src/Kernel/EntityEmbedFilterTest.php index af9f1bc..bdf6be0 100644 --- a/tests/src/Kernel/EntityEmbedFilterTest.php +++ b/tests/src/Kernel/EntityEmbedFilterTest.php @@ -235,34 +235,6 @@ class EntityEmbedFilterTest extends EntityEmbedFilterTestBase { ]; } - /** - * Tests for invalid Entity. - * - * @dataProvider providerTestInvalidEntity - */ - public function testInvalidEntity(array $embed_attributes) { - $content = $this->createEmbedCode($embed_attributes); - - $this->applyFilter($content); - } - - /** - * Data provider for testInvalidEntity(). - * - * @TODO: add more tests. - */ - public function providerTestInvalidEntity() { - return [ - "Ensure that content that can't be loaded is replaced with warning" => [ - 'embed_attributes' => [ - 'data-entity-type' => 'node', - 'data-entity-uuid' => 'InvalidID', - 'data-view-mode' => 'teaser', - ], - ], - ]; - } - /** * Tests that only tags are processed. */ @@ -374,19 +346,24 @@ class EntityEmbedFilterTest extends EntityEmbedFilterTestBase { } /** - * Tests the placeholder for missing entities. + * Tests the indicator for missing entities. + * + * @dataProvider providerMissingEntityIndicator */ - public function testMissingEntityPlaceholder() { + public function testMissingEntityIndicator($uuid) { $content = $this->createEmbedCode([ 'data-entity-type' => 'node', - 'data-entity-uuid' => $this->embeddedEntity->uuid(), + 'data-entity-uuid' => $uuid, 'data-view-mode' => 'default', ]); - $this->applyFilter($content); - $this->assertCount(1, $this->cssSelect('div.embedded-entity > [data-entity-embed-test-view-mode="default"]')); - - $this->embeddedEntity->delete(); + // If the UUID being used in the embed is that of the sample entity, first + // assert that it currently results in a functional embed, then delete it. + if ($uuid === static::EMBEDDED_ENTITY_UUID) { + $this->applyFilter($content); + $this->assertCount(1, $this->cssSelect('div.embedded-entity > [data-entity-embed-test-view-mode="default"]')); + $this->embeddedEntity->delete(); + } $this->applyFilter($content); $this->assertCount(0, $this->cssSelect('div.embedded-entity > [data-entity-embed-test-view-mode="default"]')); @@ -400,4 +377,18 @@ class EntityEmbedFilterTest extends EntityEmbedFilterTestBase { ]); } + /** + * Data provider for testMissingEntityIndicator(). + */ + public function providerMissingEntityIndicator() { + return [ + 'valid UUID but for a deleted entity' => [ + static::EMBEDDED_ENTITY_UUID + ], + 'invalid UUID' => [ + 'invalidUUID', + ], + ]; + } + }