You are here

public function DevelRouterRebuildTest::testRouterRebuildConfirmForm in Devel 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelRouterRebuildTest.php \Drupal\Tests\devel\Functional\DevelRouterRebuildTest::testRouterRebuildConfirmForm()
  2. 8.2 tests/src/Functional/DevelRouterRebuildTest.php \Drupal\Tests\devel\Functional\DevelRouterRebuildTest::testRouterRebuildConfirmForm()
  3. 4.x tests/src/Functional/DevelRouterRebuildTest.php \Drupal\Tests\devel\Functional\DevelRouterRebuildTest::testRouterRebuildConfirmForm()

Test routes rebuild.

File

tests/src/Functional/DevelRouterRebuildTest.php, line 24

Class

DevelRouterRebuildTest
Tests routes rebuild.

Namespace

Drupal\Tests\devel\Functional

Code

public function testRouterRebuildConfirmForm() {

  // Reset the state flag.
  \Drupal::state()
    ->set('devel_test_route_rebuild', NULL);
  $this
    ->drupalGet('devel/menu/reset');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $web_user = $this
    ->drupalCreateUser([
    'administer site configuration',
  ]);
  $this
    ->drupalLogin($web_user);
  $this
    ->drupalGet('devel/menu/reset');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('Are you sure you want to rebuild the router?');
  $route_rebuild_state = \Drupal::state()
    ->get('devel_test_route_rebuild');
  $this
    ->assertEmpty($route_rebuild_state);
  $this
    ->drupalPostForm('devel/menu/reset', [], t('Rebuild'));
  $this
    ->assertSession()
    ->pageTextContains('The router has been rebuilt.');
  $route_rebuild_state = \Drupal::state()
    ->get('devel_test_route_rebuild');
  $this
    ->assertEquals('Router rebuild fired', $route_rebuild_state);
}