Drupal investigation

RevisionOverviewIntegrationTest.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\Tests\entity\Kernel;
  3. use Drupal\KernelTests\KernelTestBase;
  4. use Symfony\Component\Routing\Route;
  5. /**
  6. * Tests some integration of the revision overview:
  7. *
  8. * - Are the routes added properly.
  9. * - Are the local tasks added properly.
  10. */
  11. class RevisionOverviewIntegrationTest extends KernelTestBase {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static $modules = ['node', 'entity_module_test', 'entity', 'user', 'system'];
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected function setUp() {
  20. parent::setUp();
  21. $this->installSchema('system', 'router');
  22. \Drupal::service('router.builder')->rebuild();
  23. }
  24. public function testIntegration() {
  25. /** @var \Drupal\Core\Menu\LocalTaskManagerInterface $local_tasks_manager */
  26. $local_tasks_manager = \Drupal::service('plugin.manager.menu.local_task');
  27. $tasks = $local_tasks_manager->getDefinitions();
  28. $this->assertArrayHasKey('entity.revisions_overview:entity_test_enhanced', $tasks);
  29. $this->assertArrayNotHasKey('entity.revisions_overview:node', $tasks, 'Node should have been excluded because it provides their own');
  30. $this->assertEquals('entity.entity_test_enhanced.version_history', $tasks['entity.revisions_overview:entity_test_enhanced']['route_name']);
  31. $this->assertEquals('entity.entity_test_enhanced.canonical', $tasks['entity.revisions_overview:entity_test_enhanced']['base_route']);
  32. /** @var \Drupal\Core\Routing\RouteProviderInterface $route_provider */
  33. $route_provider = \Drupal::service('router.route_provider');
  34. $route = $route_provider->getRouteByName('entity.entity_test_enhanced.version_history');
  35. $this->assertInstanceOf(Route::class, $route);
  36. $this->assertEquals('\Drupal\entity\Controller\RevisionOverviewController::revisionOverviewController', $route->getDefault('_controller'));
  37. }
  38. }