1
|
|
|
<?php |
2
|
|
|
require_once 'CMSStubs.php'; |
3
|
|
|
require_once 'Intraface/Kernel.php'; |
4
|
|
|
require_once 'Intraface/modules/cms/TemplateSection.php'; |
5
|
|
|
|
6
|
|
|
class TemplateSectionTest extends PHPUnit_Framework_TestCase |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
function setUp() |
10
|
|
|
{ |
11
|
|
|
$this->kernel = $this->createKernel(); |
|
|
|
|
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
function createKernel() |
15
|
|
|
{ |
16
|
|
|
$this->kernel = new Stub_Intranet; |
17
|
|
|
|
18
|
|
|
return $this->kernel; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function createTemplate() |
22
|
|
|
{ |
23
|
|
|
return new FakeCMSTemplate(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
function createSite() |
27
|
|
|
{ |
28
|
|
|
return new FakeCMSSite(); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function testConstruction() |
32
|
|
|
{ |
33
|
|
|
$site = new CMS_TemplateSection($this->createTemplate()); |
34
|
|
|
$this->assertTrue(is_object($site)); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
function testSaveReturnsInteger() |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$section = new CMS_TemplateSection($this->createTemplate()); |
40
|
|
|
$section->value['type_key'] = 1; |
41
|
|
|
$data = array('identifier' => uniqid(), 'name' => 'name'); |
42
|
|
|
$this->assertTrue($section->save($data) > 0); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function testAddParameterReturnsTrue() |
46
|
|
|
{ |
47
|
|
|
$section = new CMS_TemplateSection($this->createTemplate()); |
48
|
|
|
$section->value['type_key'] = 1; |
49
|
|
|
$data = array('identifier' => uniqid(), 'name' => 'name'); |
50
|
|
|
$this->assertTrue($section->save($data) > 0); |
51
|
|
|
$this->assertTrue($section->addParameter('test', 'test')); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
View Code Duplication |
function testDelete() |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
$section = new CMS_TemplateSection($this->createTemplate()); |
57
|
|
|
$section->value['type_key'] = 1; |
58
|
|
|
$data = array('identifier' => uniqid(), 'name' => 'name'); |
59
|
|
|
$this->assertTrue($section->delete($data)); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: