diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php index 9095b7d..7ec6bb6 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php @@ -21,33 +21,12 @@ class ConfigExportImportUITest extends WebTestBase { /** - * The site UUID. - * - * @var string - */ - protected $siteUuid; - - /** - * The slogan value, for a simple export test case. - * - * @var string - */ - protected $slogan; - - /** * The contents of the config export tarball, held between test methods. * * @var string */ protected $tarball; - /** - * The name of the role with config UI administer permissions. - * - * @var string - */ - protected $admin_role; - public static $modules = array('config'); public static function getInfo() { @@ -79,6 +58,34 @@ public function testExportImport() { ->save(); $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->newSlogan); + // Create a content type. + $this->content_type = $this->drupalCreateContentType(); + + // Create a field. + $this->field = entity_create('field_entity', array( + 'name' => drupal_strtolower($this->randomName()), + 'entity_type' => 'node', + 'type' => 'text', + )); + $this->field->save(); + entity_create('field_instance', array( + 'field_name' => $this->field->name, + 'entity_type' => 'node', + 'bundle' => $this->content_type->type, + ))->save(); + entity_get_form_display('node', $this->content_type->type, 'default') + ->setComponent($this->field->name, array( + 'type' => 'text_textfield', + )) + ->save(); + entity_get_display('node', $this->content_type->type, 'full') + ->setComponent($this->field->name) + ->save(); + + $this->drupalGet('node/add/' . $this->content_type->type); + $this->assertFieldByName("{$this->field->name}[0][value]", '', 'Widget is displayed'); + + // Export the configuration. $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export'); $this->tarball = $this->drupalGetContent(); @@ -87,12 +94,31 @@ public function testExportImport() { ->save(); $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->originalSlogan); + // Delete the custom field. + $field_instances = entity_load_multiple('field_instance'); + foreach ($field_instances as $field_instance) { + if ($field_instance->field_name == $this->field->name) { + $field_instance->delete(); + } + } + $fields = entity_load_multiple('field_entity'); + foreach ($fields as $field) { + if ($field->name == $this->field->name) { + $field->delete(); + } + } + $this->drupalGet('node/add/' . $this->content_type->type); + $this->assertNoFieldByName("{$this->field->name}[0][value]", '', 'Widget is not displayed'); + + // Import the configuration. $filename = 'temporary://' . $this->randomName(); file_put_contents($filename, $this->tarball); $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload'); $this->drupalPostForm(NULL, array(), 'Import all'); $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->newSlogan); + + $this->drupalGet('node/add'); + $this->assertFieldByName("{$this->field->name}[0][value]", '', 'Widget is displayed'); } } -