SiteTest::testSaveSucceedsWithValidValues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
require_once 'CMSStubs.php';
3
require_once 'Intraface/modules/cms/Site.php';
4
5
class SiteTest extends PHPUnit_Framework_TestCase
6
{
7
    protected $db;
8
9
    function setUp()
10
    {
11
        $this->db = MDB2::singleton(DB_DSN);
12
        $this->kernel = $this->createKernel();
0 ignored issues
show
Bug introduced by
The property kernel 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...
13
    }
14
15
    function tearDown()
16
    {
17
        $this->db->exec('TRUNCATE cms_site');
18
    }
19
20
    function createKernel()
21
    {
22
        $this->kernel = new Stub_Kernel;
23
        $this->kernel->setting->set('intranet', 'cms.stylesheet.default', 'some.css');
24
        return $this->kernel;
25
    }
26
27
    function testConstruction()
28
    {
29
        $site = new CMS_Site($this->kernel);
30
        $this->assertTrue(is_object($site));
31
    }
32
33 View Code Duplication
    function testSaveSucceedsWithValidValues()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
34
    {
35
        $site = new CMS_Site($this->kernel);
36
        $site_array = array(
37
            'name' => 'Tester',
38
            'url' => 'http://localhost/',
39
            'cc_license' => '1'
40
        );
41
        $site->save($site_array);
42
        $this->assertEquals($site_array['name'], $site->get('name'));
43
        $this->assertEquals($site_array['url'], $site->get('url'));
44
        $this->assertEquals($site_array['cc_license'], $site->get('cc_license'));
45
    }
46
}
47