public function TaxonomyTermArgumentTest::testReturnsTermNameIfValidTermIdIsPassed in Search API 8
Tests that the term label is returned if an existing id is provided.
@covers ::title
File
- tests/
src/ Unit/ Views/ TaxonomyTermArgumentTest.php, line 80
Class
- TaxonomyTermArgumentTest
- Tests whether the SearchApiTerm argument plugin works correctly.
Namespace
Drupal\Tests\search_api\Unit\ViewsCode
public function testReturnsTermNameIfValidTermIdIsPassed() {
$plugin = $this
->getSubjectUnderTest('argument');
$prophecy = $this
->prophesize(Term::class);
$prophecy
->label()
->willReturn('First');
$prophecy
->id()
->willReturn(1);
$term = $prophecy
->reveal();
$this->termStorage
->expects($this
->any())
->method('load')
->with($term
->id())
->willReturn($term);
$this->entityRepository
->expects($this
->any())
->method('getTranslationFromContext')
->with($term)
->will($this
->returnValue($term));
$plugin->value = [
$term
->id(),
];
$this
->assertEquals($term
->label(), $plugin
->title());
}