public function EntityUrlTest::testToUrlUriCallbackUndefined in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlUriCallbackUndefined()
- 9 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlUriCallbackUndefined()
Tests the toUrl() method with neither link templates nor a URI callback.
@dataProvider providerTestToUrlUriCallbackUndefined
@covers ::toUrl @covers ::linkTemplates
Parameters
array $bundle_info: An array of bundle info to register.
string $uri_callback: The entity type URI callback to register.
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php, line 312
Class
- EntityUrlTest
- Tests URL handling of the \Drupal\Core\Entity\EntityBase class.
Namespace
Drupal\Tests\Core\EntityCode
public function testToUrlUriCallbackUndefined(array $bundle_info, $uri_callback) {
$entity = $this
->getEntity(EntityBase::class, [
'id' => $this->entityId,
]);
$this
->registerBundleInfo($bundle_info);
$this->entityType
->getUriCallback()
->willReturn($uri_callback);
$link_template = 'canonical';
$this
->expectException(UndefinedLinkTemplateException::class);
$this
->expectExceptionMessage("No link template '{$link_template}' found for the '{$this->entityTypeId}' entity type");
$entity
->toUrl($link_template);
}