CompiledRouteLegacyTest.php in Drupal 9
File
core/tests/Drupal/Tests/Core/Routing/CompiledRouteLegacyTest.php
View source
<?php
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Routing\CompiledRoute;
use Drupal\Tests\UnitTestCase;
class CompiledRouteLegacyTest extends UnitTestCase {
private $compiled_route;
private $mocked_route;
protected function setUp() : void {
parent::setUp();
$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([]);
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
}