RevisionOverviewIntegrationTest.php in Entity API 8.0
File
tests/Kernel/RevisionOverviewIntegrationTest.php
View source
<?php
namespace Drupal\Tests\entity\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Routing\Route;
class RevisionOverviewIntegrationTest extends KernelTestBase {
public static $modules = [
'node',
'entity_module_test',
'entity',
'user',
'system',
];
protected function setUp() {
parent::setUp();
$this
->installSchema('system', 'router');
\Drupal::service('router.builder')
->rebuild();
}
public function testIntegration() {
$local_tasks_manager = \Drupal::service('plugin.manager.menu.local_task');
$tasks = $local_tasks_manager
->getDefinitions();
$this
->assertArrayHasKey('entity.revisions_overview:entity_test_enhanced', $tasks);
$this
->assertArrayNotHasKey('entity.revisions_overview:node', $tasks, 'Node should have been excluded because it provides their own');
$this
->assertEquals('entity.entity_test_enhanced.version_history', $tasks['entity.revisions_overview:entity_test_enhanced']['route_name']);
$this
->assertEquals('entity.entity_test_enhanced.edit_form', $tasks['entity.revisions_overview:entity_test_enhanced']['base_route']);
$route_provider = \Drupal::service('router.route_provider');
$route = $route_provider
->getRouteByName('entity.entity_test_enhanced.version_history');
$this
->assertInstanceOf(Route::class, $route);
$this
->assertEquals('\\Drupal\\entity\\Controller\\RevisionOverviewController::revisionOverviewController', $route
->getDefault('_controller'));
}
}