1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpCacheGUITest\Unit\Presentation; |
4
|
|
|
|
5
|
|
|
use OpCacheGUI\I18n\Translator; |
6
|
|
|
use OpCacheGUITest\Mocks\Presentation\TemplateMock; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
class TemplateTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @covers OpCacheGUI\Presentation\Template::__construct |
13
|
|
|
*/ |
14
|
|
|
public function testConstructCorrectInterface() |
15
|
|
|
{ |
16
|
|
|
$template = new TemplateMock(__DIR__, $this->createMock(Translator::class)); |
17
|
|
|
|
18
|
|
|
$this->assertInstanceOf('\\OpCacheGUI\\Presentation\\Renderer', $template); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @covers OpCacheGUI\Presentation\Template::__construct |
23
|
|
|
* @covers OpCacheGUI\Presentation\Template::__get |
24
|
|
|
*/ |
25
|
|
|
public function testMagicGetExists() |
26
|
|
|
{ |
27
|
|
|
$template = new TemplateMock(__DIR__, $this->createMock(Translator::class)); |
28
|
|
|
|
29
|
|
|
$template->set('foo', 'bar'); |
30
|
|
|
|
31
|
|
|
$this->assertSame('bar', $template->foo); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @covers OpCacheGUI\Presentation\Template::__construct |
36
|
|
|
* @covers OpCacheGUI\Presentation\Template::__get |
37
|
|
|
*/ |
38
|
|
|
public function testMagicGetDoesNotExist() |
39
|
|
|
{ |
40
|
|
|
$template = new TemplateMock(__DIR__, $this->createMock(Translator::class)); |
41
|
|
|
|
42
|
|
|
$this->assertNull($template->foo); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @covers OpCacheGUI\Presentation\Template::__construct |
47
|
|
|
* @covers OpCacheGUI\Presentation\Template::__isset |
48
|
|
|
*/ |
49
|
|
|
public function testMagicIssetExists() |
50
|
|
|
{ |
51
|
|
|
$template = new TemplateMock(__DIR__, $this->createMock(Translator::class)); |
52
|
|
|
|
53
|
|
|
$template->set('foo', 'bar'); |
54
|
|
|
|
55
|
|
|
$this->assertTrue(isset($template->foo)); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @covers OpCacheGUI\Presentation\Template::__construct |
60
|
|
|
* @covers OpCacheGUI\Presentation\Template::__isset |
61
|
|
|
*/ |
62
|
|
|
public function testMagicIssetDoesNotExist() |
63
|
|
|
{ |
64
|
|
|
$template = new TemplateMock(__DIR__, $this->createMock(Translator::class)); |
65
|
|
|
|
66
|
|
|
$this->assertFalse(isset($template->foo)); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|