Passed
Pull Request — master (#1)
by Korotkov
01:49
created

DecoratorTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 36
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getComponent() 0 3 1
A testComponent() 0 3 1
A setUp() 0 3 1
A testXmlDecorator() 0 4 1
A testJsonDecorator() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @copyright Copyright (c) 2018, Korotkov Danila
8
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
9
 */
10
11
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Structural\Decorator\Component;
13
use Structural\Decorator\XmlDecorator;
14
use Structural\Decorator\JsonDecorator;
15
16
17
/**
18
 * Class DecoratorTest
19
 */
20
class DecoratorTest extends PHPUnit_Framework_TestCase
21
{
22
23
    /**
24
     * @var Component
25
     */
26
    protected $component;
27
28
    protected function setUp(): void
29
    {
30
        $this->component = new Component('key', 'value');
31
    }
32
33
    public function testComponent()
34
    {
35
        $this->assertCount(1, $this->getComponent()->getData());
36
    }
37
38
    public function testXmlDecorator()
39
    {
40
        $xmlDecorator = new XmlDecorator($this->getComponent());
41
        $this->assertEquals("<?xml version=\"1.0\"?>\n<root><key>value</key></root>\n", $xmlDecorator->getData());
42
    }
43
44
    public function testJsonDecorator()
45
    {
46
        $jsonDecorator = new JsonDecorator($this->getComponent());
47
        $this->assertEquals('{"key":"value"}', $jsonDecorator->getData());
48
    }
49
50
    /**
51
     * @return mixed
52
     */
53
    public function getComponent()
54
    {
55
        return $this->component;
56
    }
57
}
58