summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-03-26 20:55:15 (GMT)
committerwebchick2014-03-26 20:55:15 (GMT)
commit23edb3ffa69fbd701b2b873c8d06e1b70edc9187 (patch)
treea4ae99bf4f2c7018c7c8f4834417a0fd28d765c4
parent4a57034dd94fca90883cfbe1f02196ef5bac01a5 (diff)
Issue #2108813 by cilefen, mtift, Désiré, xjm, InternetDevels: Add fancier config import/export test scenario.
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php77
1 files changed, 57 insertions, 20 deletions
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php
index 62a2e62..0a01bd1 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigExportImportUITest.php
@@ -19,20 +19,6 @@ use Drupal\simpletest\WebTestBase;
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
@@ -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 @@ class ConfigExportImportUITest extends WebTestBase {
);
}
+ /**
+ * {@inheritdoc}
+ */
protected function setUp() {
parent::setUp();
// The initial import must be done with uid 1 because if separately named
@@ -77,6 +67,34 @@ class ConfigExportImportUITest extends WebTestBase {
->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 @@ class ConfigExportImportUITest extends WebTestBase {
->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');
}
}
-