You are here

protected function XMLExportViewsDataExportTests::testHideEmptySupport in Views data export 7.4

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

Test to check if empty fields are correctly hidden.

File

tests/xml_export.test, line 72

Class

XMLExportViewsDataExportTests

Code

protected function testHideEmptySupport() {
  $view = $this
    ->getHideIfEmptyExportView();

  // We need to ensure that the test fields are actually empty/0.
  db_update('views_test')
    ->fields(array(
    'age' => 0,
  ))
    ->condition('name', 'Paul')
    ->execute();
  db_update('views_test')
    ->fields(array(
    'name' => '',
  ))
    ->condition('name', 'George')
    ->execute();
  db_update('views_test')
    ->fields(array(
    'name' => 0,
  ))
    ->condition('name', 'John')
    ->execute();
  $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>
    <Name>0</Name>
    <Age>25</Age>
  </views_test>
  <views_test>
    <ID>2</ID>
    <Age>27</Age>
  </views_test>
  <views_test>
    <ID>3</ID>
    <Name>Ringo</Name>
    <Age>28</Age>
  </views_test>
  <views_test>
    <ID>4</ID>
    <Name>Paul</Name>
  </views_test>
  <views_test>
    <ID>5</ID>
    <Name>Meredith</Name>
    <Age>30</Age>
  </views_test>
</views_tests>';
  $message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
  $this
    ->executeAndCompareGivenView($view, $expected, $message, $style_options);
}