function EntityUrlTest::testToUrlUriCallbackUndefined

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

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) : void {
  $entity = $this->getEntity(UrlTestEntity::class, [
    'id' => static::ENTITY_ID,
  ]);
  $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 '" . static::ENTITY_TYPE_ID . "' entity type");
  $entity->toUrl($link_template);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.