protected function FieldsProcessorPluginBaseTest::assertFieldsProcessed in Search API 8
Asserts that the given fields have been correctly processed.
Parameters
\Drupal\search_api\Item\ItemInterface[] $items: An array containing one item.
string[] $processed_fields: The fields which should be processed.
string $prefix: (optional) The prefix that processed fields receive.
4 calls to FieldsProcessorPluginBaseTest::assertFieldsProcessed()
- FieldsProcessorPluginBaseTest::testProcessFieldValueOverride in tests/
src/ Unit/ Processor/ FieldsProcessorPluginBaseTest.php - Tests whether overriding of processFieldValue() works correctly.
- FieldsProcessorPluginBaseTest::testTestField in tests/
src/ Unit/ Processor/ FieldsProcessorPluginBaseTest.php - Tests whether selecting fields works correctly.
- FieldsProcessorPluginBaseTest::testTestTypeDefault in tests/
src/ Unit/ Processor/ FieldsProcessorPluginBaseTest.php - Tests whether the default implementation of testType() works correctly.
- FieldsProcessorPluginBaseTest::testTestTypeOverride in tests/
src/ Unit/ Processor/ FieldsProcessorPluginBaseTest.php - Tests whether overriding of testType() works correctly.
File
- tests/
src/ Unit/ Processor/ FieldsProcessorPluginBaseTest.php, line 680
Class
- FieldsProcessorPluginBaseTest
- Tests the base class for fields-based processors.
Namespace
Drupal\Tests\search_api\Unit\ProcessorCode
protected function assertFieldsProcessed(array $items, array $processed_fields, $prefix = "*") {
$processed_fields = array_fill_keys($processed_fields, TRUE);
foreach ($items as $item) {
foreach ($item
->getFields() as $field_id => $field) {
if (!empty($processed_fields[$field_id])) {
$expected = [
"{$prefix}{$field_id} value 1",
"{$prefix}{$field_id} value 2",
];
}
else {
$expected = [
"{$field_id} value 1",
"{$field_id} value 2",
];
}
$this
->assertEquals($expected, $field
->getValues(), "Field {$field_id} is correct.");
}
}
}