Add search attribute to search by reference

This commit is contained in:
Frederic Guillot
2015-07-04 17:35:52 -04:00
parent 0e5756ecc1
commit 198f3eda90
5 changed files with 90 additions and 0 deletions

View File

@@ -171,6 +171,36 @@ class LexerTest extends Base
);
}
public function testReferenceQuery()
{
$lexer = new Lexer;
$this->assertEquals(
array(array('match' => 'ref:', 'token' => 'T_REFERENCE'), array('match' => '123', 'token' => 'T_STRING')),
$lexer->tokenize('ref:123')
);
$this->assertEquals(
array(array('match' => 'reference:', 'token' => 'T_REFERENCE'), array('match' => '456', 'token' => 'T_STRING')),
$lexer->tokenize('reference:456')
);
$this->assertEquals(
array('T_REFERENCE' => '123'),
$lexer->map($lexer->tokenize('reference:123'))
);
$this->assertEquals(
array('T_REFERENCE' => '456'),
$lexer->map($lexer->tokenize('ref:456'))
);
$this->assertEquals(
array(),
$lexer->map($lexer->tokenize('ref: '))
);
}
public function testDescriptionQuery()
{
$lexer = new Lexer;