LazyRouteProviderInstallTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Drupal\FunctionalTests\Routing;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * @group routing
  6. */
  7. class LazyRouteProviderInstallTest extends BrowserTestBase {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. protected static $modules = ['lazy_route_provider_install_test'];
  12. /**
  13. * Tests that the lazy route provider is used during a module install.
  14. */
  15. public function testInstallation() {
  16. $this->container->get('module_installer')->install(['router_test']);
  17. // Note that on DrupalCI the test site is installed in a sub directory so
  18. // we cannot use ::assertEquals().
  19. $this->assertStringEndsWith('/admin', \Drupal::state()->get('Drupal\lazy_route_provider_install_test\PluginManager'));
  20. $this->assertStringEndsWith('/router_test/test1', \Drupal::state()->get('router_test_install'));
  21. // If there is an exception thrown in rebuilding a route then the state
  22. // 'lazy_route_provider_install_test_menu_links_discovered_alter' will be
  23. // set.
  24. // @see lazy_route_provider_install_test_menu_links_discovered_alter().
  25. $this->assertEquals('success', \Drupal::state()->get('lazy_route_provider_install_test_menu_links_discovered_alter', NULL));
  26. }
  27. }