X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate%2Ftests%2Fsrc%2FUnit%2Fdestination%2FPerComponentEntityFormDisplayTest.php;fp=web%2Fcore%2Fmodules%2Fmigrate%2Ftests%2Fsrc%2FUnit%2Fdestination%2FPerComponentEntityFormDisplayTest.php;h=0424cebf07ffd165a3811e798c3ae420bbddad07;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php b/web/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php new file mode 100644 index 000000000..0424cebf0 --- /dev/null +++ b/web/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php @@ -0,0 +1,67 @@ + 'entity_type_test', + 'bundle' => 'bundle_test', + 'form_mode' => 'form_mode_test', + 'field_name' => 'field_name_test', + 'options' => ['test setting'], + ]; + $row = new Row(); + foreach ($values as $key => $value) { + $row->setDestinationProperty($key, $value); + } + $entity = $this->getMockBuilder('Drupal\Core\Entity\Entity\EntityFormDisplay') + ->disableOriginalConstructor() + ->getMock(); + $entity->expects($this->once()) + ->method('setComponent') + ->with('field_name_test', ['test setting']) + ->will($this->returnSelf()); + $entity->expects($this->once()) + ->method('save') + ->with(); + $plugin = new TestPerComponentEntityFormDisplay($entity); + $this->assertSame($plugin->import($row), ['entity_type_test', 'bundle_test', 'form_mode_test', 'field_name_test']); + $this->assertSame($plugin->getTestValues(), ['entity_type_test', 'bundle_test', 'form_mode_test']); + } + +} + +class TestPerComponentEntityFormDisplay extends PerComponentEntityFormDisplay { + const MODE_NAME = 'form_mode'; + protected $testValues; + public function __construct($entity) { + $this->entity = $entity; + } + protected function getEntity($entity_type, $bundle, $form_mode) { + $this->testValues = func_get_args(); + return $this->entity; + } + public function getTestValues() { + return $this->testValues; + } + +}