Completed
Push — master ( 9109fd...709bda )
by Aimeos
02:33
created

StandardTest::testAddFilterCodes()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 2
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A StandardTest::testGet() 0 7 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2018
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Stock;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
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\Stock\Standard( $this->context );
22
	}
23
24
25
	protected function tearDown()
26
	{
27
		unset( $this->object, $this->context );
28
	}
29
30
31
	public function testCode()
32
	{
33
		$this->assertEquals( 2, count( $this->object->code( ['CNC', 'CNE'] )->search() ) );
34
	}
35
36
37
	public function testCompare()
38
	{
39
		$this->assertEquals( 1, count( $this->object->compare( '==', 'stock.stocklevel', null )->search() ) );
40
	}
41
42
43
	public function testGet()
44
	{
45
		$iface = \Aimeos\MShop\Stock\Item\Iface::class;
46
		$item = \Aimeos\MShop::create( $this->context, 'stock' )->findItem( 'CNC', [], 'product', 'default' );
47
48
		$this->assertInstanceOf( $iface, $this->object->get( $item->getId() ) );
49
	}
50
51
52
	public function testFind()
53
	{
54
		$iface = \Aimeos\MShop\Stock\Item\Iface::class;
55
		$this->assertInstanceOf( $iface, $this->object->find( 'CNC', 'default' ) );
56
	}
57
58
59
	public function testParse()
60
	{
61
		$cond = ['||' => [['==' => ['stock.dateback' => null]], ['>=' => ['stock.dateback' => '2010-01-01 00:00:00']]]];
62
		$this->assertEquals( 13, count( $this->object->parse( $cond )->search() ) );
63
	}
64
65
66
	public function testSearch()
67
	{
68
		$total = 0;
69
		$this->assertGreaterThanOrEqual( 15, count( $this->object->search( $total ) ) );
70
		$this->assertGreaterThanOrEqual( 15, $total );
71
	}
72
73
74
	public function testSlice()
75
	{
76
		$this->assertEquals( 2, count( $this->object->slice( 0, 2 )->search() ) );
77
	}
78
79
80
	public function testSort()
81
	{
82
		$this->assertGreaterThanOrEqual( 15, count( $this->object->sort()->search() ) );
83
	}
84
85
86
	public function testSortGeneric()
87
	{
88
		$this->assertGreaterThanOrEqual( 15, count( $this->object->sort( 'stock.dateback' )->search() ) );
89
	}
90
91
92
	public function testSortStock()
93
	{
94
		$result = $this->object->sort( 'stock' )->search();
95
		$this->assertStringStartsWith( 'U:TEST', reset( $result )->getProductCode() );
96
	}
97
98
99
	public function testSortStockDesc()
100
	{
101
		$result = $this->object->sort( '-stock' )->search();
102
		$this->assertStringStartsWith( 'U:TEST', end( $result )->getProductCode() );
103
	}
104
105
106
	public function testType()
107
	{
108
		$this->assertEquals( 8, count( $this->object->type( 'default' )->search() ) );
109
	}
110
}
111