Commit 23edb3ff authored by webchick's avatar webchick

Issue #2108813 by cilefen, mtift, Désiré, xjm, InternetDevels: Add fancier...

Issue #2108813 by cilefen, mtift, Désiré, xjm, InternetDevels: Add fancier config import/export test scenario.
parent 4a57034d
......@@ -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');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment