You are here

public function LinksWidgetTest::testResetLink in Facets 8

Tests the rest link.

File

tests/src/Unit/Plugin/widget/LinksWidgetTest.php, line 196

Class

LinksWidgetTest
Unit test for widget.

Namespace

Drupal\Tests\facets\Unit\Plugin\widget

Code

public function testResetLink() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setResults($this->originalResults);
  $output = $this->widget
    ->build($facet);
  $this
    ->assertSame('array', gettype($output));
  $this
    ->assertCount(4, $output['#items']);
  $request = new Request();
  $request->query
    ->set('f', []);
  $request_stack = new RequestStack();
  $request_stack
    ->push($request);
  $this
    ->createContainer();
  $container = \Drupal::getContainer();
  $container
    ->set('request_stack', $request_stack);
  \Drupal::setContainer($container);

  // Enable the show reset link.
  $this->widget
    ->setConfiguration([
    'show_reset_link' => TRUE,
  ]);
  $output = $this->widget
    ->build($facet);

  // Check that we now have more results.
  $this
    ->assertSame('array', gettype($output));
  $this
    ->assertCount(5, $output['#items']);
}