You are here

public function EntityUrlTest::testToUrlUriCallbackUndefined in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlUriCallbackUndefined()
  2. 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\Entity

Code

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);
}