Passed
Push — master ( 484f92...9dd3d0 )
by Aimeos
04:56
created

PgSQLTest::testSearchItemsSub()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 0
dl 0
loc 20
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2018-2018
6
 */
7
8
9
namespace Aimeos\MShop\Index\Manager;
10
11
12
class PgSQLTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $editor;
16
17
18
	protected function setUp()
19
	{
20
		$context = clone \TestHelperMShop::getContext();
21
		$this->editor = $context->getEditor();
22
		$config = $context->getConfig();
23
24
		$dbadapter = $config->get( 'resource/db-index/adapter', $config->get( 'resource/db/adapter' ) );
25
26
		if( $dbadapter !== 'pgsql' ) {
27
			$this->markTestSkipped( 'PostgreSQL specific test' );
28
		}
29
30
		$context->getConfig()->set( 'mshop/index/manager/text/name', 'PgSQL' );
31
		$this->object = new \Aimeos\MShop\Index\Manager\PgSQL( $context );
32
	}
33
34
35
	protected function tearDown()
36
	{
37
		unset( $this->object );
38
	}
39
40
41
	public function testSearchItemsSub()
42
	{
43
		$total = 0;
44
		$search = $this->object->createSearch();
45
		$search->setSlice( 0, 1 );
46
47
		$expr = array(
48
			$search->compare( '!=', 'index.attribute.id', null ),
49
			$search->compare( '!=', 'index.catalog.id', null ),
50
			$search->compare( '!=', 'index.supplier.id', null ),
51
			$search->compare( '>=', $search->createFunction( 'index.price:value', ['EUR'] ), 0 ),
52
			$search->compare( '>=', $search->createFunction( 'index.text:name', ['de'] ), '' ),
53
			$search->compare( '==', 'product.editor', $this->editor )
54
		);
55
56
		$search->setConditions( $search->combine( '&&', $expr ) );
57
		$result = $this->object->searchItems( $search, [], $total );
58
59
		$this->assertEquals( 1, count( $result ) );
60
		$this->assertEquals( 2, $total );
61
	}
62
}
63