class RouteWrapperTest in Drupal 7 to 8/9 Module Upgrader 8
Same name in this branch
- 8 tests/src/Unit/Routing/Drupal7/RouteWrapperTest.php \Drupal\Tests\drupalmoduleupgrader\Unit\Routing\Drupal7\RouteWrapperTest
- 8 tests/src/Unit/Routing/Drupal8/RouteWrapperTest.php \Drupal\Tests\drupalmoduleupgrader\Unit\Routing\Drupal8\RouteWrapperTest
@group DMU.Routing
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\drupalmoduleupgrader\Unit\Routing\Drupal7\RouteWrapperTest
Expanded class hierarchy of RouteWrapperTest
File
- tests/
src/ Unit/ Routing/ Drupal7/ RouteWrapperTest.php, line 11
Namespace
Drupal\Tests\drupalmoduleupgrader\Unit\Routing\Drupal7View source
class RouteWrapperTest extends UnitTestCase {
private function getMockRouteWrapper() {
$route = [
'title' => 'List revisions',
'page callback' => 'diff_diffs_overview',
'type' => 'MENU_DEFAULT_LOCAL_TASK',
'access callback' => 'diff_node_revision_access',
'access arguments' => [
1,
],
'file' => 'diff.pages.inc',
];
return new RouteWrapper('node/%node/revisions/list', $route);
}
public function testGetIdentifier() {
$this
->assertEquals('node/%node/revisions/list', $this
->getMockRouteWrapper()
->getIdentifier());
}
public function testGetPath() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertInstanceOf('\\Drupal\\drupalmoduleupgrader\\Utility\\Path\\Drupal7\\PathUtility', $wrapper
->getPath());
$this
->assertEquals('node/%node/revisions/list', $wrapper
->getPath());
}
public function testUnwrap() {
$route = [
'title' => 'List revisions',
'page callback' => 'diff_diffs_overview',
'type' => 'MENU_DEFAULT_LOCAL_TASK',
'access callback' => 'diff_node_revision_access',
'access arguments' => [
1,
],
'file' => 'diff.pages.inc',
];
$unwrapped_route = $this
->getMockRouteWrapper()
->unwrap();
$this
->assertTrue(is_array($unwrapped_route));
foreach ($route as $key => $value) {
$this
->assertArrayHasKey($key, $unwrapped_route);
$this
->assertEquals($value, $unwrapped_route[$key]);
}
}
public function testIsAbsoluteAccess() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertFalse($wrapper
->isAbsoluteAccess());
$wrapper['access callback'] = TRUE;
$this
->assertTrue($wrapper
->isAbsoluteAccess());
$wrapper['access callback'] = FALSE;
$this
->assertTrue($wrapper
->isAbsoluteAccess());
}
public function testIsPermissionBased() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertFalse($wrapper
->isPermissionBased());
$wrapper['access callback'] = 'user_access';
$this
->assertTrue($wrapper
->isPermissionBased());
}
public function testHasLink() {
$this
->assertTrue($this
->getMockRouteWrapper()
->hasLink());
}
public function testIsLink() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertFalse($wrapper
->isLink());
$wrapper['type'] = 'MENU_NORMAL_ITEM';
$this
->assertTrue($wrapper
->isLink());
}
public function testIsLocalTask() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertFalse($wrapper
->isLocalTask());
$wrapper['type'] = 'MENU_LOCAL_TASK';
$this
->assertTrue($wrapper
->isLocalTask());
}
public function testIsDefaultLocalTask() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertTrue($wrapper
->isDefaultLocalTask());
$wrapper['type'] = 'MENU_NORMAL_ITEM';
$this
->assertFalse($wrapper
->isDefaultLocalTask());
}
public function testIsLocalAction() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertFalse($wrapper
->isLocalAction());
$wrapper['type'] = 'MENU_LOCAL_ACTION';
$this
->assertTrue($wrapper
->isLocalAction());
}
public function testIsContextualLink() {
$wrapper = $this
->getMockRouteWrapper();
$this
->assertFalse($wrapper
->isContextualLink());
$wrapper['type'] = 'MENU_LOCAL_ACTION';
$this
->assertTrue($wrapper
->isLocalAction());
$this
->assertFalse($wrapper
->isContextualLink());
$wrapper['context'] = 'MENU_CONTEXT_INLINE';
$this
->assertTrue($wrapper
->isContextualLink());
$wrapper['type'] = 'MENU_NORMAL_ITEM';
$this
->assertFalse($wrapper
->isContextualLink());
}
}
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. | |
RouteWrapperTest:: |
private | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
RouteWrapperTest:: |
public | function | ||
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. | |
UnitTestCase:: |
protected | function | 340 |