You are here

public function EntityUrlTest::testLink in Drupal 8

Tests the link() method.

@covers ::urlInfo

@group legacy @expectedDeprecation EntityInterface::link() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. Use EntityInterface::toLink()->toString() instead. Note, the default relationship for configuration entities changes from 'edit-form' to 'canonical'. See https://www.drupal.org/node/2614344

File

core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php, line 413

Class

EntityUrlTest
Tests URL handling of the \Drupal\Core\Entity\Entity class.

Namespace

Drupal\Tests\Core\Entity

Code

public function testLink() {
  $link = $this
    ->createMock(Link::class);
  $link
    ->expects($this
    ->once())
    ->method('toString')
    ->willReturn('<a href="/foo">The link</a>');
  $entity = $this
    ->getEntity(EntityBase::class, [], [
    'toLink',
  ]);
  $entity
    ->expects($this
    ->once())
    ->method('toLink')
    ->with(NULL, 'canonical')
    ->willReturn($link);
  $this
    ->assertEquals('<a href="/foo">The link</a>', $entity
    ->link());
}