Completed
Push — master ( 921503...9109fd )
by Aimeos
02:03
created

StandardTest::testFind()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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();
0 ignored issues
show
Bug introduced by
The method toList() does not seem to exist on object<Aimeos\MShop\Catalog\Item\Iface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
		$this->assertEquals( 1, count( $list ) );
36
	}
37
38
39
	public function testGet()
40
	{
41
		$iface = \Aimeos\MShop\Catalog\Item\Iface::class;
42
		$item = \Aimeos\MShop::create( $this->context, 'catalog' )->findItem( 'cafe', [] );
43
44
		$this->assertInstanceOf( $iface, $this->object->get( $item->getId() ) );
45
	}
46
47
48
	public function testGetPath()
49
	{
50
		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
51
		$items = $this->object->getPath( $manager->findItem( 'cafe', [] )->getId() );
52
53
		$this->assertEquals( 3, count( $items ) );
54
55
		foreach( $items as $item ) {
56
			$this->assertInstanceOf( \Aimeos\MShop\Catalog\Item\Iface::class, $item );
57
		}
58
	}
59
60
61
	public function testGetTree()
62
	{
63
		$tree = $this->object->getTree();
64
65
		foreach( $tree->toList() as $item ) {
0 ignored issues
show
Bug introduced by
The method toList() does not seem to exist on object<Aimeos\MShop\Catalog\Item\Iface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
66
			$this->assertInstanceOf( \Aimeos\MShop\Catalog\Item\Iface::class, $item );
67
		}
68
69
		$this->assertEquals( 2, count( $tree->getChildren() ) );
70
	}
71
72
73
	public function testFind()
74
	{
75
		$iface = \Aimeos\MShop\Catalog\Item\Iface::class;
76
		$this->assertInstanceOf( $iface, $this->object->find( 'cafe', [] ) );
77
	}
78
79
80
	public function testParse()
81
	{
82
		$cond = ['>' => ['catalog.status' => 0]];
83
		$this->assertEquals( 8, count( $this->object->parse( $cond )->getTree( [] )->toList() ) );
0 ignored issues
show
Bug introduced by
The method toList() does not seem to exist on object<Aimeos\MShop\Catalog\Item\Iface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84
	}
85
86
87
	public function testRoot()
88
	{
89
		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
90
91
		$root = $manager->findItem( 'categories' );
92
		$item = $manager->findItem( 'cafe' );
93
94
		$this->assertEquals( 2, count( $this->object->root( $root->getId() )->getPath( $item->getId(), [] ) ) );
95
	}
96
97
98
	public function testVisible()
99
	{
100
		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
101
102
		$root = $manager->findItem( 'root' );
103
		$item = $manager->findItem( 'cafe' );
104
		$catIds = array_keys( $manager->getPath( $item->getId() ) );
105
106
		$result = $this->object->root( $root->getId() )->visible( $catIds )->getTree( [] );
107
108
		$this->assertEquals( 6, count( $result->toList() ) );
0 ignored issues
show
Bug introduced by
The method toList() does not seem to exist on object<Aimeos\MShop\Catalog\Item\Iface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
	}
110
}
111