protected function XMLExportViewsDataExportTests::testEmptyLabels in Views data export 7.4
Same name and namespace in other branches
- 7.3 tests/xml_export.test \XMLExportViewsDataExportTests::testEmptyLabels()
Test to ensure that valid XML is produced when someone doesn't specify a label.
File
- tests/
xml_export.test, line 134
Class
Code
protected function testEmptyLabels() {
$view = $this
->getBasicExportView();
$display = $view->display['default']->handler;
$display
->override_option('fields', array(
'id' => array(
'id' => 'id',
'table' => 'views_test',
'field' => 'id',
'relationship' => 'none',
),
'name' => array(
'id' => 'name',
'table' => 'views_test',
'field' => 'name',
'relationship' => 'none',
// Remove the label from the name field.
'label' => '',
),
'age' => array(
'id' => 'age',
'table' => 'views_test',
'field' => 'age',
'relationship' => 'none',
// Make this label intentially invalid XML.
'label' => '.',
),
));
$style_options = array(
'exporter_options' => array(
'root_node' => 'views_tests',
'item_node' => 'views_test',
),
);
$expected = '<?xml version="1.0" encoding="UTF-8"?>
<views_tests>
<views_test>
<ID>1</ID>
<Views-test:-Name>John</Views-test:-Name>
<invalid-tag-name>25</invalid-tag-name>
</views_test>
<views_test>
<ID>2</ID>
<Views-test:-Name>George</Views-test:-Name>
<invalid-tag-name>27</invalid-tag-name>
</views_test>
<views_test>
<ID>3</ID>
<Views-test:-Name>Ringo</Views-test:-Name>
<invalid-tag-name>28</invalid-tag-name>
</views_test>
<views_test>
<ID>4</ID>
<Views-test:-Name>Paul</Views-test:-Name>
<invalid-tag-name>26</invalid-tag-name>
</views_test>
<views_test>
<ID>5</ID>
<Views-test:-Name>Meredith</Views-test:-Name>
<invalid-tag-name>30</invalid-tag-name>
</views_test>
</views_tests>';
$message = 'Empty label test in ' . $this->vde_export_type . ' export matched expected output.';
$this
->executeAndCompareGivenView($view, $expected, $message, $style_options);
}