@@ -45,44 +45,39 @@ public function testCMSPageUrlResolver()
45
45
$ targetPath = $ urlPathGenerator ->getCanonicalUrlPath ($ page );
46
46
$ expectedEntityType = CmsPageUrlRewriteGenerator::ENTITY_TYPE ;
47
47
48
- $ query
49
- = <<<QUERY
50
- {
51
- urlResolver(url:" {$ requestPath }")
52
- {
53
- id
54
- relative_url
55
- type
56
- redirectCode
57
- }
58
- }
59
- QUERY ;
48
+ $ query = $ this ->createQuery ($ requestPath );
60
49
$ response = $ this ->graphQlQuery ($ query );
61
50
$ this ->assertEquals ($ cmsPageId , $ response ['urlResolver ' ]['id ' ]);
62
51
$ this ->assertEquals ($ requestPath , $ response ['urlResolver ' ]['relative_url ' ]);
63
52
$ this ->assertEquals (strtoupper (str_replace ('- ' , '_ ' , $ expectedEntityType )), $ response ['urlResolver ' ]['type ' ]);
64
53
$ this ->assertEquals (0 , $ response ['urlResolver ' ]['redirectCode ' ]);
65
54
66
55
// querying by non seo friendly url path should return seo friendly relative url
67
- $ query
68
- = <<<QUERY
69
- {
70
- urlResolver(url:" {$ targetPath }")
71
- {
72
- id
73
- relative_url
74
- type
75
- redirectCode
76
- }
77
- }
78
- QUERY ;
56
+ $ query = $ this ->createQuery ($ targetPath );
79
57
$ response = $ this ->graphQlQuery ($ query );
80
58
$ this ->assertEquals ($ cmsPageId , $ response ['urlResolver ' ]['id ' ]);
81
59
$ this ->assertEquals ($ requestPath , $ response ['urlResolver ' ]['relative_url ' ]);
82
60
$ this ->assertEquals (strtoupper (str_replace ('- ' , '_ ' , $ expectedEntityType )), $ response ['urlResolver ' ]['type ' ]);
83
61
$ this ->assertEquals (0 , $ response ['urlResolver ' ]['redirectCode ' ]);
84
62
}
85
63
64
+ /**
65
+ * @magentoApiDataFixture Magento/Cms/_files/pages.php
66
+ */
67
+ public function testResolveCMSPageWithQueryParameters ()
68
+ {
69
+ $ page = $ this ->objectManager ->create (\Magento \Cms \Model \Page::class);
70
+ $ page ->load ('page100 ' );
71
+ $ cmsPageId = $ page ->getId ();
72
+ $ requestPath = $ page ->getIdentifier ();
73
+
74
+ $ query = $ this ->createQuery ($ requestPath . '?key=value ' );
75
+ $ response = $ this ->graphQlQuery ($ query );
76
+ $ this ->assertNotEmpty ($ response ['urlResolver ' ]);
77
+ $ this ->assertEquals ($ cmsPageId , $ response ['urlResolver ' ]['id ' ]);
78
+ $ this ->assertEquals ($ requestPath , $ response ['urlResolver ' ]['relative_url ' ]);
79
+ }
80
+
86
81
/**
87
82
* Test resolution of '/' path to home page
88
83
*/
@@ -98,10 +93,24 @@ public function testResolveSlash()
98
93
$ page = $ this ->objectManager ->get (\Magento \Cms \Model \Page::class);
99
94
$ page ->load ($ homePageIdentifier );
100
95
$ homePageId = $ page ->getId ();
101
- $ query
102
- = <<<QUERY
96
+ $ query = $ this ->createQuery ('/ ' );
97
+ $ response = $ this ->graphQlQuery ($ query );
98
+ $ this ->assertArrayHasKey ('urlResolver ' , $ response );
99
+ $ this ->assertEquals ($ homePageId , $ response ['urlResolver ' ]['id ' ]);
100
+ $ this ->assertEquals ($ homePageIdentifier , $ response ['urlResolver ' ]['relative_url ' ]);
101
+ $ this ->assertEquals ('CMS_PAGE ' , $ response ['urlResolver ' ]['type ' ]);
102
+ $ this ->assertEquals (0 , $ response ['urlResolver ' ]['redirectCode ' ]);
103
+ }
104
+
105
+ /**
106
+ * @param string $path
107
+ * @return string
108
+ */
109
+ private function createQuery (string $ path ): string
110
+ {
111
+ return <<<QUERY
103
112
{
104
- urlResolver(url:"/ ")
113
+ urlResolver(url:" { $ path } ")
105
114
{
106
115
id
107
116
relative_url
@@ -110,11 +119,5 @@ public function testResolveSlash()
110
119
}
111
120
}
112
121
QUERY ;
113
- $ response = $ this ->graphQlQuery ($ query );
114
- $ this ->assertArrayHasKey ('urlResolver ' , $ response );
115
- $ this ->assertEquals ($ homePageId , $ response ['urlResolver ' ]['id ' ]);
116
- $ this ->assertEquals ($ homePageIdentifier , $ response ['urlResolver ' ]['relative_url ' ]);
117
- $ this ->assertEquals ('CMS_PAGE ' , $ response ['urlResolver ' ]['type ' ]);
118
- $ this ->assertEquals (0 , $ response ['urlResolver ' ]['redirectCode ' ]);
119
122
}
120
123
}
0 commit comments