You are here

protected function TXTExportViewsDataExportTests::testHideEmptySupport in Views data export 7.3

Same name and namespace in other branches
  1. 7.4 tests/txt_export.test \TXTExportViewsDataExportTests::testHideEmptySupport()

Test to check if empty fields are correctly hidden.

File

tests/txt_export.test, line 90

Class

TXTExportViewsDataExportTests

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();
  $expected = '[ID]

1
[Name]

0
[Age]

25
----------------------------------------

[ID]

2
[Age]

27
----------------------------------------

[ID]

3
[Name]

Ringo
[Age]

28
----------------------------------------

[ID]

4
[Name]

Paul
----------------------------------------

[ID]

5
[Name]

Meredith
[Age]

30
----------------------------------------';
  $message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
  $this
    ->executeAndCompareGivenView($view, $expected, $message);
}