|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2021 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Site; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $context; |
|
15
|
|
|
private $object; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
protected function setUp() : void |
|
19
|
|
|
{ |
|
20
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
|
21
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Site\Standard( $this->context ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
protected function tearDown() : void |
|
26
|
|
|
{ |
|
27
|
|
|
unset( $this->object, $this->context ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
public function testCompare() |
|
32
|
|
|
{ |
|
33
|
|
|
$list = $this->object->compare( '==', 'locale.site.status', 1 )->getTree()->toList(); |
|
34
|
|
|
$this->assertGreaterThanOrEqual( 1, count( $list ) ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
public function testFind() |
|
39
|
|
|
{ |
|
40
|
|
|
$item = $this->object->find( 'unittest' ); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
public function testGet() |
|
47
|
|
|
{ |
|
48
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest' ); |
|
49
|
|
|
$item = $this->object->get( $item->getId() ); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item ); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
public function testGetPath() |
|
56
|
|
|
{ |
|
57
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest', [] ); |
|
58
|
|
|
$items = $this->object->getPath( $item->getId() ); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertGreaterThanOrEqual( 1, count( $items ) ); |
|
61
|
|
|
|
|
62
|
|
|
foreach( $items as $item ) { |
|
63
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item ); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
public function testGetTree() |
|
69
|
|
|
{ |
|
70
|
|
|
$tree = $this->object->getTree(); |
|
71
|
|
|
|
|
72
|
|
|
foreach( $tree->toList() as $item ) { |
|
73
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item ); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$this->assertGreaterThanOrEqual( 1, count( $tree->toList() ) ); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
public function testParse() |
|
81
|
|
|
{ |
|
82
|
|
|
$cond = ['>' => ['locale.site.status' => 0]]; |
|
83
|
|
|
$this->assertGreaterThanOrEqual( 1, count( $this->object->parse( $cond )->getTree()->toList() ) ); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
public function testRoot() |
|
88
|
|
|
{ |
|
89
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest' ); |
|
90
|
|
|
|
|
91
|
|
|
$this->assertGreaterThanOrEqual( 1, count( $this->object->root( $item->getId() )->getPath( $item->getId() ) ) ); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
public function testSearch() |
|
96
|
|
|
{ |
|
97
|
|
|
$total = 0; |
|
98
|
|
|
$items = $this->object->compare( '==', 'locale.site.code', 'unittest' )->search( $total ); |
|
99
|
|
|
|
|
100
|
|
|
$this->assertCount( 1, $items ); |
|
101
|
|
|
$this->assertEquals( 1, $total ); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
public function testSlice() |
|
106
|
|
|
{ |
|
107
|
|
|
$this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) ); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
public function testSort() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'locale.site.label' )->search() ) ); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|