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

ViewStaticUnitTest::testRender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 13
rs 10
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