public function EntityUrlTest::testToUrlLinkTemplateAddForm in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::testToUrlLinkTemplateAddForm()
Tests the toUrl() method with the 'revision' link template.
@dataProvider providerTestToUrlLinkTemplateAddForm
@covers ::toUrl @covers ::linkTemplates @covers ::urlRouteParameters
Parameters
bool $has_bundle_key: Whether or not the mock entity type should have a bundle key.
string|null $bundle_entity_type: The ID of the bundle entity type of the mock entity type, or NULL if the mock entity type should not have a bundle entity type.
string $bundle_key: The bundle key of the mock entity type or FALSE if the entity type should not have a bundle key.
array $expected_route_parameters: The expected route parameters of the generated URL.
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php, line 265
Class
- EntityUrlTest
- Tests URL handling of the \Drupal\Core\Entity\Entity class.
Namespace
Drupal\Tests\Core\EntityCode
public function testToUrlLinkTemplateAddForm($has_bundle_key, $bundle_entity_type, $bundle_key, $expected_route_parameters) {
$values = [
'id' => $this->entityId,
'langcode' => $this->langcode,
];
$entity = $this
->getEntity(EntityBase::class, $values);
$this->entityType
->hasKey('bundle')
->willReturn($has_bundle_key);
$this->entityType
->getBundleEntityType()
->willReturn($bundle_entity_type);
$this->entityType
->getKey('bundle')
->willReturn($bundle_key);
$link_template = 'add-form';
$this
->registerLinkTemplate($link_template);
/** @var \Drupal\Core\Url $url */
$url = $entity
->toUrl($link_template);
$this
->assertUrl('entity.test_entity.add_form', $expected_route_parameters, $entity, FALSE, $url);
}