Tests loading configuration entities.
protected function loadTests() {
$view = $this
->loadView('archive');
$data = config('views.view.archive')
->get();
// Confirm that an actual view object is loaded and that it returns all of
// expected properties.
$this
->assertTrue($view instanceof View, 'Single View instance loaded.');
foreach ($this->config_properties as $property) {
$this
->assertTrue($view
->get($property), format_string('Property: @property loaded onto View.', array(
'@property' => $property,
)));
}
// Check the displays have been loaded correctly from config display data.
$expected_displays = array(
'default',
'page_1',
'block_1',
);
$this
->assertEqual(array_keys($view
->get('display')), $expected_displays, 'The correct display names are present.');
// Check each ViewDisplay object and confirm that it has the correct key and
// property values.
foreach ($view
->get('display') as $key => $display) {
$this
->assertEqual($key, $display['id'], 'The display has the correct ID assigned.');
// Get original display data and confirm that the display options array
// exists.
$original_options = $data['display'][$key];
foreach ($original_options as $orig_key => $value) {
$this
->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', array(
'@key' => $key,
)));
}
}
// Fetch data for all configuration entities and default view configurations.
$all_configuration_entities = $this->controller
->load();
$all_config = config_get_storage_names_with_prefix('views.view');
// Remove the 'views.view.' prefix from config names for comparision with
// loaded configuration entities.
$prefix_map = function ($value) {
$parts = explode('.', $value);
return end($parts);
};
// Check that the correct number of configuration entities have been loaded.
$count = count($all_configuration_entities);
$this
->assertEqual($count, count($all_config), format_string('The array of all @count configuration entities is loaded.', array(
'@count' => $count,
)));
// Check that all of these machine names match.
$this
->assertIdentical(array_keys($all_configuration_entities), array_map($prefix_map, $all_config), 'All loaded elements match.');
// Make sure that loaded default views get a UUID.
$view = views_get_view('frontpage');
$this
->assertTrue($view->storage
->uuid());
}