diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php index 62a2e6273b78002268bbf4a162dd1145a796ad20..0a01bd1c453dd79bc165468098974a334782033d 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php @@ -18,20 +18,6 @@ */ 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. * @@ -40,14 +26,15 @@ class ConfigExportImportUITest extends WebTestBase { protected $tarball; /** - * The name of the role with config UI administer permissions. + * Modules to enable. * - * @var string + * @var array */ - protected $admin_role; - - public static $modules = array('config'); + public static $modules = array('config', 'node', 'field'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Export/import UI', @@ -56,6 +43,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); // The initial import must be done with uid 1 because if separately named @@ -77,6 +67,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_config', array( + 'name' => drupal_strtolower($this->randomName()), + 'entity_type' => 'node', + 'type' => 'text', + )); + $this->field->save(); + entity_create('field_instance_config', 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(); @@ -85,12 +103,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_config'); + foreach ($field_instances as $field_instance) { + if ($field_instance->field_name == $this->field->name) { + $field_instance->delete(); + } + } + $fields = entity_load_multiple('field_config'); + 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'); } } -