protected function EntityUrlTest::getTestUrlInfo 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::getTestUrlInfo()
Creates a \Drupal\Core\Url object based on the entity and link template.
Method urlInfo() is deprecated and replaced with toUrl(). See also getTestToUrl().
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.
1 call to EntityUrlTest::getTestUrlInfo()
- EntityUrlTest::testUrlInfo in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php - Tests the urlInfo() method.
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php, line 191 - Contains \Drupal\Tests\Core\Entity\EntityUrlTest.
Class
- EntityUrlTest
- @coversDefaultClass \Drupal\Core\Entity\Entity @group Entity
Namespace
Drupal\Tests\Core\EntityCode
protected function getTestUrlInfo(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
->urlInfo($link_template, $options);
}
else {
if ($entity instanceof ConfigEntityInterface) {
$uri = $entity
->urlInfo('edit-form', $options);
}
else {
$uri = $entity
->urlInfo('canonical', $options);
}
}
return $uri;
}