function PathChangedHelperTest::testPathChangedHelperException

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php \Drupal\Tests\Core\Routing\PathChangedHelperTest::testPathChangedHelperException()

Tests that the constructor validates its arguments.

@covers ::__construct

File

core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php, line 23

Class

PathChangedHelperTest
@coversDefaultClass \Drupal\Core\Routing\PathChangedHelper @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testPathChangedHelperException() : void {
    $route_match = $this->prophesize(RouteMatchInterface::class);
    $route_match->getRouteName()
        ->willReturn('path.changed.not-bc');
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('Drupal\\Core\\Routing\\PathChangedHelper expects a route name that ends with ".bc".');
    new PathChangedHelper($route_match->reveal(), new Request());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.