@@ -29,7 +29,51 @@ public function testMap(): void
29
29
$ this ->getConfigResolverMock ()
30
30
);
31
31
32
- $ content = new Content ([
32
+ $ content = $ this ->createContentWithLocationPath (['1 ' , '2 ' , '3 ' , '4 ' , '5 ' , '6 ' , '7 ' ]);
33
+
34
+ $ result = $ mapper ->map (
35
+ new SearchHit ([
36
+ 'valueObject ' => $ content ,
37
+ ])
38
+ );
39
+
40
+ self ::assertInstanceOf (ContentSuggestion::class, $ result );
41
+ self ::assertSame ($ content , $ result ->getContent ());
42
+ self ::assertSame ('5/6/7 ' , $ result ->getPathString ());
43
+ self ::assertCount (3 , $ result ->getParentsLocation ());
44
+ self ::assertSame ('name_eng ' , $ result ->getName ());
45
+ self ::assertSame (50.0 , $ result ->getScore ());
46
+ }
47
+
48
+ public function testMapContentOutsideRootLocation (): void
49
+ {
50
+ $ mapper = new SearchHitToContentSuggestionMapper (
51
+ $ this ->getParentLocationProviderMock (),
52
+ $ this ->getConfigResolverMock ()
53
+ );
54
+
55
+ $ content = $ this ->createContentWithLocationPath (['1 ' , '2 ' , '3 ' , '4 ' , '6 ' , '7 ' ]);
56
+
57
+ $ result = $ mapper ->map (
58
+ new SearchHit ([
59
+ 'valueObject ' => $ content ,
60
+ ])
61
+ );
62
+
63
+ self ::assertInstanceOf (ContentSuggestion::class, $ result );
64
+ self ::assertSame ($ content , $ result ->getContent ());
65
+ self ::assertSame ('2/3/4/6/7 ' , $ result ->getPathString ());
66
+ self ::assertCount (5 , $ result ->getParentsLocation ());
67
+ self ::assertSame ('name_eng ' , $ result ->getName ());
68
+ self ::assertSame (50.0 , $ result ->getScore ());
69
+ }
70
+
71
+ /**
72
+ * @param string[] $path
73
+ */
74
+ private function createContentWithLocationPath (array $ path ): Content
75
+ {
76
+ return new Content ([
33
77
'id ' => 1 ,
34
78
'contentInfo ' => new ContentInfo ([
35
79
'name ' => 'name ' ,
@@ -46,27 +90,14 @@ public function testMap(): void
46
90
'contentTypeId ' => 1 ,
47
91
'mainLocation ' => new Location ([
48
92
'id ' => 8 ,
49
- 'path ' => [ ' 1 ' , ' 2 ' , ' 3 ' , ' 4 ' , ' 5 ' , ' 6 ' , ' 7 ' ] ,
93
+ 'path ' => $ path ,
50
94
]),
51
95
]),
52
96
]),
53
97
'contentType ' => new ContentType ([
54
98
'identifier ' => 'content_type_identifier ' ,
55
99
]),
56
100
]);
57
-
58
- $ result = $ mapper ->map (
59
- new SearchHit ([
60
- 'valueObject ' => $ content ,
61
- ])
62
- );
63
-
64
- self ::assertInstanceOf (ContentSuggestion::class, $ result );
65
- self ::assertSame ($ content , $ result ->getContent ());
66
- self ::assertSame ('5/6/7 ' , $ result ->getPathString ());
67
- self ::assertCount (3 , $ result ->getParentsLocation ());
68
- self ::assertSame ('name_eng ' , $ result ->getName ());
69
- self ::assertSame (50.0 , $ result ->getScore ());
70
101
}
71
102
72
103
/**
0 commit comments