diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php index 539879a..7b4fec6 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php @@ -33,6 +33,13 @@ class ConfigExportImportUITest extends WebTestBase { * @var string */ protected $tarball; + + /** + * A content type, held between test methods. + * + * @var string + */ + protected $content_type; /** * The name of the role with config UI administer permissions. @@ -70,11 +77,17 @@ protected function setUp() { */ function testExport() { // Create a role for second round. - $this->admin_role = $this->drupalCreateRole(array('synchronize configuration', 'import configuration')); + $this->admin_role = $this->drupalCreateRole(array('synchronize configuration', 'import configuration', 'administer content types')); $this->slogan = $this->randomString(16); \Drupal::config('system.site') ->set('slogan', $this->slogan) ->save(); + + // Create a content type programmaticaly. + $this->content_type = $this->drupalCreateContentType(); + $type_exists = (bool) entity_load('node_type', $this->content_type->type); + $this->assertTrue($type_exists, 'The new content type has been created in the database.'); + $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export'); $this->tarball = $this->drupalGetContent(); } @@ -91,22 +104,34 @@ function testImport() { $web_user->addRole($this->admin_role); $web_user->save(); $this->drupalLogin($web_user); + + // Change the site slogan. \Drupal::config('system.site') ->set('slogan', $this->randomString(16)) ->save(); + $this->assertNotEqual($this->slogan, \Drupal::config('system.site')->get('slogan')); + + // Delete the content type we added earlier. + $this->drupalPostForm('admin/structure/types/manage/' . $this->content_type->type . '/delete', array(), 'Delete'); + $type_exists = (bool) entity_load('node_type', $this->content_type->type); + $this->assertFalse($type_exists, 'The new content type has been deleted.'); + $this->doImport($filename); + + // Check that settings are returned to their prior values. + $this->assertEqual($this->slogan, \Drupal::config('system.site')->get('slogan')); + $type_exists = (bool) entity_load('node_type', $this->content_type->type); + $this->assertTrue($type_exists, 'The new content type has been created in the database.'); } /** - * Import a tarball and assert the data is correct. + * Import a tarball. * * @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/full/import', array('files[import_tarball]' => $filename), 'Upload'); $this->drupalPostForm(NULL, array(), 'Import all'); - $this->assertEqual($this->slogan, \Drupal::config('system.site')->get('slogan')); } }