Passed
Push — master ( 6cf50b...92e939 )
by Aimeos
01:45
created

StandardTest::testHas()   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), 2017-2018
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Attribute;
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 $context;
15
	private $object;
16
17
18
	protected function setUp()
19
	{
20
		$this->context = \TestHelperFrontend::getContext();
21
		$this->object = new \Aimeos\Controller\Frontend\Attribute\Standard( $this->context );
22
	}
23
24
25
	protected function tearDown()
26
	{
27
		unset( $this->object, $this->context );
28
	}
29
30
31
	public function testAttribute()
32
	{
33
		$manager = \Aimeos\MShop::create( $this->context, 'attribute' );
34
35
		$blueId = $manager->findItem( 'blue', [], 'product', 'color' )->getId();
36
		$whiteId = $manager->findItem( 'white', [], 'product', 'color' )->getId();
37
38
		$this->assertEquals( 2, count( $this->object->attribute( [$blueId, $whiteId] )->search() ) );
39
	}
40
41
42
	public function testDomain()
43
	{
44
		$this->assertEquals( 5, count( $this->object->domain( 'media' )->search() ) );
45
	}
46
47
48
	public function testCompare()
49
	{
50
		$this->assertEquals( 5, count( $this->object->compare( '==', 'attribute.type', 'color' )->search() ) );
51
	}
52
53
54
	public function testFind()
55
	{
56
		$iface = \Aimeos\MShop\Attribute\Item\Iface::class;
57
		$this->assertInstanceOf( $iface, $this->object->find( 'white', [], 'color' ) );
58
	}
59
60
61
	public function testGet()
62
	{
63
		$iface = \Aimeos\MShop\Attribute\Item\Iface::class;
64
		$item = \Aimeos\MShop::create( $this->context, 'attribute' )->findItem( 'white', [], 'product', 'color' );
65
66
		$this->assertInstanceOf( $iface, $this->object->get( $item->getId() ) );
67
	}
68
69
70
	public function testHas()
71
	{
72
		$this->assertEquals( 2, count( $this->object->has( 'price', 'default' )->search() ) );
73
	}
74
75
76
	public function testParse()
77
	{
78
		$cond = ['&&' => [['>' => ['attribute.status' => 0]], ['==' => ['attribute.type' => 'color']]]];
79
		$this->assertEquals( 5, count( $this->object->parse( $cond )->search() ) );
80
	}
81
82
83
	public function testProperty()
84
	{
85
		$this->assertEquals( 1, count( $this->object->property( 'size', '1024' )->search() ) );
86
	}
87
88
89
	public function testSearch()
90
	{
91
		$total = 0;
92
		$this->assertGreaterThanOrEqual( 26, count( $this->object->search( [], $total ) ) );
93
		$this->assertGreaterThanOrEqual( 26, $total );
94
	}
95
96
97
	public function testSlice()
98
	{
99
		$this->assertEquals( 2, count( $this->object->slice( 0, 2 )->search() ) );
100
	}
101
102
103
	public function testSort()
104
	{
105
		$this->assertGreaterThanOrEqual( 26, count( $this->object->sort()->search() ) );
106
	}
107
108
109
	public function testSortGeneric()
110
	{
111
		$this->assertGreaterThanOrEqual( 26, count( $this->object->sort( 'attribute.status' )->search() ) );
112
	}
113
114
115
	public function testSortPosition()
116
	{
117
		$result = $this->object->sort( 'position' )->search( [] );
118
		$this->assertEquals( 'white', reset( $result )->getCode() );
119
	}
120
121
122
	public function testSortCodeDesc()
123
	{
124
		$result = $this->object->sort( '-position' )->search( [] );
125
		$this->assertStringStartsWith( 'white', end( $result )->getCode() );
126
	}
127
128
129
	public function testType()
130
	{
131
		$this->assertEquals( 6, count( $this->object->type( 'size' )->search() ) );
132
	}
133
}
134