Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* @file
* Contains \Drupal\node\Tests\Config\NodeImportChangeTest.
*/
namespace Drupal\node\Tests\Config;
use Drupal\simpletest\DrupalUnitTestBase;
/**
* Tests updating content types as part of config import.
*/
class NodeImportChangeTest extends DrupalUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'entity', 'field', 'text', 'field_sql_storage', 'system', 'node_test_config');
/**
* Set the default field storage backend for fields created during tests.
*/
public function setUp() {
parent::setUp();
$this->installSchema('system', array('config_snapshot'));
// Set default storage backend.
$this->installConfig(array('field', 'node_test_config'));
}
public static function getInfo() {
return array(
'name' => 'Node config change tests',
'description' => 'Change content types during config create method invocation.',
'group' => 'Node',
);
}
/**
* Tests importing an updated content type.
*/
public function testImportChange() {
$node_type_id = 'default';
$node_type_config_name = "node.type.$node_type_id";
// Simulate config data to import:
// - a modified version (modified label) of the node type config.
$active = $this->container->get('config.storage');
$staging = $this->container->get('config.storage.staging');
$this->copyConfig($active, $staging);
$node_type = $active->read($node_type_config_name);
$new_label = 'Test update import field';
$node_type['name'] = $new_label;
// Save as files in the the staging directory.
$staging->write($node_type_config_name, $node_type);
// Import the content of the staging directory.
$this->configImporter()->import();
// Check that the updated config was correctly imported.
$node_type = entity_load('node_type', $node_type_id);
$this->assertEqual($node_type->label(), $new_label, 'Node type name has been updated.');
}
}