Commit 61d9a9ce authored by idebr's avatar idebr Committed by borisson_

Issue #2878914 by idebr: Update test assertions to new W3C valid query-strings

parent 5d62cfb6
......@@ -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,
],
];
......
......@@ -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());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment