class PerComponentEntityFormDisplayTest

Same name and namespace in other branches
  1. 11.x core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php \Drupal\Tests\migrate\Unit\destination\PerComponentEntityFormDisplayTest

Tests the entity display destination plugin.

@group migrate

Hierarchy

Expanded class hierarchy of PerComponentEntityFormDisplayTest

File

core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php, line 19

Namespace

Drupal\Tests\migrate\Unit\destination
View source
class PerComponentEntityFormDisplayTest extends MigrateTestCase {
  
  /**
   * Tests the entity display import method.
   */
  public function testImport() {
    $values = [
      'entity_type' => '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([
      'entity_type_test',
      'bundle_test',
      'form_mode_test',
      'field_name_test',
    ], $plugin->import($row));
    $this->assertSame([
      'entity_type_test',
      'bundle_test',
      'form_mode_test',
    ], $plugin->getTestValues());
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.