Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/tests/views_view.test | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Definition of ViewsViewTest.
|
|
5 |
* Views class tests.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Views class tests. |
|
10 | 9 |
* |
11 |
* @codingStandardsIgnoreStart |
|
12 | 10 |
*/ |
13 | 11 |
class ViewsViewTest extends ViewsSqlTest { |
14 |
// @codingStandardsIgnoreEnd |
|
12 |
|
|
13 |
/** |
|
14 |
* Provide the test's meta information. |
|
15 |
*/ |
|
15 | 16 |
public static function getInfo() { |
16 | 17 |
return array( |
17 | 18 |
'name' => 'Test the view class', |
18 |
'description' => 'Tests some functionality of the view class',
|
|
19 |
'description' => 'Tests some functionality of the view class', |
|
19 | 20 |
'group' => 'Views', |
20 | 21 |
); |
21 | 22 |
} |
22 | 23 |
|
23 | 24 |
/** |
24 |
* Tests the deconstructor to be sure that every kind of heavy objects are removed.
|
|
25 |
* Ensure that every kind of heavy objects are removed by the destructor.
|
|
25 | 26 |
*/ |
26 | 27 |
function testDestroy() { |
27 | 28 |
$view = $this->view_test_destroy(); |
... | ... | |
39 | 40 |
$this->assertViewDestroy($view); |
40 | 41 |
} |
41 | 42 |
|
43 |
/** |
|
44 |
* Assert that a given view is destroyed properly. |
|
45 |
* |
|
46 |
* @param object $view |
|
47 |
* The view to destroy. |
|
48 |
*/ |
|
42 | 49 |
function assertViewDestroy($view) { |
43 | 50 |
$this->assertFalse(isset($view->display['default']->handler), 'Make sure all displays are destroyed.'); |
44 | 51 |
$this->assertFalse(isset($view->display['attachment_1']->handler), 'Make sure all displays are destroyed.'); |
... | ... | |
61 | 68 |
$this->assertEqual($view->attachment_after, ''); |
62 | 69 |
} |
63 | 70 |
|
71 |
/** |
|
72 |
* Test deleting a view. |
|
73 |
*/ |
|
64 | 74 |
function testDelete() { |
65 |
// Delete a database view |
|
75 |
// Delete a database view.
|
|
66 | 76 |
$view = $this->view_test_delete(); |
67 | 77 |
$view->save(); |
68 | 78 |
$view = views_get_view($view->name); |
... | ... | |
75 | 85 |
$this->assertNull($view, "Make sure that the old view gets cleared by the reset parameter."); |
76 | 86 |
} |
77 | 87 |
|
88 |
/** |
|
89 |
* Test validation. |
|
90 |
*/ |
|
78 | 91 |
function testValidate() { |
79 | 92 |
// Test a view with multiple displays. |
80 | 93 |
// Validating a view shouldn't change the active display. |
81 |
// @todo: Create an extra validation view.
|
|
94 |
// @todo Create an extra validation view. |
|
82 | 95 |
$view = $this->view_test_destroy(); |
83 | 96 |
$view->set_display('page_1'); |
84 | 97 |
|
... | ... | |
86 | 99 |
|
87 | 100 |
$this->assertEqual('page_1', $view->current_display, "The display should be constant while validating"); |
88 | 101 |
|
89 |
// @todo: Write real tests for the validation.
|
|
102 |
// @todo Write real tests for the validation. |
|
90 | 103 |
// In general the following things could be tested: |
91 |
// - Deleted displays shouldn't be validated |
|
104 |
// - Deleted displays shouldn't be validated.
|
|
92 | 105 |
// - Multiple displays are validating and the errors are merged together. |
93 | 106 |
} |
94 | 107 |
|
95 | 108 |
/** |
96 |
* This view provides some filters, fields, arguments, relationships, sorts, areas and attachments. |
|
109 |
* Generate an example view. |
|
110 |
* |
|
111 |
* Includes: |
|
112 |
* filters, fields, arguments, relationships, sorts, areas and attachments. |
|
97 | 113 |
*/ |
98 | 114 |
function view_test_destroy() { |
99 |
$view = new view; |
|
115 |
$view = new view();
|
|
100 | 116 |
$view->name = 'test_destroy'; |
101 | 117 |
$view->description = ''; |
102 | 118 |
$view->tag = ''; |
... | ... | |
257 | 273 |
|
258 | 274 |
return $view; |
259 | 275 |
} |
276 |
|
|
277 |
/** |
|
278 |
* Creates a test view. |
|
279 |
*/ |
|
260 | 280 |
function view_test_delete() { |
261 |
$view = new view; |
|
281 |
$view = new view();
|
|
262 | 282 |
$view->name = 'test_view_delete'; |
263 | 283 |
$view->description = ''; |
264 | 284 |
$view->tag = ''; |
... | ... | |
294 | 314 |
|
295 | 315 |
return $view; |
296 | 316 |
} |
317 |
|
|
297 | 318 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules