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

SectionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_getURL() 0 6 1
A test_visibleIn() 0 7 1
A initRequest() 0 11 1
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
}