class RouterBaseTest in Drupal 7 to 8/9 Module Upgrader 8
@group DMU.Routing
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\drupalmoduleupgrader\Unit\Routing\RouterBaseTest
Expanded class hierarchy of RouterBaseTest
File
- tests/
src/ Unit/ Routing/ RouterBaseTest.php, line 14
Namespace
Drupal\Tests\drupalmoduleupgrader\Unit\RoutingView source
class RouterBaseTest extends UnitTestCase {
private $userEdit, $userView, $userRoot, $routeProvider;
public function setUp() {
parent::setUp();
$this->userEdit = new Route('/user/{user}/edit');
$this->userView = new Route('/user/{user}');
$this->userRoot = new Route('/user');
$route_collection = new RouteCollection();
$route_collection
->add('user', $this->userRoot);
$this->routeProvider = $this
->createMock('\\Drupal\\Core\\Routing\\RouteProviderInterface');
$this->routeProvider
->expects($this
->any())
->method('getRoutesByPattern')
->with('/user')
->will($this
->returnValue($route_collection));
}
public function testAddRoute() {
$router = new RouterBase();
$this
->assertCount(0, $router);
$route = new RouteWrapper('user.edit', $this->userEdit, $this->routeProvider);
$router
->addRoute($route);
$this
->assertCount(1, $router);
}
/**
* @depends testAddRoute
*/
public function testFinalize() {
$router = new RouterBase();
$user_edit = new RouteWrapper('user.edit', $this->userEdit, $this->routeProvider);
$router
->addRoute($user_edit);
$user_view = new RouteWrapper('user.view', $this->userView, $this->routeProvider);
$router
->addRoute($user_view);
$router
->finalize();
$this
->assertTrue($user_edit
->hasParent());
$this
->assertSame($user_view, $user_edit
->getParent());
$this
->assertTrue($user_view
->hasParent());
$this
->assertEquals('/user', $user_view
->getParent()
->getPath());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RouterBaseTest:: |
private | property | ||
RouterBaseTest:: |
public | function |
Overrides UnitTestCase:: |
|
RouterBaseTest:: |
public | function | ||
RouterBaseTest:: |
public | function | @depends testAddRoute | |
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 | Mocks a block with a block plugin. | 1 |
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. |