PathChangedHelperTest.php

Same filename in this branch
  1. main core/tests/Drupal/KernelTests/Core/Routing/PathChangedHelperTest.php
Same filename and directory in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Routing/PathChangedHelperTest.php
  2. 11.x core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php
  3. 10 core/tests/Drupal/KernelTests/Core/Routing/PathChangedHelperTest.php
  4. 10 core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php

Namespace

Drupal\Tests\Core\Routing

File

core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\Core\Routing;

use Drupal\Core\Routing\PathChangedHelper;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Symfony\Component\HttpFoundation\Request;

/**
 * Tests Drupal\Core\Routing\PathChangedHelper.
 */
class PathChangedHelperTest extends UnitTestCase {
  
  /**
   * Tests that the constructor validates its arguments.
   *
   * @legacy-covers ::__construct
   */
  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());
  }

}

Classes

Title Deprecated Summary
PathChangedHelperTest Tests Drupal\Core\Routing\PathChangedHelper.

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