Passed
Push — master ( 635cae...14ad00 )
by Aimeos
02:06
created

StandardTest::testSortMultiple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
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 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 testParse()
57
	{
58
		$cond = ['&&' => [['==' => ['supplier.status' => 1]], ['=~' => ['supplier.label' => 'unit']]]];
59
		$this->assertEquals( 2, count( $this->object->parse( $cond )->search() ) );
60
	}
61
62
63
	public function testSearch()
64
	{
65
		$total = 0;
66
		$items = $this->object->uses( ['product'] )->compare( '=~', 'supplier.code', 'unit' )
67
			->sort( 'supplier.code' )->search( $total );
68
69
		$this->assertGreaterThanOrEqual( 2, count( $items ) );
70
		$this->assertGreaterThanOrEqual( 2, $total );
71
		$this->assertEquals( 2, count( current( $items )->getRefItems( 'product' ) ) );
72
	}
73
74
75
	public function testSlice()
76
	{
77
		$this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) );
78
	}
79
80
81
	public function testSort()
82
	{
83
		$this->assertGreaterThanOrEqual( 2, count( $this->object->sort()->search() ) );
84
	}
85
86
87
	public function testSortGeneric()
88
	{
89
		$this->assertGreaterThanOrEqual( 2, count( $this->object->sort( 'supplier.label' )->search() ) );
90
	}
91
92
93
	public function testSortMultiple()
94
	{
95
		$this->assertGreaterThanOrEqual( 2, count( $this->object->sort( 'supplier.label,-supplier.id' )->search() ) );
96
	}
97
98
99
	public function testUses()
100
	{
101
		$this->assertSame( $this->object, $this->object->uses( ['text'] ) );
102
	}
103
}
104