public function UserRoleTest::testPrepareValueWithNewRole in Feeds 8.3
Tests referencing a newly created role.
@covers ::prepareValue @covers ::findEntity @covers ::createRole
File
- tests/
src/ Unit/ Feeds/ Target/ UserRoleTest.php, line 175
Class
- UserRoleTest
- @coversDefaultClass \Drupal\feeds\Feeds\Target\UserRole @group feeds
Namespace
Drupal\Tests\feeds\Unit\Feeds\TargetCode
public function testPrepareValueWithNewRole() {
$this->entityFinder
->findEntities($this
->getReferencableEntityTypeId(), 'label', 'Bar')
->willReturn([])
->shouldBeCalled();
$role = $this
->prophesize(RoleInterface::class);
$role
->save()
->willReturn(TRUE);
$role
->id()
->willReturn('bar');
$this->entityStorage
->create([
'id' => 'bar',
'label' => 'Bar',
])
->willReturn($role
->reveal())
->shouldBeCalled();
$target_plugin = $this
->createTargetPluginInstance([
'autocreate' => TRUE,
]);
$method = $this
->getProtectedClosure($target_plugin, 'prepareValue');
$values = [
'target_id' => 'Bar',
];
$method(0, $values);
$this
->assertSame($values, [
'target_id' => 'bar',
]);
}