protected function EntityUrlTest::getTestToUrl in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::getTestToUrl()
Creates a \Drupal\Core\Url object based on the entity and link template.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The test entity.
string $link_template: The link template.
string $langcode: The langcode.
Return value
\Drupal\Core\Url The URL for this entity's link template.
3 calls to EntityUrlTest::getTestToUrl()
- EntityUrlTest::testToUrl in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php - Tests the toUrl() method.
- EntityUrlTest::testToUrlForInvalidLinkTemplate in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php - Tests the toUrl() method with an invalid link template.
- EntityUrlTest::testToUrlWithSpecificLanguageInOptions in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php - Tests for Entity::toUrl() exercising different language options.
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php, line 238 - Contains \Drupal\Tests\Core\Entity\EntityUrlTest.
Class
- EntityUrlTest
- @coversDefaultClass \Drupal\Core\Entity\Entity @group Entity
Namespace
Drupal\Tests\Core\EntityCode
protected function getTestToUrl(EntityInterface $entity, $link_template, array $options = [], $langcode = NULL) {
$entity_type = $this
->getMock('Drupal\\Core\\Entity\\EntityTypeInterface');
$entity_type
->expects($this
->any())
->method('getLinkTemplates')
->will($this
->returnValue(array(
'edit-form' => 'test_entity_type.edit',
)));
if ($langcode) {
$entity->langcode = $langcode;
}
$this->entityManager
->expects($this
->any())
->method('getDefinition')
->with('test_entity_type')
->will($this
->returnValue($entity_type));
// If no link template is given, call without a value to test the default.
if ($link_template) {
$uri = $entity
->toUrl($link_template, $options);
}
else {
if ($entity instanceof ConfigEntityInterface) {
$uri = $entity
->toUrl('edit-form', $options);
}
else {
$uri = $entity
->toUrl('canonical', $options);
}
}
return $uri;
}