From 63f9f5f6444f269dda80d44ca7627543d56121c7 Mon Sep 17 00:00:00 2001
From: idebr <idebr@1879760.no-reply.drupal.org>
Date: Tue, 16 May 2017 20:46:58 +0200
Subject: [PATCH] Issue #2878914 by idebr: Update test assertions to new W3C
 valid query-strings

---
 .../tests/src/Functional/RestIntegrationTest.php   | 28 +++++++++++-----------
 .../Unit/Plugin/url_processor/QueryStringTest.php  | 16 ++++++-------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/modules/rest_facets/tests/src/Functional/RestIntegrationTest.php b/modules/rest_facets/tests/src/Functional/RestIntegrationTest.php
index aa77454..bf7e5c7 100644
--- a/modules/rest_facets/tests/src/Functional/RestIntegrationTest.php
+++ b/modules/rest_facets/tests/src/Functional/RestIntegrationTest.php
@@ -117,11 +117,11 @@ class RestIntegrationTest extends FacetsTestBase {
     // Verify the facet "Type".
     $results = [
       'article' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aarticle',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aarticle',
         'count' => 2,
       ],
       'item' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem',
         'count' => 3,
       ],
     ];
@@ -135,23 +135,23 @@ class RestIntegrationTest extends FacetsTestBase {
     // Verify the facet "Keywords".
     $results = [
       'banana' => [
-        'url' => $base_url . '/facets-rest?f[0]=keywords%3Abanana',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=keywords%3Abanana',
         'count' => 1,
       ],
       'strawberry' => [
-        'url' => $base_url . '/facets-rest?f[0]=keywords%3Astrawberry',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=keywords%3Astrawberry',
         'count' => 2,
       ],
       'apple' => [
-        'url' => $base_url . '/facets-rest?f[0]=keywords%3Aapple',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=keywords%3Aapple',
         'count' => 2,
       ],
       'orange' => [
-        'url' => $base_url . '/facets-rest?f[0]=keywords%3Aorange',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=keywords%3Aorange',
         'count' => 3,
       ],
       'grape' => [
-        'url' => $base_url . '/facets-rest?f[0]=keywords%3Agrape',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=keywords%3Agrape',
         'count' => 3,
       ],
     ];
@@ -163,14 +163,14 @@ class RestIntegrationTest extends FacetsTestBase {
     }
 
     // Filter and verify that the results are correct.
-    $json = $this->drupalGet($base_url . '/facets-rest?f[0]=type%3Aitem');
+    $json = $this->drupalGet($base_url . '/facets-rest?f%5B0%5D=type%3Aitem');
     $json_decoded = json_decode($json);
 
     $this->assertEqual(count($json_decoded->search_results), 3);
 
     $results = [
       'article' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem&f[1]=type%3Aarticle',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem&f%5B1%5D=type%3Aarticle',
         'count' => 2,
       ],
       'item' => [
@@ -178,23 +178,23 @@ class RestIntegrationTest extends FacetsTestBase {
         'count' => 3,
       ],
       'banana' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem&f[1]=keywords%3Abanana',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem&f%5B1%5D=keywords%3Abanana',
         'count' => 0,
       ],
       'strawberry' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem&f[1]=keywords%3Astrawberry',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem&f%5B1%5D=keywords%3Astrawberry',
         'count' => 0,
       ],
       'apple' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem&f[1]=keywords%3Aapple',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem&f%5B1%5D=keywords%3Aapple',
         'count' => 1,
       ],
       'orange' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem&f[1]=keywords%3Aorange',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem&f%5B1%5D=keywords%3Aorange',
         'count' => 2,
       ],
       'grape' => [
-        'url' => $base_url . '/facets-rest?f[0]=type%3Aitem&f[1]=keywords%3Agrape',
+        'url' => $base_url . '/facets-rest?f%5B0%5D=type%3Aitem&f%5B1%5D=keywords%3Agrape',
         'count' => 1,
       ],
     ];
diff --git a/tests/src/Unit/Plugin/url_processor/QueryStringTest.php b/tests/src/Unit/Plugin/url_processor/QueryStringTest.php
index 946bf71..78a2060 100644
--- a/tests/src/Unit/Plugin/url_processor/QueryStringTest.php
+++ b/tests/src/Unit/Plugin/url_processor/QueryStringTest.php
@@ -147,7 +147,7 @@ class QueryStringTest extends UnitTestCase {
     /** @var \Drupal\facets\Result\ResultInterface $r */
     foreach ($results as $r) {
       $this->assertInstanceOf('\Drupal\facets\Result\ResultInterface', $r);
-      $this->assertEquals('route:test?f[0]=test%3A' . $r->getRawValue(), $r->getUrl()->toUriString());
+      $this->assertEquals('route:test?f%5B0%5D=test%3A' . $r->getRawValue(), $r->getUrl()->toUriString());
     }
   }
 
@@ -173,10 +173,10 @@ class QueryStringTest extends UnitTestCase {
     foreach ($results as $k => $r) {
       $this->assertInstanceOf('\Drupal\facets\Result\ResultInterface', $r);
       if ($k === 2) {
-        $this->assertEquals('route:test?f[0]=king%3Akong', $r->getUrl()->toUriString());
+        $this->assertEquals('route:test?f%5B0%5D=king%3Akong', $r->getUrl()->toUriString());
       }
       else {
-        $this->assertEquals('route:test?f[0]=king%3Akong&f[1]=test%3A' . $r->getRawValue(), $r->getUrl()->toUriString());
+        $this->assertEquals('route:test?f%5B0%5D=king%3Akong&f%5B1%5D=test%3A' . $r->getRawValue(), $r->getUrl()->toUriString());
       }
     }
   }
@@ -197,9 +197,9 @@ class QueryStringTest extends UnitTestCase {
     $this->processor = new QueryString(['facet' => $facet], 'query_string', [], new Request());
     $results = $this->processor->buildUrls($facet, $this->originalResults);
 
-    $this->assertEquals('route:test?f[0]=test%3A' . $results[0]->getRawValue(), $results[0]->getUrl()->toUriString());
-    $this->assertEquals('route:test?f[0]=test%3A' . $results[3]->getRawValue(), $results[3]->getUrl()->toUriString());
-    $this->assertEquals('route:test?f[0]=test%3A' . $results[4]->getRawValue(), $results[4]->getUrl()->toUriString());
+    $this->assertEquals('route:test?f%5B0%5D=test%3A' . $results[0]->getRawValue(), $results[0]->getUrl()->toUriString());
+    $this->assertEquals('route:test?f%5B0%5D=test%3A' . $results[3]->getRawValue(), $results[3]->getUrl()->toUriString());
+    $this->assertEquals('route:test?f%5B0%5D=test%3A' . $results[4]->getRawValue(), $results[4]->getUrl()->toUriString());
     $this->assertEquals('route:test', $results[1]->getUrl()->toUriString());
     $this->assertEquals('route:test', $results[2]->getUrl()->toUriString());
   }
@@ -240,7 +240,7 @@ class QueryStringTest extends UnitTestCase {
     /** @var \Drupal\facets\Result\ResultInterface $r */
     foreach ($results as $r) {
       $this->assertInstanceOf('\Drupal\facets\Result\ResultInterface', $r);
-      $this->assertEquals('route:test?ab[0]=test%3A' . $r->getRawValue(), $r->getUrl()->toUriString());
+      $this->assertEquals('route:test?ab%5B0%5D=test%3A' . $r->getRawValue(), $r->getUrl()->toUriString());
     }
 
   }
@@ -258,7 +258,7 @@ class QueryStringTest extends UnitTestCase {
     $results = $this->processor->buildUrls($facet, $this->originalResults);
 
     foreach ($results as $result) {
-      $this->assertEquals('route:test?f[0]=test__' . $result->getRawValue(), $result->getUrl()->toUriString());
+      $this->assertEquals('route:test?f%5B0%5D=test__' . $result->getRawValue(), $result->getUrl()->toUriString());
     }
   }
 
-- 
2.7.0.windows.2

