class CompiledRouteLegacyTest in Drupal 9
@coversDefaultClass \Drupal\Core\Routing\CompiledRoute @group Routing @group legacy
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- class \Drupal\Tests\Core\Routing\CompiledRouteLegacyTest
Expanded class hierarchy of CompiledRouteLegacyTest
File
- core/
tests/ Drupal/ Tests/ Core/ Routing/ CompiledRouteLegacyTest.php, line 13
Namespace
Drupal\Tests\Core\RoutingView source
class CompiledRouteLegacyTest extends UnitTestCase {
/**
* A compiled route object for testing purposes.
*
* @var \Drupal\Core\Routing\CompiledRoute
*/
private $compiled_route;
/**
* @var \Symfony\Component\Routing\Route
* A mocked Route object.
*/
private $mocked_route;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// We can pass in dummy values because we're not doing anything in this
// test except for verifying the deprecation notices are being thrown.
$this->compiled_route = new CompiledRoute(0, "", 0, "", "", [], []);
$this->mocked_route = $this
->createMock('Symfony\\Component\\Routing\\Route');
$this->mocked_route
->expects($this
->any())
->method('getDefaults')
->willReturn([]);
$this->mocked_route
->expects($this
->any())
->method('getRequirements')
->willReturn([]);
$this->mocked_route
->expects($this
->any())
->method('getOptions')
->willReturn([]);
}
/**
* Tests for deprecated message and no PHP error.
*
* @covers ::getOptions
*/
public function testOptionsDeprecated() {
$this
->expectDeprecation('Drupal\\Core\\Routing\\CompiledRoute::getOptions() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
if (PHP_VERSION_ID >= 80000) {
$this
->expectWarning();
$this
->expectWarningMessage('Undefined property: Drupal\\Core\\Routing\\CompiledRoute::$route');
}
else {
$this
->expectNotice();
$this
->expectNoticeMessage('Undefined property: Drupal\\Core\\Routing\\CompiledRoute::$route');
}
$this->compiled_route
->getOptions();
}
/**
* Tests to make sure we get an array when dynamically setting.
*
* @covers ::getOptions
*/
public function testOptionsDynamicallySet() {
$this
->expectDeprecation('Drupal\\Core\\Routing\\CompiledRoute::getOptions() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
$this->compiled_route->route = $this->mocked_route;
$this->compiled_route
->getOptions();
}
/**
* Tests for deprecated message and no PHP error.
*
* @covers ::getDefaults
*/
public function testDefaultsDeprecated() {
$this
->expectDeprecation('Drupal\\Core\\Routing\\CompiledRoute::getDefaults() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
if (PHP_VERSION_ID >= 80000) {
$this
->expectWarning();
$this
->expectWarningMessage('Undefined property: Drupal\\Core\\Routing\\CompiledRoute::$route');
}
else {
$this
->expectNotice();
$this
->expectNoticeMessage('Undefined property: Drupal\\Core\\Routing\\CompiledRoute::$route');
}
$this->compiled_route
->getDefaults();
}
/**
* Tests to make sure we get an array when dynamically setting.
*
* @covers ::getDefaults
*/
public function testDefaultsDynamicallySet() {
$this
->expectDeprecation('Drupal\\Core\\Routing\\CompiledRoute::getDefaults() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
$this->compiled_route->route = $this->mocked_route;
$this->compiled_route
->getDefaults();
}
/**
* @covers ::getRequirements
*/
public function testRequirementsDeprecated() {
$this
->expectDeprecation('Drupal\\Core\\Routing\\CompiledRoute::getRequirements() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
if (PHP_VERSION_ID >= 80000) {
$this
->expectWarning();
$this
->expectWarningMessage('Undefined property: Drupal\\Core\\Routing\\CompiledRoute::$route');
}
else {
$this
->expectNotice();
$this
->expectNoticeMessage('Undefined property: Drupal\\Core\\Routing\\CompiledRoute::$route');
}
$this->compiled_route
->getRequirements();
}
/**
* Tests to make sure we get an array when dynamically setting.
*
* @covers ::getRequirements
*/
public function testRequirementsDynamicallySet() {
$this
->expectDeprecation('Drupal\\Core\\Routing\\CompiledRoute::getRequirements() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3159706');
$this->compiled_route->route = $this->mocked_route;
$this->compiled_route
->getRequirements();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CompiledRouteLegacyTest:: |
private | property | A compiled route object for testing purposes. | |
CompiledRouteLegacyTest:: |
private | property | A mocked Route object. | |
CompiledRouteLegacyTest:: |
protected | function |
Overrides UnitTestCase:: |
|
CompiledRouteLegacyTest:: |
public | function | Tests for deprecated message and no PHP error. | |
CompiledRouteLegacyTest:: |
public | function | Tests to make sure we get an array when dynamically setting. | |
CompiledRouteLegacyTest:: |
public | function | Tests for deprecated message and no PHP error. | |
CompiledRouteLegacyTest:: |
public | function | Tests to make sure we get an array when dynamically setting. | |
CompiledRouteLegacyTest:: |
public | function | @covers ::getRequirements | |
CompiledRouteLegacyTest:: |
public | function | Tests to make sure we get an array when dynamically setting. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
public static | function |