public function TaxonomyTermArgumentTest::testReturnsCommaSeparatedNamesIfValidTermIdsArePassed in Search API 8
Tests that a comma separated list of term labels is returned.
@covers ::title
File
- tests/
src/ Unit/ Views/ TaxonomyTermArgumentTest.php, line 105
Class
- TaxonomyTermArgumentTest
- Tests whether the SearchApiTerm argument plugin works correctly.
Namespace
Drupal\Tests\search_api\Unit\ViewsCode
public function testReturnsCommaSeparatedNamesIfValidTermIdsArePassed() {
$plugin = $this
->getSubjectUnderTest('argument');
$prophecy = $this
->prophesize(Term::class);
$prophecy
->label()
->willReturn('First');
$prophecy
->id()
->willReturn(1);
$term1 = $prophecy
->reveal();
$prophecy = $this
->prophesize(Term::class);
$prophecy
->label()
->willReturn('Second');
$prophecy
->id()
->willReturn(2);
$term2 = $prophecy
->reveal();
$this->termStorage
->expects($this
->at(0))
->method('load')
->with($term1
->id())
->willReturn($term1);
$this->termStorage
->expects($this
->at(1))
->method('load')
->with($term2
->id())
->willReturn($term2);
$this->entityRepository
->expects($this
->at(0))
->method('getTranslationFromContext')
->with($term1)
->will($this
->returnValue($term1));
$this->entityRepository
->expects($this
->at(1))
->method('getTranslationFromContext')
->with($term2)
->will($this
->returnValue($term2));
$plugin->value = [
$term1
->id(),
$term2
->id(),
];
$this
->assertEquals("{$term1->label()}, {$term2->label()}", $plugin
->title());
}