mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Search;
|
|
|
|
use Chill\MainBundle\Search\SearchApiQuery;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SearchApiQueryTest extends TestCase
|
|
{
|
|
public function testMultipleWhereClauses()
|
|
{
|
|
$q = new SearchApiQuery();
|
|
$q->setSelectJsonbMetadata('boum')
|
|
->setSelectKey('bim')
|
|
->setSelectPertinence('1')
|
|
->setFromClause('badaboum')
|
|
->andWhereClause('foo', [ 'alpha' ])
|
|
->andWhereClause('bar', [ 'beta' ])
|
|
;
|
|
|
|
$query = $q->buildQuery();
|
|
|
|
$this->assertStringContainsString('(foo) AND (bar)', $query);
|
|
$this->assertEquals(['alpha', 'beta'], $q->buildParameters());
|
|
|
|
$query = $q->buildQuery(true);
|
|
|
|
$this->assertStringContainsString('(foo) AND (bar)', $query);
|
|
$this->assertEquals(['alpha', 'beta'], $q->buildParameters());
|
|
}
|
|
|
|
public function testWithoutWhereClause()
|
|
{
|
|
$q = new SearchApiQuery();
|
|
$q->setSelectJsonbMetadata('boum')
|
|
->setSelectKey('bim')
|
|
->setSelectPertinence('1')
|
|
->setFromClause('badaboum')
|
|
;
|
|
|
|
$this->assertTrue(\is_string($q->buildQuery()));
|
|
$this->assertEquals([], $q->buildParameters());
|
|
}
|
|
|
|
}
|