You are here

public function UrlTest::testInvalidEntityUriParameter in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testInvalidEntityUriParameter()

Tests the fromUri() method with an invalid entity: URI.

@covers ::fromUri @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException

File

core/tests/Drupal/Tests/Core/UrlTest.php, line 598
Contains \Drupal\Tests\Core\UrlTest.

Class

UrlTest
@coversDefaultClass \Drupal\Core\Url @group UrlTest

Namespace

Drupal\Tests\Core

Code

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..'));
  Url::fromUri('entity:test_entity/1/blah')
    ->toString();
}