Passed
Push — master ( 3be634...c73837 )
by Gabriel
01:57
created

SectionTest::test_visibleIn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
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_getURL()
25
    {
26
        $this->initRequest();
27
        $section = new Section();
28
29
        self::assertSame('http://mydomain.com/subfolder', $section->getURL());
30
    }
31
32
    protected function initRequest()
33
    {
34
        $server = [
35
            'HTTP_HOST' => 'mydomain.com',
36
            'SCRIPT_FILENAME' => '/home/app/subfolder/index.php',
37
            'SCRIPT_NAME' => '/subfolder/index.php',
38
            'REQUEST_URI' => '/subfolder/',
39
        ];
40
        $request = new \Nip\Http\Request([], [], [], [], [], $server);
41
42
        Container::getInstance()->set('request', $request);
43
    }
44
}