MultipleBlockFormTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/Block/MultipleBlockFormTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Block;
use Drupal\block_test\PluginForm\EmptyBlockForm;
use Drupal\KernelTests\KernelTestBase;
class MultipleBlockFormTest extends KernelTestBase {
public static $modules = [
'system',
'block',
'block_test',
];
public function testMultipleForms() {
$configuration = [
'label' => 'A very cool block',
];
$block = \Drupal::service('plugin.manager.block')
->createInstance('test_multiple_forms_block', $configuration);
$form_object1 = \Drupal::service('plugin_form.factory')
->createInstance($block, 'configure');
$form_object2 = \Drupal::service('plugin_form.factory')
->createInstance($block, 'secondary');
$this
->assertSame($block, $form_object1);
$this
->assertInstanceOf(EmptyBlockForm::class, $form_object2);
$this
->assertAttributeEquals($block, 'plugin', $form_object2);
}
}