TemplateSectionTest::testAddParameterReturnsTrue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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();
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...
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();
0 ignored issues
show
Bug introduced by
The call to FakeCMSSite::__construct() misses a required argument $kernel.

This check looks for function calls that miss required arguments.

Loading history...
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()
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...
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()
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...
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));
0 ignored issues
show
Unused Code introduced by
The call to CMS_TemplateSection::delete() has too many arguments starting with $data.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
60
    }
61
}
62