diff --git a/core_search_facets/src/Tests/IntegrationTest.php b/core_search_facets/src/Tests/IntegrationTest.php index f600e38..9890971 100644 --- a/core_search_facets/src/Tests/IntegrationTest.php +++ b/core_search_facets/src/Tests/IntegrationTest.php @@ -2,6 +2,7 @@ namespace Drupal\core_search_facets\Tests; +use Drupal\Component\Render\FormattableMarkup; use Drupal\facets\Tests\ExampleContentTrait; use Drupal\node\Entity\Node; @@ -67,12 +68,13 @@ class IntegrationTest extends WebTestBase { // Verify that the number of results per item. $this->drupalGet('search/node', ['query' => ['keys' => 'test']]); - $this->assertLink('page (19)'); - $this->assertLink('article (10)'); + $this->assertRaw('page (19)'); + $this->assertRaw('article (10)'); + $this->assertNoRaw('(-) page (19)'); // Verify that the label is correct for a clicked link. $this->clickLink('page (19)'); - $this->assertLink('(-) page (19)'); + $this->assertRaw('(-) page (19)'); // Do not show the block on empty behaviors. // Truncate the search_index table because, for the moment, we don't have @@ -113,27 +115,27 @@ class IntegrationTest extends WebTestBase { // Assert date facets. $this->drupalGet('search/node', ['query' => ['keys' => 'test']]); - $this->assertLink('February 2016 (9)'); - $this->assertLink('March 2016 (10)'); - $this->assertLink('April 2016 (10)'); + $this->assertRaw('February 2016 (9)'); + $this->assertRaw('March 2016 (10)'); + $this->assertRaw('April 2016 (10)'); $this->assertResponse(200); $this->clickLink('March 2016 (10)'); $this->assertResponse(200); - $this->assertLink('March 8, 2016 (1)'); - $this->assertLink('March 9, 2016 (2)'); + $this->assertRaw('March 8, 2016 (1)'); + $this->assertRaw('March 9, 2016 (2)'); $this->clickLink('March 9, 2016 (2)'); $this->assertResponse(200); - $this->assertLink('10 AM (1)'); - $this->assertLink('12 PM (1)'); + $this->assertRaw('10 AM (1)'); + $this->assertRaw('12 PM (1)'); $this->drupalGet('search/node', ['query' => ['keys' => 'test']]); - $this->assertLink('April 2016 (10)'); + $this->assertRaw('April 2016 (10)'); $this->clickLink('April 2016 (10)'); $this->assertResponse(200); - $this->assertLink('April 1, 2016 (1)'); - $this->assertLink('April 2, 2016 (1)'); + $this->assertRaw('April 1, 2016 (1)'); + $this->assertRaw('April 2, 2016 (1)'); } /** @@ -159,10 +161,10 @@ class IntegrationTest extends WebTestBase { search_update_totals(); $this->drupalGet('search/node', ['query' => ['keys' => 'test']]); - $this->assertLink('December 2016 (1)'); + $this->assertRaw('December 2016 (1)'); $this->clickLink('December 2016 (1)'); $this->assertResponse(200); - $this->assertLink('December 3, 2016 (1)'); + $this->assertRaw('December 3, 2016 (1)'); $this->clickLink('December 3, 2016 (1)'); $this->assertResponse(200); diff --git a/src/Plugin/facets/widget/LinksWidget.php b/src/Plugin/facets/widget/LinksWidget.php index 774ba04..31db9ee 100644 --- a/src/Plugin/facets/widget/LinksWidget.php +++ b/src/Plugin/facets/widget/LinksWidget.php @@ -2,6 +2,7 @@ namespace Drupal\facets\Plugin\facets\widget; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -189,12 +190,12 @@ class LinksWidget implements WidgetInterface { * The text to display. */ protected function extractText(ResultInterface $result) { - $text = $result->getDisplayValue(); + $text = new FormattableMarkup('@text', ['@text' => $result->getDisplayValue(), '@count' => $result->getCount()]); if ($this->showNumbers && $result->getCount()) { - $text .= ' (' . $result->getCount() . ')'; + $text->string .= ' (@count)'; } if ($result->isActive()) { - $text = '(-) ' . $text; + $text->string = '(-) ' . $text->string; } return $text; } diff --git a/src/Tests/UrlIntegrationTest.php b/src/Tests/UrlIntegrationTest.php index cfe1a26..4d3107f 100644 --- a/src/Tests/UrlIntegrationTest.php +++ b/src/Tests/UrlIntegrationTest.php @@ -184,7 +184,7 @@ class UrlIntegrationTest extends WebTestBase { // Make sure 'test:colon' is active. $url = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['f[0]' => 'water_bear:test:colon']]); $this->assertUrl($url); - $this->assertLink('(-) test:colon'); + $this->assertRaw('(-) test:colon'); $this->assertLink('orange'); $this->assertLink('banana'); } @@ -204,7 +204,7 @@ class UrlIntegrationTest extends WebTestBase { $this->clickLink('item'); $this->assertResponse(200); - $this->assertLink('(-) item'); + $this->assertRaw('(-) item'); $this->assertLink('article'); $this->assertUrl($url); }