You are here

public function EntityUrlTest::testToUrlForInvalidLinkTemplate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlForInvalidLinkTemplate()

Tests the toUrl() method with an invalid link template.

@covers ::toUrl

@expectedException \Drupal\Core\Entity\Exception\UndefinedLinkTemplateException

@expectedExceptionMessage No link template 'canonical' found for the 'test_entity_type' entity type

@dataProvider providerTestToUrlForInvalidLinkTemplate

File

core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php, line 156
Contains \Drupal\Tests\Core\Entity\EntityUrlTest.

Class

EntityUrlTest
@coversDefaultClass \Drupal\Core\Entity\Entity @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testToUrlForInvalidLinkTemplate($entity_class, $link_template) {

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  $entity = $this
    ->getMockForAbstractClass($entity_class, array(
    array(
      'id' => 'test_entity_id',
    ),
    'test_entity_type',
  ));
  $uri = $this
    ->getTestToUrl($entity, $link_template);
  $this
    ->assertEmpty($uri);
}