$entity =
$this->
getMockBuilder('Drupal\Core\Entity\Entity\EntityViewDisplay'
) ->
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 TestPerComponentEntityDisplay($entity);
$this->
assertSame(['entity_type_test', 'bundle_test', 'view_mode_test', 'field_name_test'
],
$plugin->
import($row));
$this->
assertSame(['entity_type_test', 'bundle_test', 'view_mode_test'
],
$plugin->
getTestValues());
}}class TestPerComponentEntityDisplay extends ComponentEntityDisplayBase
{ const MODE_NAME = 'view_mode';
protected $testValues;
protected $entity;