protected function SearchApiExcludeEntityProcessorTest::setUp in Search API Exclude Entity 8
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Processor/ SearchApiExcludeEntityProcessorTest.php, line 78
Class
- SearchApiExcludeEntityProcessorTest
- Tests the "Search API Exclude Entity" processor.
Namespace
Drupal\Tests\search_api_exclude_entity\Unit\ProcessorCode
protected function setUp() {
parent::setUp();
$this
->setUpMockContainer();
$this->fieldsHelper = \Drupal::getContainer()
->get('search_api.fields_helper');
$this->index = $this
->createMock(IndexInterface::class);
$this->excludeEnabledValue = $this
->createMock(FieldItemListInterface::class);
$this->excludeEnabledValue
->method('getValue')
->willReturn([
0 => [
'value' => '1',
],
]);
$this->excludeDisabledValue = $this
->createMock(FieldItemListInterface::class);
$this->excludeDisabledValue
->method('getValue')
->willReturn([
0 => [
'value' => '0',
],
]);
// Node type 'article' has two exclude fields.
$entity_field_manager = $this
->createMock(EntityFieldManagerInterface::class);
$entity_field_manager
->method('getFieldMapByFieldType')
->with('search_api_exclude_entity')
->willReturn([
'node' => [
$this->fieldName1 => [
'type' => 'search_api_exclude_entity',
'bundles' => [
'article' => 'article',
],
],
$this->fieldName2 => [
'type' => 'search_api_exclude_entity',
'bundles' => [
'article' => 'article',
],
],
],
]);
$configuration['fields']['node'] = [
$this->fieldName1,
$this->fieldName2,
];
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
$this->processor = new SearchApiExcludeEntityProcessor($configuration, 'search_api_exclude_entity_processor', []);
$this->processor
->setEntityFieldManager($entity_field_manager);
}