Passed
Push — master ( 216152...7bdf82 )
by Aimeos
02:00
created

StandardTest::testSearch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Supplier;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
	private $object;
15
	private $context;
16
17
18
	protected function setUp()
19
	{
20
		$this->context = \TestHelperFrontend::getContext();
21
		$this->object = new \Aimeos\Controller\Frontend\Supplier\Standard( $this->context );
22
	}
23
24
25
	protected function tearDown()
26
	{
27
		unset( $this->object, $this->context );
28
	}
29
30
31
	public function testCompare()
32
	{
33
		$this->assertEquals( 2, count( $this->object->compare( '=~', 'supplier.label', 'unit' )->search() ) );
34
	}
35
36
37
	public function testFind()
38
	{
39
		$item = $this->object->uses( ['product'] )->find( 'unitCode001' );
40
41
		$this->assertInstanceOf( \Aimeos\MShop\Supplier\Item\Iface::class, $item );
42
		$this->assertEquals( 2, count( $item->getRefItems( 'product' ) ) );
43
	}
44
45
46
	public function testGet()
47
	{
48
		$item = \Aimeos\MShop::create( $this->context, 'supplier' )->findItem( 'unitCode001' );
49
		$item = $this->object->uses( ['product'] )->get( $item->getId() );
50
51
		$this->assertInstanceOf( \Aimeos\MShop\Supplier\Item\Iface::class, $item );
52
		$this->assertEquals( 2, count( $item->getRefItems( 'product' ) ) );
53
	}
54
55
56
	public function testHas()
57
	{
58
		$manager = \Aimeos\MShop::create( $this->context, 'product' );
59
		$prodId = $manager->findItem( 'CNE' )->getId();
60
61
		$this->assertEquals( 1, count( $this->object->has( 'product', 'default', $prodId )->search() ) );
62
	}
63
64
65
	public function testParse()
66
	{
67
		$cond = ['&&' => [['==' => ['supplier.status' => 1]], ['=~' => ['supplier.label' => 'unit']]]];
68
		$this->assertEquals( 2, count( $this->object->parse( $cond )->search() ) );
69
	}
70
71
72
	public function testSearch()
73
	{
74
		$total = 0;
75
		$items = $this->object->uses( ['product'] )->compare( '=~', 'supplier.code', 'unit' )
76
			->sort( 'supplier.code' )->search( $total );
77
78
		$this->assertGreaterThanOrEqual( 2, count( $items ) );
79
		$this->assertGreaterThanOrEqual( 2, $total );
80
		$this->assertEquals( 2, count( current( $items )->getRefItems( 'product' ) ) );
81
	}
82
83
84
	public function testSlice()
85
	{
86
		$this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) );
87
	}
88
89
90
	public function testSort()
91
	{
92
		$this->assertGreaterThanOrEqual( 2, count( $this->object->sort()->search() ) );
93
	}
94
95
96
	public function testSortGeneric()
97
	{
98
		$this->assertGreaterThanOrEqual( 2, count( $this->object->sort( 'supplier.label' )->search() ) );
99
	}
100
101
102
	public function testSortMultiple()
103
	{
104
		$this->assertGreaterThanOrEqual( 2, count( $this->object->sort( 'supplier.label,-supplier.id' )->search() ) );
105
	}
106
107
108
	public function testUses()
109
	{
110
		$this->assertSame( $this->object, $this->object->uses( ['text'] ) );
111
	}
112
}
113