function EntityConverterTest::testConvert
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvert()
- 10 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvert()
- 11.x core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvert()
Tests the convert() method.
@dataProvider providerTestConvert
@covers ::convert
File
-
core/
tests/ Drupal/ Tests/ Core/ ParamConverter/ EntityConverterTest.php, line 293
Class
- EntityConverterTest
- @coversDefaultClass \Drupal\Core\ParamConverter\EntityConverter @group ParamConverter @group Entity
Namespace
Drupal\Tests\Core\ParamConverterCode
public function testConvert($value, array $definition, array $defaults, $expected_result) {
$this->setUpMocks();
$this->entityRepository
->expects($this->any())
->method('getCanonical')
->willReturnCallback(function ($entity_type_id, $entity_id) {
return $entity_type_id === 'entity_test' && $entity_id === 'valid_id' ? (object) [
'id' => 'valid_id',
] : NULL;
});
$this->assertEquals($expected_result, $this->entityConverter
->convert($value, $definition, 'foo', $defaults));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.