123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- class TXTExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
- protected $profile = 'testing';
- public static function getInfo() {
- return array(
- 'name' => 'TXT Export',
- 'description' => 'Various tests for exporting to TXT.',
- 'group' => 'Views Data Export',
- );
- }
- protected $vde_export_type = 'TXT';
- protected function getStylePluginName() {
- return 'views_data_export_txt';
- }
- protected function getExportView($path = 'vde_test') {
- // Create the basic view.
- $view = $this->getBasicExportView();
- $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
- $display->override_option('style_plugin', $this->getStylePluginName());
- $display->override_option('path', $path);
- $expected = '[ID]
- 1
- [Name]
- John
- [Age]
- 25
- ----------------------------------------
- [ID]
- 2
- [Name]
- George
- [Age]
- 27
- ----------------------------------------
- [ID]
- 3
- [Name]
- Ringo
- [Age]
- 28
- ----------------------------------------
- [ID]
- 4
- [Name]
- Paul
- [Age]
- 26
- ----------------------------------------
- [ID]
- 5
- [Name]
- Meredith
- [Age]
- 30
- ----------------------------------------';
- return array(&$view, $expected);
- }
- /**
- * Test to check if empty fields are correctly hidden.
- */
- 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);
- }
- }
|