|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2022 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Base\View\Helper\Site; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $object; |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
protected function setUp() : void |
|
18
|
|
|
{ |
|
19
|
|
|
$view = new \Aimeos\Base\View\Standard(); |
|
20
|
|
|
$view->pageSiteItem = new TestSite( '1.', 'label1' ); |
|
21
|
|
|
|
|
22
|
|
|
$this->object = new \Aimeos\Base\View\Helper\Site\Standard( $view ); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
protected function tearDown() : void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->object = null; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
public function testTransform() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->assertInstanceOf( '\\Aimeos\\Base\\View\\Helper\\Site\\Iface', $this->object->transform() ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
public function testCan() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->assertEquals( true, $this->object->transform()->can( '1.' ) ); |
|
41
|
|
|
$this->assertEquals( true, $this->object->transform()->can( '1.2.' ) ); |
|
42
|
|
|
$this->assertEquals( false, $this->object->transform()->can( '3.' ) ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
public function testLabel() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->assertEquals( 'label1', $this->object->transform()->label() ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testMatch() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->assertEquals( 'label1', $this->object->transform()->match( '1.' ) ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
public function testReadonly() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->assertEquals( 'readonly', $this->object->transform()->readonly( '1.2.' ) ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
public function testSiteid() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->assertEquals( '1.', $this->object->transform()->siteid() ); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
class TestSite |
|
72
|
|
|
{ |
|
73
|
|
|
private $id; |
|
74
|
|
|
private $label; |
|
75
|
|
|
|
|
76
|
|
|
public function __construct( $id, $label ) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->id = $id; |
|
79
|
|
|
$this->label = $label; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getSiteId() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->id; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getLabel() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->label; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|