diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php new file mode 100644 index 0000000..5f97517 --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php @@ -0,0 +1,103 @@ + 'Export/import UI', + 'description' => 'Tests the user interface for importing/exporting configuration.', + 'group' => 'Configuration', + ); + } + + protected function setUp() { + parent::setUp(); + // The initial import must be done with uid 1 because if separately named + // roles are created then the role is lost after import. If the roles + // created have the same name then the sync will fail because they will + // have different UUIDs. + $this->drupalLogin($this->root_user); + } + + /** + * Tests exporting the site configuration. + */ + function testExport() { + // Create a role for second round. + $this->role = $this->drupalCreateRole(array('synchronize configuration', 'import configuration')); + $this->slogan = $this->randomString(16); + \Drupal::config('system.site') + ->set('slogan', $this->slogan) + ->save(); + $this->drupalPostForm('admin/config/development/configuration/export', array(), 'Export'); + $this->tarball = $this->drupalGetContent(); + } + + /** + * Tests importing the tarball created in testExport(). + */ + function testImport() { + $filename = 'temporary://' . $this->randomName(); + file_put_contents($filename, $this->tarball); + $this->doImport($filename); + // Now that the role is imported, change the slogan and reimport with a non-root user. + $web_user = $this->drupalCreateUser(); + $web_user->addRole($this->role); + $web_user->save(); + $this->drupalLogin($web_user); + \Drupal::config('system.site') + ->set('slogan', $this->randomString(16)) + ->save(); + $this->doImport($filename); + } + + /** + * Import a tarball and assert the slogan is correct. + * + * @param string $filename + * The name of the tarball containing the configuration to be imported. + */ + protected function doImport($filename) { + $this->assertNotEqual($this->slogan, \Drupal::config('system.site')->get('slogan')); + $this->drupalPostForm('admin/config/development/configuration/import', array('files[import_tarball]' => $filename), 'Upload'); + $this->drupalPostForm(NULL, array(), 'Import all'); + $this->assertEqual($this->slogan, \Drupal::config('system.site')->get('slogan')); + } +} diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 7eb76fd..c2d4b44 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -748,6 +748,9 @@ public function run(array $methods = array()) { } } else { + if (defined("$class::SORT_METHODS")) { + sort($class_methods); + } foreach ($class_methods as $method) { // If the current method starts with "test", run it - it's a test. if (strtolower(substr($method, 0, 4)) == 'test') {