You are here

public function EntityUrlTest::testToUrlWithSpecificLanguageInOptions in Zircon Profile 8.0

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

Tests for Entity::toUrl() exercising different language options.

@covers ::toUrl

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

public function testToUrlWithSpecificLanguageInOptions() {

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

  // Ensure that a specified language overrides the current translation
  // language.
  $uri = $this
    ->getTestToUrl($entity, 'edit-form', [], 'en');
  $this
    ->assertEquals('en', $uri
    ->getOption('language')
    ->getId());
  $uri = $this
    ->getTestToUrl($entity, 'edit-form', [
    'language' => new Language([
      'id' => 'fr',
    ]),
  ], 'en');
  $this
    ->assertEquals('fr', $uri
    ->getOption('language')
    ->getId());
}