.../Value/RelationshipNormalizerValueTest.php | 120 ++++++++++++++++++--- 1 file changed, 107 insertions(+), 13 deletions(-) diff --git a/tests/src/Unit/Normalizer/Value/RelationshipNormalizerValueTest.php b/tests/src/Unit/Normalizer/Value/RelationshipNormalizerValueTest.php index 855abfd..f7751ad 100644 --- a/tests/src/Unit/Normalizer/Value/RelationshipNormalizerValueTest.php +++ b/tests/src/Unit/Normalizer/Value/RelationshipNormalizerValueTest.php @@ -88,13 +88,21 @@ class RelationshipNormalizerValueTest extends UnitTestCase { $uid2->getCacheMaxAge()->willReturn(10); $img_id = $this->randomMachineName(); $img1 = $this->prophesize(RelationshipItemNormalizerValue::class); - $img1->rasterizeValue()->willReturn(['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal']]); + $img1->rasterizeValue()->willReturn([ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal'], + ]); $img1->getInclude()->willReturn(NULL); $img1->getCacheContexts()->willReturn(['ccimg1']); $img1->getCacheTags()->willReturn(['ctimg1']); $img1->getCacheMaxAge()->willReturn(100); $img2 = $this->prophesize(RelationshipItemNormalizerValue::class); - $img2->rasterizeValue()->willReturn(['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Adorable llama', 'title' => 'My spirit animal 😍']]); + $img2->rasterizeValue()->willReturn([ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => ['alt' => 'Adorable llama', 'title' => 'My spirit animal 😍'], + ]); $img2->getInclude()->willReturn(NULL); $img2->getCacheContexts()->willReturn(['ccimg2']); $img2->getCacheTags()->willReturn(['ctimg2']); @@ -155,7 +163,14 @@ class RelationshipNormalizerValueTest extends UnitTestCase { ->setCacheMaxAge(10), ], 'single cardinality, with meta' => [[$img1->reveal()], 1, [ - 'data' => ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal']], + 'data' => [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + ], + ], 'links' => $links, ], (new CacheableMetadata()) @@ -166,8 +181,24 @@ class RelationshipNormalizerValueTest extends UnitTestCase { 'multiple cardinality, all same values, with meta' => [ [$img1->reveal(), $img1->reveal()], 2, [ 'data' => [ - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal', 'arity' => 0]], - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal', 'arity' => 1]], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + 'arity' => 0, + ], + ], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + 'arity' => 1, + ], + ], ], 'links' => $links, ], @@ -179,9 +210,33 @@ class RelationshipNormalizerValueTest extends UnitTestCase { 'multiple cardinality, some same values with same values but different meta' => [ [$img1->reveal(), $img1->reveal(), $img2->reveal()], 2, [ 'data' => [ - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal', 'arity' => 0]], - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal', 'arity' => 1]], - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Adorable llama', 'title' => 'My spirit animal 😍', 'arity' => 2]], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + 'arity' => 0, + ], + ], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + 'arity' => 1, + ], + ], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Adorable llama', + 'title' => 'My spirit animal 😍', + 'arity' => 2, + ], + ], ], 'links' => $links, ], @@ -191,11 +246,44 @@ class RelationshipNormalizerValueTest extends UnitTestCase { ->setCacheMaxAge(50), ], 'all the edge cases!' => [ - [$img1->reveal(), $img1->reveal(), $img2->reveal(), $uid1->reveal(), $uid2->reveal(), $uid1->reveal()], 10, [ + [ + $img1->reveal(), + $img1->reveal(), + $img2->reveal(), + $uid1->reveal(), + $uid2->reveal(), + $uid1->reveal(), + ], + 10, + [ 'data' => [ - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal', 'arity' => 0]], - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Cute llama', 'title' => 'My spirit animal', 'arity' => 1]], - ['type' => 'file--file', 'id' => $img_id, 'meta' => ['alt' => 'Adorable llama', 'title' => 'My spirit animal 😍', 'arity' => 2]], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + 'arity' => 0, + ], + ], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Cute llama', + 'title' => 'My spirit animal', + 'arity' => 1, + ], + ], + [ + 'type' => 'file--file', + 'id' => $img_id, + 'meta' => [ + 'alt' => 'Adorable llama', + 'title' => 'My spirit animal 😍', + 'arity' => 2, + ], + ], ['type' => 'user', 'id' => 1, 'meta' => ['arity' => 0]], ['type' => 'user', 'id' => 2], ['type' => 'user', 'id' => 1, 'meta' => ['arity' => 1]], @@ -204,7 +292,13 @@ class RelationshipNormalizerValueTest extends UnitTestCase { ], (new CacheableMetadata()) ->setCacheContexts(['ccbar', 'ccfoo', 'ccimg1', 'ccimg2', 'user']) - ->setCacheTags(['ctbar', 'ctfoo', 'ctimg1', 'ctimg2', 'relationship:foo']) + ->setCacheTags([ + 'ctbar', + 'ctfoo', + 'ctimg1', + 'ctimg2', + 'relationship:foo', + ]) ->setCacheMaxAge(10), ], ];