AssetsTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testCreate() 0 26 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Form\Factory\PageLayout;
6
7
use AbterPhp\Website\Domain\Entities\PageLayout as Entity;
8
use PHPUnit\Framework\TestCase;
9
10
class AssetsTest extends TestCase
11
{
12
    /** @var Assets - System Under Test */
13
    protected $sut;
14
15
    public function setUp(): void
16
    {
17
        parent::setUp();
18
19
        $this->sut = new Assets();
20
    }
21
22
    public function testCreate()
23
    {
24
        $id         = 'bde8a749-b409-43c6-a061-c6a7d2dce6a0';
25
        $name       = 'Foo';
26
        $identifier = 'foo';
27
        $header     = 'bar';
28
        $footer     = 'baz';
29
        $cssFiles   = ['qux', 'quux'];
30
        $jsFiles    = ['poic', 'yozz'];
31
        $body       = 'pior';
32
33
        $assets = new Entity\Assets($identifier, $header, $footer, $cssFiles, $jsFiles);
34
        $entity = new Entity($id, $name, $identifier, '', $body, $assets);
35
36
        $actualResult = $this->sut->create($entity);
37
38
        $this->assertIsArray($actualResult);
39
40
        $html = '';
41
        foreach ($actualResult as $item) {
42
            $html .= (string)$item;
43
        }
44
        $this->assertStringContainsString('header', $html);
45
        $this->assertStringContainsString('footer', $html);
46
        $this->assertStringContainsString('css-files', $html);
47
        $this->assertStringContainsString('js-files', $html);
48
    }
49
}
50