1
|
|
|
<?php |
2
|
|
|
require_once 'CMSStubs.php'; |
3
|
|
|
require_once 'Intraface/modules/cms/Element.php'; |
4
|
|
|
|
5
|
|
|
class PageElementTest extends PHPUnit_Framework_TestCase |
6
|
|
|
{ |
7
|
|
|
private $pagelist; |
8
|
|
|
|
9
|
|
View Code Duplication |
function setUp() |
|
|
|
|
10
|
|
|
{ |
11
|
|
|
$kernel = new Stub_Kernel(); |
12
|
|
|
$site = new FakeCMSSite($kernel); |
13
|
|
|
$page = new FakeCMSPage($site); |
14
|
|
|
$section = new FakeCMSSection($page); |
15
|
|
|
$this->pagelist = new Intraface_modules_cms_element_Pagelist($section); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
function tearDown() |
19
|
|
|
{ |
20
|
|
|
unset($this->pagelist); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
function testConstruction() |
24
|
|
|
{ |
25
|
|
|
$this->assertTrue(is_object($this->pagelist)); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
View Code Duplication |
function testSave() |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$data = array( |
31
|
|
|
'elm_properties' => 'none', |
32
|
|
|
'elm_adjust' => 'left', |
33
|
|
|
'elm_width' => '100px', |
34
|
|
|
'headline' => 'Test', |
35
|
|
|
'show_type' => 'article', |
36
|
|
|
'keyword' => array(1), |
37
|
|
|
'show' => 1, |
38
|
|
|
'lifetime' => 20, |
39
|
|
|
'no_results_text' => 'none', |
40
|
|
|
'read_more_text' => 'none' |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
$this->assertTrue($this->pagelist->save($data) > 0); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function testSaveWhenUpdating() |
47
|
|
|
{ |
48
|
|
|
$data = array( |
49
|
|
|
'elm_properties' => 'none', |
50
|
|
|
'elm_adjust' => 'left', |
51
|
|
|
'elm_width' => '100px', |
52
|
|
|
'headline' => 'Test', |
53
|
|
|
'show_type' => 'article', |
54
|
|
|
'keyword' => array(1), |
55
|
|
|
'show' => 1, |
56
|
|
|
'lifetime' => 20, |
57
|
|
|
'no_results_text' => 'none', |
58
|
|
|
'read_more_text' => 'none' |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
$this->assertTrue($this->pagelist->save($data) > 0); |
62
|
|
|
|
63
|
|
|
$data = array( |
64
|
|
|
'elm_properties' => 'none', |
65
|
|
|
'elm_adjust' => 'left', |
66
|
|
|
'elm_width' => '100px', |
67
|
|
|
'headline' => 'Test', |
68
|
|
|
'show_type' => 'article', |
69
|
|
|
'keyword' => array(1), |
70
|
|
|
'show' => 1, |
71
|
|
|
'lifetime' => 20, |
72
|
|
|
'no_results_text' => 'none', |
73
|
|
|
'read_more_text' => 'none' |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
$this->assertTrue($this->pagelist->save($data) > 0); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
View Code Duplication |
function testValidateFailsWhenInvalidValues() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
$data = array( |
82
|
|
|
'elm_properties' => 'wrongvalue', |
83
|
|
|
'elm_adjust' => 'wrongvalue', |
84
|
|
|
'elm_width' => '100wrongvalue', |
85
|
|
|
'elm_box' => 'wrongvalue', |
86
|
|
|
'headline' => 'Test', |
87
|
|
|
'show_type' => 'article', |
88
|
|
|
'keyword' => array(1), |
89
|
|
|
'show' => 1, |
90
|
|
|
'lifetime' => 20, |
91
|
|
|
'no_results_text' => 'none', |
92
|
|
|
'read_more_text' => 'none' |
93
|
|
|
); |
94
|
|
|
|
95
|
|
|
$this->assertTrue($this->pagelist->save($data) == 0); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
function testDeleteReturnsTrue() |
99
|
|
|
{ |
100
|
|
|
$this->assertTrue($this->pagelist->delete()); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
function testUnDeleteReturnsTrue() |
104
|
|
|
{ |
105
|
|
|
$this->assertTrue($this->pagelist->delete()); |
106
|
|
|
$this->assertTrue($this->pagelist->undelete()); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.