function EntityUrlTest::assertUrl
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::assertUrl()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::assertUrl()
- 10 core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php \Drupal\Tests\Core\Entity\EntityUrlTest::assertUrl()
Asserts that a given URL object matches the expectations.
@internal
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\Tests\Core\Entity\StubEntityBase|\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.
6 calls to EntityUrlTest::assertUrl()
- EntityUrlTest::testToUrlDefaultFallback in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php - Tests the toUrl() method without specifying the $rel parameter.
- 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.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUrlTest.php, line 514
Class
- EntityUrlTest
- Tests URL handling of the \Drupal\Core\Entity\EntityBase class.
Namespace
Drupal\Tests\Core\EntityCode
protected function assertUrl(string $expected_route_name, array $expected_route_parameters, $entity, bool $has_language, Url $url) : void {
$this->assertEquals($expected_route_name, $url->getRouteName());
$this->assertEquals($expected_route_parameters, $url->getRouteParameters());
$this->assertEquals(static::ENTITY_TYPE_ID, $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'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.