@@ -21,25 +21,51 @@ class CategoryPathTest extends TestCase
2121 /** @var MockObject|Category */
2222 private $ currentCategory ;
2323
24- public function test_category_path_is_correctly_sorted ()
24+ /** @var MockObject|CommunicationConfig */
25+ private $ communicationConfig ;
26+
27+ /** @var MockObject|Registry */
28+ private $ registry ;
29+
30+ public function test_category_path_for_ng_version ()
31+ {
32+ $ this ->communicationConfig ->method ('getVersion ' )->willReturn ('ng ' );
33+ $ categoryPath = $ this ->newCategoryPath ($ this ->communicationConfig );
34+
35+ $ this ->currentCategory ->method ('getParentCategories ' )
36+ ->willReturn ([$ this ->category ('Men ' , 1 ), $ this ->category ('Tops ' , 2 ), $ this ->category ('Jackets ' , 3 )]);
37+
38+ $ value = 'filter=CategoryPath%3AMen%2FTops%2FJackets ' ;
39+ $ this ->assertSame ($ value , (string ) $ categoryPath ->getCategoryPath ());
40+ }
41+
42+ public function test_category_path_for_standard_version ()
2543 {
44+ $ this ->communicationConfig ->method ('getVersion ' )->willReturn ('7.3 ' );
45+ $ categoryPath = $ this ->newCategoryPath ($ this ->communicationConfig );
46+
2647 $ this ->currentCategory ->method ('getParentCategories ' )
27- ->willReturn ([$ this ->category ('C ' , 3 ), $ this ->category ('A ' , 1 ), $ this ->category ('B ' , 2 )]);
48+ ->willReturn ([$ this ->category ('Jackets ' , 3 ), $ this ->category ('Men ' , 1 ), $ this ->category ('Tops ' , 2 )]);
2849
29- $ value = 'filterCategoryPathROOT=A ,filterCategoryPathROOT%2FA=B ,filterCategoryPathROOT%2FA%2FB=C ' ;
30- $ this ->assertSame ($ value , (string ) $ this -> categoryPath ->getValue ());
50+ $ value = 'filterCategoryPathROOT=Men ,filterCategoryPathROOT%2FMen=Tops ,filterCategoryPathROOT%2FMen%2FTops=Jackets ' ;
51+ $ this ->assertSame ($ value , (string ) $ categoryPath ->getAddParams ());
3152 }
3253
3354 protected function setUp (): void
3455 {
56+ $ this ->communicationConfig = $ this ->createMock (CommunicationConfig::class);
3557 $ this ->currentCategory = $ this ->createMock (Category::class);
36- $ registry = new Registry ();
37- $ this ->categoryPath = new CategoryPath ($ registry , $ this ->createMock (CommunicationConfig::class));
38- $ registry ->register ('current_category ' , $ this ->currentCategory );
58+ $ this ->registry = new Registry ();
59+ $ this ->registry ->register ('current_category ' , $ this ->currentCategory );
3960 }
4061
4162 private function category (string $ name , int $ level ): Category
4263 {
4364 return $ this ->createConfiguredMock (Category::class, ['getName ' => $ name , 'getLevel ' => $ level ]);
4465 }
66+
67+ private function newCategoryPath (CommunicationConfig $ communicationConfig ): CategoryPath
68+ {
69+ return new CategoryPath ($ this ->registry , $ this ->communicationConfig );;
70+ }
4571}
0 commit comments