You are here

public function RouteBuilderTest::testRebuildIfNeeded in Drupal 8

Tests \Drupal\Core\Routing\RouteBuilder::rebuildIfNeeded() method.

File

core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php, line 258
Contains \Drupal\Tests\Core\Routing\RouteBuilderTest.

Class

RouteBuilderTest
@coversDefaultClass \Drupal\Core\Routing\RouteBuilder @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testRebuildIfNeeded() {
  $this->lock
    ->expects($this
    ->once())
    ->method('acquire')
    ->with('router_rebuild')
    ->will($this
    ->returnValue(TRUE));
  $this->lock
    ->expects($this
    ->once())
    ->method('release')
    ->with('router_rebuild');
  $this->yamlDiscovery
    ->expects($this
    ->any())
    ->method('findAll')
    ->will($this
    ->returnValue([]));
  $this->routeBuilder
    ->setRebuildNeeded();

  // This will trigger a successful rebuild.
  $this
    ->assertTrue($this->routeBuilder
    ->rebuildIfNeeded());

  // This will not trigger a rebuild.
  $this
    ->assertFalse($this->routeBuilder
    ->rebuildIfNeeded());
}