ExtraFieldFormPluginTest.php in Extra Field 8.2
File
tests/src/Kernel/ExtraFieldFormPluginTest.php
View source
<?php
namespace Drupal\Tests\extra_field\Kernel;
use Drupal\Core\Form\FormState;
use Drupal\extra_field_test\Plugin\ExtraField\Form\SingleItemTest;
use Drupal\KernelTests\KernelTestBase;
class ExtraFieldFormPluginTest extends KernelTestBase {
public static $modules = [
'extra_field',
'extra_field_test',
];
public function testFormPlugin($pluginId, array $output) {
switch ($pluginId) {
case 'single_item_test':
$extraField = new SingleItemTest([], $pluginId, []);
break;
}
$form = [];
$formState = new FormState();
$pluginOutput = $extraField
->formElement($form, $formState);
$this
->assertEquals($output, $pluginOutput);
}
public function formPluginProvider() {
$info[] = [
'single_item_test',
[
'#markup' => 'Example markup provided by extra field form plugin.',
],
];
return $info;
}
}