Completed
Push — master ( bf375b...cc5661 )
by Rafał
07:07
created

HtmlWidgetTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 29.41 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 10
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testCheckingVisibility() 0 4 1
A testRendering() 0 4 1
A tearDown() 10 10 4

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
3
/**
4
 * This file is part of the Superdesk Web Publisher Templates System.
5
 *
6
 * Copyright 2015 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\TemplatesSystem\Tests\Gimme\Container;
16
17
use SWP\Component\TemplatesSystem\Gimme\Widget\HtmlWidgetHandler;
18
use SWP\Component\TemplatesSystem\Tests\Gimme\Model\WidgetModel;
19
20
class HtmlWidgetTest extends \PHPUnit_Framework_TestCase
21
{
22
    private $widget;
23
24
    public function setUp()
25
    {
26
        $widgetEntity = new WidgetModel();
27
        $widgetEntity->setId(1);
28
        $widgetEntity->setParameters(['html_body' => 'simple html body']);
29
30
        $this->widget = new HtmlWidgetHandler($widgetEntity);
31
    }
32
33
    public function testCheckingVisibility()
34
    {
35
        $this->assertTrue($this->widget->isVisible());
36
    }
37
38
    public function testRendering()
39
    {
40
        $this->assertEquals($this->widget->render(), 'simple html body');
41
    }
42
43 View Code Duplication
    protected function tearDown()
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...
44
    {
45
        $reflection = new \ReflectionObject($this);
46
        foreach ($reflection->getProperties() as $prop) {
47
            if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
0 ignored issues
show
introduced by
Consider using $prop->class. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
48
                $prop->setAccessible(true);
49
                $prop->setValue($this, null);
50
            }
51
        }
52
    }
53
}
54