Completed
Push — master ( e3663d...ab0db8 )
by Alex
03:22
created

ViewStaticUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 33
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRender() 0 13 1
A testEmptyBlockName() 0 9 1
1
<?php
2
namespace Mezon\Application\Tests;
3
4
use Mezon\HtmlTemplate\HtmlTemplate;
5
use Mezon\Application\ViewStatic;
6
use PHPUnit\Framework\TestCase;
7
8
class ViewStaticUnitTest extends TestCase
9
{
10
11
    /**
12
     * Testing constructor
13
     */
14
    public function testRender(): void
15
    {
16
        // setup
17
        $template = new HtmlTemplate(__DIR__ . '/res/');
18
        $template->setPageVar('block', 'BLOCK!!!');
19
        $view = new ViewStatic($template, 'block');
20
21
        // test body
22
        $content = $view->render();
23
24
        // assertions
25
        $this->assertEquals('some BLOCK!!! {unexisting-var}', $content);
26
        $this->assertEquals('block', $view->getViewName());
27
    }
28
29
    /**
30
     * Testing unexisting block renderring
31
     */
32
    public function testEmptyBlockName(): void
33
    {
34
        // setup
35
        $this->expectException(\Exception::class);
36
        $template = new HtmlTemplate(__DIR__ . '/res/');
37
        $view = new ViewStatic($template);
38
39
        // test body and assertions
40
        $view->render();
41
    }
42
}
43