Completed
Push — master ( 64f114...82d9eb )
by Korotkov
02:36 queued 17s
created

AbstractFactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 9
c 4
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testXML() 0 8 1
A testJson() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author  : Jagepard <[email protected]>
7
 * @license https://mit-license.org/ MIT
8
 */
9
10
namespace Creational\AbstractFactory\Tests;
11
12
use Creational\AbstractFactory\XMLFactory;
13
use Creational\AbstractFactory\JsonFactory;
14
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
15
16
class AbstractFactoryTest extends PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @var string
20
     */
21
    private $content = 'Message';
22
23
    public function testJson()
24
    {
25
        $content = \json_encode(['content' => $this->content]);
26
27
        $this->assertEquals((new JsonFactory())->createMessage($this->content), $content);
28
    }
29
30
    public function testXML()
31
    {
32
        $dom = new \DOMDocument("1.0", "utf-8");
33
        $content = $dom->createElement("content", $this->content);
34
        $dom->appendChild($content);
35
        $xmlFactory = new XMLFactory();
36
37
        $this->assertEquals($xmlFactory->createMessage($this->content), $dom->saveXML());
38
    }
39
}
40