You are here

protected function XMLExportViewsDataExportTests::testXMLNoEntityEncode in Views data export 7.4

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

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

File

tests/xml_export.test, line 262

Class

XMLExportViewsDataExportTests

Code

protected function testXMLNoEntityEncode() {
  $view = $this
    ->getBasicExportView();
  $display = $view->display['default']->handler;
  $style_options = array(
    'exporter_options' => array(
      'no_entity_encode' => array(
        'id' => 'id',
      ),
      'root_node' => 'views_tests',
      'item_node' => 'views_test',
    ),
  );
  $display
    ->override_option('fields', array(
    'id' => array(
      'id' => 'id',
      'table' => 'views_test',
      'field' => 'id',
      'relationship' => 'none',
      'alter' => array(
        'alter_text' => TRUE,
        'text' => '<strong>[id]</strong>',
      ),
    ),
    '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><strong>1</strong></ID>
    <Name>&amp;lt;em&amp;gt;John&amp;lt;/em&amp;gt;</Name>
    <Age>25</Age>
  </views_test>
  <views_test>
    <ID><strong>2</strong></ID>
    <Name>&amp;lt;em&amp;gt;George&amp;lt;/em&amp;gt;</Name>
    <Age>27</Age>
  </views_test>
  <views_test>
    <ID><strong>3</strong></ID>
    <Name>&amp;lt;em&amp;gt;Ringo&amp;lt;/em&amp;gt;</Name>
    <Age>28</Age>
  </views_test>
  <views_test>
    <ID><strong>4</strong></ID>
    <Name>&amp;lt;em&amp;gt;Paul&amp;lt;/em&amp;gt;</Name>
    <Age>26</Age>
  </views_test>
  <views_test>
    <ID><strong>5</strong></ID>
    <Name>&amp;lt;em&amp;gt;Meredith&amp;lt;/em&amp;gt;</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);
}