/** * Tests \Drupal\Core\Routing\RouteBuilder::rebuildIfNeeded() method. */ 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(array())); $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()); }
/** * Resets some other systems like rebuilding the route information or caches. */ protected function resetSystem() { if ($this->routeBuilder) { $this->routeBuilder->setRebuildNeeded(); } $this->systemListReset(); // @todo It feels wrong to have the requirement to clear the local tasks // cache here. Cache::deleteTags(array('local_task' => 1)); $this->themeRegistryRebuild(); }
/** * Tests \Drupal\Core\Routing\RouteBuilder::rebuildIfNeeded() method. */ public function testRebuildIfNecessary() { $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->routeBuilderIndicator->expects($this->once())->method('setRebuildNeeded'); $this->routeBuilderIndicator->expects($this->once())->method('setRebuildDone'); $this->routeBuilderIndicator->expects($this->exactly(2))->method('isRebuildNeeded')->will($this->onConsecutiveCalls(TRUE, FALSE)); $this->yamlDiscovery->expects($this->any())->method('findAll')->will($this->returnValue(array())); $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()); }
/** * Run the Drupal route rebuild. */ public function rebuildRoutes() { $this->routeBuilder->rebuild(); }