|
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
|
|
|
} |