You are here

protected function EntityUrlTest::assertUrl in Drupal 8

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

Asserts that a given URL object matches the expectations.

Parameters

string $expected_route_name: The expected route name of the generated URL.

array $expected_route_parameters: The expected route parameters of the generated URL.

\Drupal\Core\Entity\Entity|\PHPUnit\Framework\MockObject\MockObject $entity: The entity that is expected to be set as a URL option.

bool $has_language: Whether or not the URL is expected to have a language option.

\Drupal\Core\Url $url: The URL option to make the assertions on.

5 calls to EntityUrlTest::assertUrl()
EntityUrlTest::testToUrlLinkTemplateAddForm in core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
Tests the toUrl() method with the 'revision' link template.
EntityUrlTest::testToUrlLinkTemplateNoId in core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
Tests the toUrl() method with link templates without an entity ID.
EntityUrlTest::testToUrlLinkTemplateRevision in core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
Tests the toUrl() method with the 'revision' link template.
EntityUrlTest::testToUrlLinkTemplates in core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
Tests the toUrl() method with simple link templates.
EntityUrlTest::testToUrlUriCallback in core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
Tests the toUrl() method with a URI callback.

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

protected function assertUrl($expected_route_name, array $expected_route_parameters, $entity, $has_language, Url $url) {
  $this
    ->assertEquals($expected_route_name, $url
    ->getRouteName());
  $this
    ->assertEquals($expected_route_parameters, $url
    ->getRouteParameters());
  $this
    ->assertEquals($this->entityTypeId, $url
    ->getOption('entity_type'));
  $this
    ->assertEquals($entity, $url
    ->getOption('entity'));
  if ($has_language) {
    $this
      ->assertEquals($this->langcode, $url
      ->getOption('language')
      ->getId());
  }
  else {
    $this
      ->assertNull($url
      ->getOption('language'));
  }
}