mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge pull request #1502 from mdarse/ar-731-status-search-dsl
PHRAS-731 Add status match DSL
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\SearchEngine\AST;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\AST\FlagStatement;
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group searchengine
|
||||
* @group ast
|
||||
*/
|
||||
class FlagStatementTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSerialization()
|
||||
{
|
||||
$this->assertTrue(method_exists(FlagStatement::class, '__toString'), 'Class does not have method __toString');
|
||||
$node = new FlagStatement('foo', true);
|
||||
$this->assertEquals('<flag:foo set>', (string) $node);
|
||||
$node = new FlagStatement('foo', false);
|
||||
$this->assertEquals('<flag:foo cleared>', (string) $node);
|
||||
}
|
||||
|
||||
public function testQueryBuild()
|
||||
{
|
||||
$query_context = $this->prophesize(QueryContext::class);
|
||||
|
||||
$node = new FlagStatement('foo', true);
|
||||
$query = $node->buildQuery($query_context->reveal());
|
||||
|
||||
$expected = '{
|
||||
"term": {
|
||||
"flags.foo": true
|
||||
}
|
||||
}';
|
||||
|
||||
$this->assertEquals(json_decode($expected, true), $query);
|
||||
}
|
||||
}
|
@@ -78,6 +78,15 @@ id:90 AND foo|(<record_identifier:90> AND <text:"foo">)
|
||||
id:90 foo|<text:"id:90 foo">
|
||||
recordid:90|<record_identifier:90>
|
||||
|
||||
# Flag matcher
|
||||
flag.foo:true|<flag:foo set>
|
||||
flag.foo:1|<flag:foo set>
|
||||
flag.foo:false|<flag:foo cleared>
|
||||
flag.foo:0|<flag:foo cleared>
|
||||
flag.true:true|<flag:true set>
|
||||
flag.foo bar:true|<text:"flag.foo bar:true">
|
||||
true|<text:"true">
|
||||
|
||||
# Matcher on unknown name --> fulltext
|
||||
foo:bar|<text:"foo:bar">
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 11.
|
Reference in New Issue
Block a user