Completed
Push — master ( c1ac02...038e21 )
by Aimeos
02:23
created

StandardTest::testSearchItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
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
13
{
14
	private $object;
15
16
17
	protected function setUp()
18
	{
19
		$this->object = new \Aimeos\Controller\Frontend\Supplier\Standard( \TestHelperFrontend::getContext() );
20
	}
21
22
23
	protected function tearDown()
24
	{
25
		unset( $this->object );
26
	}
27
28
29
	public function testCreateFilter()
30
	{
31
		$filter = $this->object->createFilter();
32
33
		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
34
		$this->assertEquals( 0, $filter->getSliceStart() );
35
		$this->assertEquals( 100, $filter->getSliceSize() );
36
	}
37
38
39
	public function testGetItem()
40
	{
41
		$context = \TestHelperFrontend::getContext();
42
		$manager = \Aimeos\MShop\Factory::createManager( $context, 'supplier' );
43
		$id = $manager->findItem( 'unitCode001' )->getId();
44
45
		$result = $this->object->getItem( $id );
46
47
		$this->assertInstanceOf( '\Aimeos\MShop\Supplier\Item\Iface', $result );
48
	}
49
50
51
	public function testGetItems()
52
	{
53
		$context = \TestHelperFrontend::getContext();
54
		$manager = \Aimeos\MShop\Factory::createManager( $context, 'supplier' );
55
		$id = $manager->findItem( 'unitCode001' )->getId();
56
57
		$result = $this->object->getItems( [$id] );
58
59
		$this->assertInternalType( 'array', $result );
60
		$this->assertEquals( 1, count( $result ) );
61
	}
62
63
64
	public function testSearchItems()
65
	{
66
		$filter = $this->object->createFilter();
67
68
		$total = 0;
69
		$results = $this->object->searchItems( $filter, [], $total );
70
71
		$this->assertEquals( 2, $total );
72
		$this->assertEquals( 2, count( $results ) );
73
	}
74
}
75