public function ExtraFieldDisplayPluginTest::testDisplayFormattedPlugin in Extra Field 8.2
Tests formatted display plugins.
@covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::view @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::getLabel @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::getLabelDisplay @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::getFieldName @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::getFieldType @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::isEmpty @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::getLangcode @covers \Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase::isTranslatable
@dataProvider displayPluginFormattedProvider
Parameters
string $pluginId: Plugin ID of the plugin under test.
array $output: Plugin output as returned by ::view.
array $methods: Return value of various plugin methods.
File
- tests/
src/ Kernel/ ExtraFieldDisplayPluginTest.php, line 141
Class
- ExtraFieldDisplayPluginTest
- Kernel test for Extra Field display plugins.
Namespace
Drupal\Tests\extra_field\KernelCode
public function testDisplayFormattedPlugin($pluginId, array $output, array $methods) {
switch ($pluginId) {
case 'single_text_test':
$extraField = new SingleTextFieldTest([], $pluginId, []);
break;
case 'empty_formatted_test':
$extraField = new EmptyFormattedFieldTest([], $pluginId, []);
break;
case 'multiple_text_test':
$extraField = new MultipleItemsFieldTest([], $pluginId, []);
break;
}
$pluginOutput = $extraField
->view($this->node);
unset($pluginOutput['#object']);
unset($pluginOutput['#items']);
$pluginMethod = [
'getLabel' => $extraField
->getLabel(),
'getLabelDisplay' => $extraField
->getLabelDisplay(),
'getFieldName' => $extraField
->getFieldName(),
'getFieldType' => $extraField
->getFieldType(),
'isEmpty' => $extraField
->isEmpty(),
'getLangcode' => $extraField
->getLangcode(),
'isTranslatable' => $extraField
->isTranslatable(),
];
$this
->assertEquals($output, $pluginOutput);
$this
->assertEquals($methods, $pluginMethod);
}