diff --git a/core/lib/Drupal/Core/Routing/MatcherDumper.php b/core/lib/Drupal/Core/Routing/MatcherDumper.php index 7f85bf0..3249c9b 100644 --- a/core/lib/Drupal/Core/Routing/MatcherDumper.php +++ b/core/lib/Drupal/Core/Routing/MatcherDumper.php @@ -113,6 +113,8 @@ public function dump(array $options = array()) { // unstable router states due to random failures. $transaction = $this->connection->startTransaction(); try { + // During development routes might be moved to another provider (dynamic_routes + // or event a different module. $delete = $this->connection->delete($this->tableName); $or = $delete->orConditionGroup(); $or->condition('provider', $options['provider']); diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php index 2b7900b..60d9e7b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/MatcherDumperTest.php @@ -114,6 +114,38 @@ function testAddAdditionalRoutes() { } /** + * Tests that changing the provider of a route updates the dumped value. + * + * @see https://drupal.org/node/2160811 + */ + public function testRenameRouteProvider() { + $connection = Database::getConnection(); + $dumper = new MatcherDumper($connection, 'test_routes'); + $this->fixtures->createTables($connection); + + $route = new Route('/test'); + $collection = new RouteCollection(); + $collection->add('test', $route); + + $dumper->addRoutes($collection); + $dumper->dump(array('provider' => 'module_provider')); + + $record = $connection->query("SELECT * FROM {test_routes} WHERE name = :name", array(':name' => 'test'))->fetchObject(); + $this->assertEqual($record->provider, 'module_provider'); + + // Dump the same route again and ensure that the route has the new provider. + $dumper->addRoutes($collection); + $dumper->dump(array('provider' => 'module_provider2')); + + $result = $connection->query("SELECT * FROM {test_routes} WHERE provider = :provider", array(':provider' => 'module_provider'))->fetchObject(); + $this->assertFalse($result); + + $record = $connection->query("SELECT * FROM {test_routes} WHERE provider = :provider", array(':provider' => 'module_provider2'))->fetchObject(); + $this->assertEqual($record->path, '/test'); + $this->assertEqual($record->name, 'test'); + } + + /** * Confirm that we can dump a route collection to the database. */ public function testDump() {