public function testConvert($value, array
$definition, array
$defaults,
$expected_result) { $storage =
$this->
prophesize(EntityStorageInterface::
class);
$storage->
loadRevision('valid_id'
)->
willReturn((object) ['revision_id' => 'valid_id'
]);
$storage->
loadRevision('invalid_id'
)->
willReturn(NULL
);
$entity_type_manager =
$this->
prophesize(EntityTypeManagerInterface::
class);
$entity_type_manager->
getStorage('entity_test'
)->
willReturn($storage->
reveal());
$entity_repository =
$this->
prophesize(EntityRepositoryInterface::
class);
$converter =
new EntityRevisionParamConverter($entity_type_manager->
reveal(),
$entity_repository->
reveal());
$result =
$converter->
convert($value,
$definition, 'test_revision',
$defaults);
$this->
assertEquals($expected_result,
$result);
} /**
* Provides test data for testConvert.
*/
public function providerTestConvert() { $data =
[];
// Existing entity type.
$data[] =
['valid_id',
['type' => 'entity_revision:entity_test'
],
['test_revision' => 'valid_id'
],
(object) ['revision_id' => 'valid_id'
]];
// Invalid ID.