5 * Contains \Drupal\Tests\migrate\Unit\destination\PerComponentEntityFormDisplayTest.
8 namespace Drupal\Tests\migrate\Unit\destination;
10 use Drupal\migrate\Plugin\migrate\destination\PerComponentEntityFormDisplay;
11 use Drupal\migrate\Row;
12 use Drupal\Tests\migrate\Unit\MigrateTestCase;
15 * Tests the entity display destination plugin.
19 class PerComponentEntityFormDisplayTest extends MigrateTestCase {
22 * Tests the entity display import method.
24 public function testImport() {
26 'entity_type' => 'entity_type_test',
27 'bundle' => 'bundle_test',
28 'form_mode' => 'form_mode_test',
29 'field_name' => 'field_name_test',
30 'options' => ['test setting'],
33 foreach ($values as $key => $value) {
34 $row->setDestinationProperty($key, $value);
36 $entity = $this->getMockBuilder('Drupal\Core\Entity\Entity\EntityFormDisplay')
37 ->disableOriginalConstructor()
39 $entity->expects($this->once())
40 ->method('setComponent')
41 ->with('field_name_test', ['test setting'])
42 ->will($this->returnSelf());
43 $entity->expects($this->once())
46 $plugin = new TestPerComponentEntityFormDisplay($entity);
47 $this->assertSame($plugin->import($row), ['entity_type_test', 'bundle_test', 'form_mode_test', 'field_name_test']);
48 $this->assertSame($plugin->getTestValues(), ['entity_type_test', 'bundle_test', 'form_mode_test']);
53 class TestPerComponentEntityFormDisplay extends PerComponentEntityFormDisplay {
54 const MODE_NAME = 'form_mode';
55 protected $testValues;
56 public function __construct($entity) {
57 $this->entity = $entity;
59 protected function getEntity($entity_type, $bundle, $form_mode) {
60 $this->testValues = func_get_args();
63 public function getTestValues() {
64 return $this->testValues;