LazyRouteProviderInstallTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. * {@inheritdoc}
  14. */
  15. protected $defaultTheme = 'stark';
  16. /**
  17. * Tests that the lazy route provider is used during a module install.
  18. */
  19. public function testInstallation() {
  20. $this->container->get('module_installer')->install(['router_test']);
  21. // Note that on DrupalCI the test site is installed in a sub directory so
  22. // we cannot use ::assertEquals().
  23. $this->assertStringEndsWith('/admin', \Drupal::state()->get('Drupal\lazy_route_provider_install_test\PluginManager'));
  24. $this->assertStringEndsWith('/router_test/test1', \Drupal::state()->get('router_test_install'));
  25. // If there is an exception thrown in rebuilding a route then the state
  26. // 'lazy_route_provider_install_test_menu_links_discovered_alter' will be
  27. // set.
  28. // @see lazy_route_provider_install_test_menu_links_discovered_alter().
  29. $this->assertEquals('success', \Drupal::state()->get('lazy_route_provider_install_test_menu_links_discovered_alter', NULL));
  30. }
  31. }