You are here

public function TaxonomyTermArgumentTest::testReturnsArgumentIfInvalidTermIdIsPassed in Search API 8

Tests that the set argument is returned when non existing ids are provided.

@covers ::title

File

tests/src/Unit/Views/TaxonomyTermArgumentTest.php, line 57

Class

TaxonomyTermArgumentTest
Tests whether the SearchApiTerm argument plugin works correctly.

Namespace

Drupal\Tests\search_api\Unit\Views

Code

public function testReturnsArgumentIfInvalidTermIdIsPassed() {
  $plugin = $this
    ->getSubjectUnderTest('argument');
  $prophecy = $this
    ->prophesize(Term::class);
  $prophecy
    ->label()
    ->willReturn('First');
  $prophecy
    ->id()
    ->willReturn(1);
  $term = $prophecy
    ->reveal();
  $non_existing_term_id = $term
    ->id() + 1;
  $this->termStorage
    ->expects($this
    ->any())
    ->method('load')
    ->with($non_existing_term_id)
    ->willReturn(NULL);
  $plugin->value = [
    $non_existing_term_id,
  ];
  $this
    ->assertEquals('argument', $plugin
    ->title());
}