You are here

protected function XMLExportViewsDataExportTests::testXMLCDATAWrapper in Views data export 7.4

Same name and namespace in other branches
  1. 7.3 tests/xml_export.test \XMLExportViewsDataExportTests::testXMLCDATAWrapper()

Test to ensure certain fields can be optionally non-escaped.

File

tests/xml_export.test, line 343

Class

XMLExportViewsDataExportTests

Code

protected function testXMLCDATAWrapper() {
  $view = $this
    ->getBasicExportView();
  $style_options = array(
    'exporter_options' => array(
      'cdata_wrapper' => array(
        'id' => 'id',
        'name' => 'name',
      ),
      'root_node' => 'views_tests',
      'item_node' => 'views_test',
    ),
  );
  $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',
      'alter' => array(
        'alter_text' => TRUE,
        'text' => '<em>[name]</em>',
      ),
    ),
    'age' => array(
      'id' => 'age',
      'table' => 'views_test',
      'field' => 'age',
      'relationship' => 'none',
    ),
  ));
  $expected = '<?xml version="1.0" encoding="UTF-8"?>
<views_tests>
  <views_test>
    <ID><![CDATA[1]]></ID>
    <Name><![CDATA[<em>John</em>]]></Name>
    <Age>25</Age>
  </views_test>
  <views_test>
    <ID><![CDATA[2]]></ID>
    <Name><![CDATA[<em>George</em>]]></Name>
    <Age>27</Age>
  </views_test>
  <views_test>
    <ID><![CDATA[3]]></ID>
    <Name><![CDATA[<em>Ringo</em>]]></Name>
    <Age>28</Age>
  </views_test>
  <views_test>
    <ID><![CDATA[4]]></ID>
    <Name><![CDATA[<em>Paul</em>]]></Name>
    <Age>26</Age>
  </views_test>
  <views_test>
    <ID><![CDATA[5]]></ID>
    <Name><![CDATA[<em>Meredith</em>]]></Name>
    <Age>30</Age>
  </views_test>
</views_tests>';
  $message = 'XML in values test in ' . $this->vde_export_type . ' export matched expected output.';
  $this
    ->executeAndCompareGivenView($view, $expected, $message, $style_options);
}