Completed
Pull Request — master (#6)
by Paweł
05:54
created

HtmlWidgetTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 23
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testcheckingVisibility() 0 4 1
A testRendering() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Templates System
5
 *
6
 * Copyright 2015 Sourcefabric z.u. 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\TemplatesSystem\Tests\Gimme\Container;
16
17
use SWP\TemplatesSystem\Tests\Gimme\Model\Widget;
18
use SWP\TemplatesSystem\Gimme\Widget\HtmlWidget;
19
20
class HtmlWidgetTest extends \PHPUnit_Framework_TestCase
21
{
22
    private $container;
0 ignored issues
show
Unused Code introduced by
The property $container is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
23
24
    public function setUp()
25
    {
26
    	$widgetEntity = new Widget();
27
    	$widgetEntity->setId(1);
28
        $widgetEntity->setParameters(['html_body' => 'simple html body']);
29
30
        $this->widget = new HtmlWidget($widgetEntity);
0 ignored issues
show
Bug introduced by
The property widget 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...
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