You are here

protected function XMLExportViewsDataExportExporterTests::testTagValidity in Views data export 7.4

Test that tags always come out valid.

File

tests/exporter_tests/xml.test, line 308

Class

XMLExportViewsDataExportExporterTests

Code

protected function testTagValidity() {

  // Set up a dataset with problems in the attribute names.
  $spaced_dataset = array(
    array(
      'name of artist' => 'John Lennon',
      'their age' => 25,
      'their job' => 'they are a Singer',
      'created' => gmmktime(0, 0, 0, 1, 1, 2000),
    ),
  );

  // Test each of the different swap-out options.
  // Dash.
  $result = $this
    ->executeFullWrite($this
    ->getExporter(array(
    'transform' => true,
    'transform_type' => 'dash',
  )), $spaced_dataset, 0, array(
    'name of artist' => '',
    'their age' => '1',
    'their job' => 'BadCharacters>&<',
  ));
  $expected = '  <item>
    <no-name>John Lennon</no-name>
    <data>25</data>
    <BadCharacters>they are a Singer</BadCharacters>
    <created>946684800</created>
  </item>
';
  $this
    ->logVerboseResult($result, 'Actual result');
  $this
    ->logVerboseResult($expected, 'Expected result');
  $this
    ->assertEqual($result, $expected, 'The content is as expected.');
}