function UrlTest::testInvalidEntityUriParameter
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testInvalidEntityUriParameter()
- 10 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testInvalidEntityUriParameter()
- 11.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testInvalidEntityUriParameter()
Tests the fromUri() method with an invalid entity: URI.
@covers ::fromUri
File
-
core/
tests/ Drupal/ Tests/ Core/ UrlTest.php, line 630
Class
- UrlTest
- @coversDefaultClass \Drupal\Core\Url @group UrlTest
Namespace
Drupal\Tests\CoreCode
public function testInvalidEntityUriParameter() {
// Make the mocked URL generator behave like the actual one.
$this->urlGenerator
->expects($this->once())
->method('generateFromRoute')
->with('entity.test_entity.canonical', [
'test_entity' => '1/blah',
])
->willThrowException(new InvalidParameterException('Parameter "test_entity" for route "/test_entity/{test_entity}" must match "[^/]++" ("1/blah" given) to generate a corresponding URL..'));
$this->expectException(InvalidParameterException::class);
Url::fromUri('entity:test_entity/1/blah')->toString();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.