1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2012 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Controller\Frontend\Catalog; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
private $context; |
16
|
|
|
private $object; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() |
20
|
|
|
{ |
21
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
22
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Catalog\Standard( $this->context ); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
protected function tearDown() |
27
|
|
|
{ |
28
|
|
|
unset( $this->object, $this->context ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
public function testCompare() |
33
|
|
|
{ |
34
|
|
|
$list = $this->object->compare( '==', 'catalog.code', 'categories' )->getTree()->toList(); |
35
|
|
|
$this->assertEquals( 1, count( $list ) ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testFind() |
40
|
|
|
{ |
41
|
|
|
$item = $this->object->uses( ['product'] )->find( 'cafe' ); |
42
|
|
|
|
43
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Catalog\Item\Iface::class, $item ); |
44
|
|
|
$this->assertEquals( 2, count( $item->getRefItems( 'product' ) ) ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
public function testGet() |
49
|
|
|
{ |
50
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'catalog' )->findItem( 'cafe' ); |
51
|
|
|
$item = $this->object->uses( ['product'] )->get( $item->getId() ); |
52
|
|
|
|
53
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Catalog\Item\Iface::class, $item ); |
54
|
|
|
$this->assertEquals( 2, count( $item->getRefItems( 'product' ) ) ); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
public function testGetPath() |
59
|
|
|
{ |
60
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'catalog' )->findItem( 'cafe', [] ); |
61
|
|
|
$items = $this->object->uses( ['product'] )->getPath( $item->getId() ); |
62
|
|
|
|
63
|
|
|
$this->assertEquals( 3, count( $items ) ); |
64
|
|
|
$this->assertEquals( 2, count( current( array_reverse( $items, true ) )->getRefItems( 'product' ) ) ); |
65
|
|
|
|
66
|
|
|
foreach( $items as $item ) { |
67
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Catalog\Item\Iface::class, $item ); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
public function testGetTree() |
73
|
|
|
{ |
74
|
|
|
$tree = $this->object->uses( ['product'] )->getTree(); |
75
|
|
|
|
76
|
|
|
foreach( $tree->toList() as $item ) { |
77
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Catalog\Item\Iface::class, $item ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$this->assertEquals( 2, count( $tree->getChildren() ) ); |
81
|
|
|
$this->assertEquals( 4, count( current( array_reverse( $tree->toList(), true ) )->getRefItems( 'product' ) ) ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
public function testParse() |
86
|
|
|
{ |
87
|
|
|
$cond = ['>' => ['catalog.status' => 0]]; |
88
|
|
|
$this->assertEquals( 8, count( $this->object->parse( $cond )->getTree()->toList() ) ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
public function testRoot() |
93
|
|
|
{ |
94
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'catalog' ); |
95
|
|
|
|
96
|
|
|
$root = $manager->findItem( 'categories' ); |
97
|
|
|
$item = $manager->findItem( 'cafe' ); |
98
|
|
|
|
99
|
|
|
$this->assertEquals( 2, count( $this->object->root( $root->getId() )->getPath( $item->getId() ) ) ); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
public function testSearch() |
104
|
|
|
{ |
105
|
|
|
$total = 0; |
106
|
|
|
$items = $this->object->uses( ['product'] )->compare( '==', 'catalog.code', 'cafe' )->search( $total ); |
107
|
|
|
|
108
|
|
|
$this->assertCount( 1, $items ); |
109
|
|
|
$this->assertEquals( 2, count( current( $items )->getRefItems( 'product' ) ) ); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
public function testUses() |
114
|
|
|
{ |
115
|
|
|
$this->assertSame( $this->object, $this->object->uses( ['text'] ) ); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
public function testVisible() |
120
|
|
|
{ |
121
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'catalog' ); |
122
|
|
|
|
123
|
|
|
$root = $manager->findItem( 'root' ); |
124
|
|
|
$item = $manager->findItem( 'cafe' ); |
125
|
|
|
$catIds = array_keys( $manager->getPath( $item->getId() ) ); |
126
|
|
|
|
127
|
|
|
$result = $this->object->root( $root->getId() )->visible( $catIds )->getTree(); |
128
|
|
|
|
129
|
|
|
$this->assertEquals( 6, count( $result->toList() ) ); |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths