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\Text; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class PgSQLTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$context = clone \TestHelperMShop::getContext(); |
20
|
|
|
$config = $context->getConfig(); |
21
|
|
|
|
22
|
|
|
$dbadapter = $config->get( 'resource/db-index/adapter', $config->get( 'resource/db/adapter' ) ); |
23
|
|
|
|
24
|
|
|
if( $dbadapter !== 'pgsql' ) { |
25
|
|
|
$this->markTestSkipped( 'PostgreSQL specific test' ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$this->object = new \Aimeos\MShop\Index\Manager\Text\PgSQL( \TestHelperMShop::getContext() ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
protected function tearDown() |
33
|
|
|
{ |
34
|
|
|
unset( $this->object ); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function testGetSearchAttributes() |
39
|
|
|
{ |
40
|
|
|
$list = $this->object->getSearchAttributes(); |
41
|
|
|
|
42
|
|
|
foreach( $list as $attribute ) { |
43
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Criteria\Attribute\Iface::class, $attribute ); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
public function testSearchItemsRelevance() |
49
|
|
|
{ |
50
|
|
|
$search = $this->object->createSearch(); |
51
|
|
|
|
52
|
|
|
$search->setConditions( $search->combine( '&&', [ |
53
|
|
|
$search->compare( '>', $search->createFunction( 'index.text:relevance', ['de', 'T-DISC'] ), 0 ), |
54
|
|
|
$search->compare( '>', $search->createFunction( 'index.text:relevance', ['de', 't-disc'] ), 0 ), |
55
|
|
|
] ) ); |
56
|
|
|
|
57
|
|
|
$search->setSortations( [ |
58
|
|
|
$search->sort( '+', $search->createFunction( 'sort:index.text:relevance', ['de', 'T-DISC'] ) ), |
59
|
|
|
$search->sort( '+', $search->createFunction( 'sort:index.text:relevance', ['de', 't-disc'] ) ), |
60
|
|
|
] ); |
61
|
|
|
|
62
|
|
|
$result = $this->object->searchItems( $search, [] ); |
63
|
|
|
|
64
|
|
|
$this->assertEquals( 1, count( $result ) ); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|