Chris@0: tableDefinition(); Chris@0: $schema = $connection->schema(); Chris@0: Chris@0: foreach ($tables as $name => $table) { Chris@0: $schema->dropTable($name); Chris@0: $schema->createTable($name, $table); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Drop the tables used for the sample data. Chris@0: * Chris@0: * @param \Drupal\Core\Database\Connection $connection Chris@0: * The connection to use to drop the tables. Chris@0: */ Chris@0: public function dropTables(Connection $connection) { Chris@0: $tables = $this->tableDefinition(); Chris@0: $schema = $connection->schema(); Chris@0: Chris@0: foreach ($tables as $name => $table) { Chris@0: $schema->dropTable($name); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns an array of URL aliases for testing. Chris@0: * Chris@0: * @return array of URL alias definitions. Chris@0: */ Chris@0: public function sampleUrlAliases() { Chris@0: return [ Chris@0: [ Chris@0: 'source' => '/node/1', Chris@0: 'alias' => '/alias_for_node_1_en', Chris@17: 'langcode' => 'en', Chris@0: ], Chris@0: [ Chris@0: 'source' => '/node/2', Chris@0: 'alias' => '/alias_for_node_2_en', Chris@17: 'langcode' => 'en', Chris@0: ], Chris@0: [ Chris@0: 'source' => '/node/1', Chris@0: 'alias' => '/alias_for_node_1_fr', Chris@17: 'langcode' => 'fr', Chris@0: ], Chris@0: [ Chris@0: 'source' => '/node/1', Chris@0: 'alias' => '/alias_for_node_1_und', Chris@17: 'langcode' => 'und', Chris@17: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the table definition for the URL alias fixtures. Chris@0: * Chris@0: * @return array Chris@0: * Table definitions. Chris@0: */ Chris@0: public function tableDefinition() { Chris@0: $tables = []; Chris@0: Chris@0: // Prime the drupal_get_filename() cache with the location of the system Chris@0: // module as its location is known and shouldn't change. Chris@0: // @todo Remove as part of https://www.drupal.org/node/2186491 Chris@0: drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml'); Chris@0: module_load_install('system'); Chris@0: $schema = system_schema(); Chris@0: Chris@0: $tables['url_alias'] = AliasStorage::schemaDefinition(); Chris@0: $tables['key_value'] = $schema['key_value']; Chris@0: Chris@0: return $tables; Chris@0: } Chris@0: Chris@0: }