Completed
Push — master ( c73837...66cd91 )
by Gabriel
01:54
created

SectionTest::test_printIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Nip\Mvc\Tests\Sections;
4
5
use Nip\Container\Container;
6
use Nip\Mvc\Sections\Section;
7
use Nip\Mvc\Tests\AbstractTest;
8
9
/**
10
 * Class SectionTest
11
 * @package Nip\Mvc\Tests\Sections
12
 */
13
class SectionTest extends AbstractTest
14
{
15
    public function test_visibleIn()
16
    {
17
        $section = new Section();
18
        $section->writeData(['visibleIn' => ['admin']]);
19
20
        self::assertTrue($section->visibleIn('admin'));
21
        self::assertFalse($section->visibleIn('frontend'));
22
    }
23
24
    public function test_printIcon()
25
    {
26
        $section = new Section();
27
        $section->writeData(['icon' => '<path class="fil0" d="M512 402l0 110" >']);
28
29
        self::assertSame(
30
            '<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"  focusable="false" aria-hidden="true" role="presentation"><path class="fil0" d="M512 402l0 110" ></svg>',
31
            $section->printIcon()
32
        );
33
    }
34
35
    public function test_getURL()
36
    {
37
        $this->initRequest();
38
        $section = new Section();
39
40
        self::assertSame('http://mydomain.com/subfolder', $section->getURL());
41
    }
42
43
    protected function initRequest()
44
    {
45
        $server = [
46
            'HTTP_HOST' => 'mydomain.com',
47
            'SCRIPT_FILENAME' => '/home/app/subfolder/index.php',
48
            'SCRIPT_NAME' => '/subfolder/index.php',
49
            'REQUEST_URI' => '/subfolder/',
50
        ];
51
        $request = new \Nip\Http\Request([], [], [], [], [], $server);
52
53
        Container::getInstance()->set('request', $request);
54
    }
55
}