SectionLongTextTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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);
0 ignored issues
show
Bug introduced by
The property site does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
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