function EntityRevisionParamConverterTest::testConvert
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/ParamConverter/EntityRevisionParamConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityRevisionParamConverterTest::testConvert()
- 8.9.x core/tests/Drupal/Tests/Core/ParamConverter/EntityRevisionParamConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityRevisionParamConverterTest::testConvert()
- 11.x core/tests/Drupal/Tests/Core/ParamConverter/EntityRevisionParamConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityRevisionParamConverterTest::testConvert()
Tests the convert() method.
@dataProvider providerTestConvert
@covers ::convert
File
-
core/
tests/ Drupal/ Tests/ Core/ ParamConverter/ EntityRevisionParamConverterTest.php, line 74
Class
- EntityRevisionParamConverterTest
- @coversDefaultClass \Drupal\Core\ParamConverter\EntityRevisionParamConverter @group entity
Namespace
Drupal\Tests\Core\ParamConverterCode
public function testConvert($value, array $definition, array $defaults, $expected_result) : void {
$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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.