function EntityUrlTest::testToUrlUriCallbackUndefined
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlUriCallbackUndefined()
- 10 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlUriCallbackUndefined()
- 11.x 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 311
Class
- EntityUrlTest
- Tests URL handling of the \Drupal\Core\Entity\Entity 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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.