GalleryElementTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 21.05 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 8
loc 38
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 8 8 1
A tearDown() 0 4 1
A testConstruction() 0 4 1
A testSave() 0 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
require_once 'CMSStubs.php';
3
require_once 'Intraface/modules/cms/Element.php';
4
require_once 'Intraface/modules/cms/element/Gallery.php';
5
6
class GalleryElementTest extends PHPUnit_Framework_TestCase
7
{
8
    private $gallery;
9
10 View Code Duplication
    function setUp()
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...
11
    {
12
        $kernel = new Stub_Kernel();
13
        $site = new FakeCMSSite($kernel);
14
        $page = new FakeCMSPage($site);
15
        $section = new FakeCMSSection($page);
16
        $this->gallery = new Intraface_modules_cms_element_Gallery($section);
17
    }
18
19
    function tearDown()
20
    {
21
        unset($this->gallery);
22
    }
23
24
    function testConstruction()
25
    {
26
        $this->assertTrue(is_object($this->gallery));
27
    }
28
29
    function testSave()
30
    {
31
        $data = array(
32
            'elm_properties' => 'none',
33
            'elm_adjust' => 'left',
34
            'elm_width' => '100px',
35
            'gallery_select_method' => 'single_image',
36
            'thumbnail_size' => 'small',
37
            'popup_size' => 'medium',
38
            'show_description' => true
39
        );
40
41
        $this->assertTrue($this->gallery->save($data) > 0);
42
    }
43
}
44