Projet

Général

Profil

Paste
Télécharger (2,29 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views_data_export / tests / txt_export.test @ 651307cd

1 85ad3d82 Assos Assos
<?php
2
3
class TXTExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
4
5
  protected $profile = 'testing';
6
7
  public static function getInfo() {
8
    return array(
9
      'name' => 'TXT Export',
10
      'description' => 'Various tests for exporting to TXT.',
11
      'group' => 'Views Data Export',
12
    );
13
  }
14
15
  protected $vde_export_type = 'TXT';
16
17
  protected function getStylePluginName() {
18
    return 'views_data_export_txt';
19
  }
20
21
  protected function getExportView($path = 'vde_test') {
22
    // Create the basic view.
23
    $view = $this->getBasicExportView();
24
25
    $display = $view->new_display('views_data_export', 'Data export', 'vde_test');
26
    $display->override_option('style_plugin', $this->getStylePluginName());
27
    $display->override_option('path', $path);
28
29
    $expected = '[ID]
30
31
1
32
[Name]
33
34
John
35
[Age]
36
37
25
38
----------------------------------------
39
40
[ID]
41
42
2
43
[Name]
44
45
George
46
[Age]
47
48
27
49
----------------------------------------
50
51
[ID]
52
53
3
54
[Name]
55
56
Ringo
57
[Age]
58
59
28
60
----------------------------------------
61
62
[ID]
63
64
4
65
[Name]
66
67
Paul
68
[Age]
69
70
26
71
----------------------------------------
72
73
[ID]
74
75
5
76
[Name]
77
78
Meredith
79
[Age]
80
81
30
82
----------------------------------------';
83
84
    return array(&$view, $expected);
85
  }
86
87
  /**
88
   * Test to check if empty fields are correctly hidden.
89
   */
90
  protected function testHideEmptySupport() {
91
    $view = $this->getHideIfEmptyExportView();
92
93
    // We need to ensure that the test fields are actually empty/0.
94
    db_update('views_test')
95
      ->fields(array('age' => 0,))
96
      ->condition('name', 'Paul')
97
      ->execute();
98
99
    db_update('views_test')
100
      ->fields(array('name' => '',))
101
      ->condition('name', 'George')
102
      ->execute();
103
104
    db_update('views_test')
105
      ->fields(array('name' => 0,))
106
      ->condition('name', 'John')
107
      ->execute();
108
109
    $expected = '[ID]
110
111
1
112
[Name]
113
114
0
115
[Age]
116
117
25
118
----------------------------------------
119
120
[ID]
121
122
2
123
[Age]
124
125
27
126
----------------------------------------
127
128
[ID]
129
130
3
131
[Name]
132
133
Ringo
134
[Age]
135
136
28
137
----------------------------------------
138
139
[ID]
140
141
4
142
[Name]
143
144
Paul
145
----------------------------------------
146
147
[ID]
148
149
5
150
[Name]
151
152
Meredith
153
[Age]
154
155
30
156
----------------------------------------';
157
158
    $message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
159
160
    $this->executeAndCompareGivenView($view, $expected, $message);
161
162
  }
163
164
}