You are here

protected function XMLExportViewsDataExportExporterTests::testEntityEncode in Views data export 7.4

Test the entity encoding options.

File

tests/exporter_tests/xml.test, line 211

Class

XMLExportViewsDataExportExporterTests

Code

protected function testEntityEncode() {

  // Whip up a dataset with some valid XML attribute values.
  $test_entity_encode_dataset = array(
    array(
      'name' => '<strong>John</strong>',
      'age' => 25,
      'job' => '<em>Singer</em>',
    ),
  );

  // Execute a full write, specifying that the name attribute already provides
  // valid XML, so should not be played around with.
  $result = $this
    ->executeFullWrite($this
    ->getExporter(array(
    'no_entity_encode' => array(
      'name' => 'name',
    ),
  )), $test_entity_encode_dataset, 0, array(
    'name' => 'name',
    'age' => 'age',
    'job' => 'job',
  ));

  // Expect the name attribute to contain the <strong> XML tags.
  // The <em> tags in the job attribute should still be escaped/encoded.
  $expected = '  <item>
    <name><strong>John</strong></name>
    <age>25</age>
    <job>&amp;lt;em&amp;gt;Singer&amp;lt;/em&amp;gt;</job>
  </item>
';
  $this
    ->logVerboseResult($result, 'Actual result');
  $this
    ->logVerboseResult($expected, 'Expected to contain');
  $this
    ->assertEqual($result, $expected, 'The entities were encoded correctly.');
}