function DevelRouterRebuildTest::testRouterRebuildConfirmForm

Same name in other branches
  1. 5.x tests/src/Functional/DevelRouterRebuildTest.php \Drupal\Tests\devel\Functional\DevelRouterRebuildTest::testRouterRebuildConfirmForm()

Test routes rebuild.

File

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

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);
    $this->drupalLogin($this->adminUser);
    $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', [], '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);
}