|
1
|
|
|
<?php |
|
2
|
|
|
require_once 'CMSStubs.php'; |
|
3
|
|
|
require_once 'Intraface/modules/cms/Section.php'; |
|
4
|
|
|
|
|
5
|
|
|
define('PATH_CACHE', './'); |
|
6
|
|
|
|
|
7
|
|
|
class Testable_CMS_Section_LongText extends Intraface_modules_cms_section_Longtext |
|
8
|
|
|
{ |
|
9
|
|
|
function getTemplateSection() |
|
10
|
|
|
{ |
|
11
|
|
|
return new FakeCMSTemplateSection($this->kernel); |
|
12
|
|
|
} |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
class SectionLongTextTest extends PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
private $kernel; |
|
19
|
|
|
private $page; |
|
20
|
|
|
protected $db; |
|
21
|
|
|
|
|
22
|
|
|
function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->db = MDB2::singleton(DB_DSN); |
|
25
|
|
|
|
|
26
|
|
|
$this->kernel = new Stub_Kernel; |
|
27
|
|
|
$this->kernel->setting->set('user', 'htmleditor', 'someeditor'); |
|
28
|
|
|
$this->site = new FakeCMSSite($this->kernel); |
|
|
|
|
|
|
29
|
|
|
$this->page = new FakeCMSPage($this->site); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function tearDown() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->db->exec('TRUNCATE cms_section'); |
|
35
|
|
|
$this->db->exec('TRUNCATE cms_template'); |
|
36
|
|
|
$this->db->exec('TRUNCATE cms_template_section'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function testConstruction() |
|
40
|
|
|
{ |
|
41
|
|
|
$section = new Testable_CMS_Section_LongText($this->page); |
|
42
|
|
|
$this->assertTrue(is_object($section)); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function testSaveReturnsTrue() |
|
46
|
|
|
{ |
|
47
|
|
|
$section = new Testable_CMS_Section_LongText($this->page); |
|
48
|
|
|
$section->getParameter(); |
|
49
|
|
|
$data = array('type_key' => 1, 'template_section_id' => 1); |
|
50
|
|
|
$section->save($data); |
|
51
|
|
|
$section->template_section = new FakeCMSTemplateSection($this->kernel); |
|
52
|
|
|
$data = array('text' => 'Some text'); |
|
53
|
|
|
$section->save_section($data); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
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: