1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Xpressengine\Skin; |
4
|
|
|
|
5
|
|
|
function view($view = null, $data = [], $mergeData = []) |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
return $view; |
8
|
|
|
} |
9
|
|
|
|
10
|
|
|
namespace Xpressengine\Tests\Skin; |
11
|
|
|
|
12
|
|
|
use Xpressengine\Skin\BladeSkin; |
|
|
|
|
13
|
|
|
|
14
|
|
|
class BladeSkinTest extends \PHPUnit_Framework_TestCase |
15
|
|
|
{ |
16
|
|
View Code Duplication |
public function testRender() |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
$skin = new TestBladeSkin(); |
19
|
|
|
$data = 'data'; |
20
|
|
|
$ret = $skin->setView('view')->setData($data)->render(); |
21
|
|
|
|
22
|
|
|
$this->assertEquals('my.path.view', $ret); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testPath() |
26
|
|
|
{ |
27
|
|
|
$skin = new TestBladeSkin(); |
28
|
|
|
|
29
|
|
|
$this->assertEquals('my.path', $skin->getSkinPath()); |
30
|
|
|
$this->assertEquals('my.path.a.b', $skin->getSkinPath('a.b')); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testRenderUsingMethod() |
34
|
|
|
{ |
35
|
|
|
$skin = new TestBladeSkin(); |
36
|
|
|
$skin->setView('my.list'); |
37
|
|
|
$this->assertEquals('my.list', $skin->render()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @expectedException \Xpressengine\Skin\Exceptions\PathNotAssignedException |
42
|
|
|
*/ |
43
|
|
|
public function testPathWhenPathNotAssigned() |
44
|
|
|
{ |
45
|
|
|
$skin = new TestBladeSkinNotAssignPath(); |
46
|
|
|
$skin->getSkinPath(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @expectedException \Xpressengine\Skin\Exceptions\PathNotAssignedException |
51
|
|
|
*/ |
52
|
|
|
public function testRenderWhenPathNotAssigned() |
53
|
|
|
{ |
54
|
|
|
$skin = new TestBladeSkinNotAssignPath(); |
55
|
|
|
$skin->setView('list')->render(); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
class TestBladeSkin extends BladeSkin |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
protected static $id = 'test.skin'; |
62
|
|
|
protected $path = 'my.path'; |
63
|
|
|
|
64
|
|
|
protected function myList($view) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
return 'my.list'; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
class TestBladeSkinNotAssignPath extends BladeSkin |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
protected static $id = 'test.skin'; |
73
|
|
|
} |
74
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.