class LinkBindingTest 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\LinkBinding\LinkBindingTest
Expanded class hierarchy of LinkBindingTest
File
- tests/
src/ Unit/ Routing/ LinkBinding/ LinkBindingTest.php, line 15
Namespace
Drupal\Tests\drupalmoduleupgrader\Unit\Routing\LinkBindingView source
class LinkBindingTest extends UnitTestCase {
private $source, $destination;
public function setUp() {
parent::setUp();
$item = [
'title' => 'Diff',
'description' => 'Diff settings.',
'file' => 'diff.admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => [
'diff_admin_settings',
],
'access arguments' => [
'administer site configuration',
],
];
$this->source = new Drupal7Route('admin/config/content/diff', $item);
$this->destination = new Drupal8Route('diff.settings', new Route('/admin/config/content/diff'), $this
->createMock('\\Drupal\\Core\\Routing\\RouteProviderInterface'));
}
private function getMockBinding() {
return new LinkBinding($this->source, $this->destination);
}
public function testGetSource() {
$this
->assertSame($this->source, $this
->getMockBinding()
->getSource());
}
public function testGetDestination() {
$this
->assertSame($this->destination, $this
->getMockBinding()
->getDestination());
}
public function testGetIdentifier() {
$this
->assertSame('diff.settings', $this
->getMockBinding()
->getIdentifier());
}
public function testOnIndexed() {
$binding = $this
->getMockBinding();
$index = new LinkIndex();
$index
->addBinding($binding);
$this
->assertSame('diff.settings', $binding
->getIdentifier());
// If a binding is added with the same identifier (which could easily happen,
// depending on how the binding computes its identifier), _0, _1, etc. should
// be appended to it by the index.
$clone = clone $binding;
$index
->addBinding($clone);
$this
->assertSame('diff.settings_0', $clone
->getIdentifier());
}
public function testBuild() {
$link = $this
->getMockBinding()
->build();
$this
->assertEquals('diff.settings', $link['route_name']);
$this
->assertEquals('Diff', $link['title']);
$this
->assertArrayNotHasKey('weight', $link);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LinkBindingTest:: |
private | property | ||
LinkBindingTest:: |
private | function | ||
LinkBindingTest:: |
public | function |
Overrides UnitTestCase:: |
|
LinkBindingTest:: |
public | function | ||
LinkBindingTest:: |
public | function | ||
LinkBindingTest:: |
public | function | ||
LinkBindingTest:: |
public | function | ||
LinkBindingTest:: |
public | function | ||
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. | |
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. |