public function UrlTest::testInvalidEntityUriParameter in Drupal 8
Tests the fromUri() method with an invalid entity: URI.
@covers ::fromUri
File
- core/
tests/ Drupal/ Tests/ Core/ UrlTest.php, line 632 - Contains \Drupal\Tests\Core\UrlTest.
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();
}