diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-01 09:47:10 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-01 09:47:10 -0400 |
commit | a089cd72de82acb95986a630b862a4c3090e3e2a (patch) | |
tree | 6616fc5a482d5c1cf981dbc6d4e04ddccb6a7f89 /tests | |
parent | 4b94714b3d45656b022228562478514024550732 (diff) |
Fixed lexer issue with non word characters
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Core/Filter/LexerTest.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/units/Core/Filter/LexerTest.php b/tests/units/Core/Filter/LexerTest.php index b777531d..d57a7953 100644 --- a/tests/units/Core/Filter/LexerTest.php +++ b/tests/units/Core/Filter/LexerTest.php @@ -214,4 +214,48 @@ class LexerTest extends Base $this->assertSame($expected, $lexer->tokenize('tag:"tag 1" tag:tag2')); } + + public function testTokenizeWithDash() + { + $lexer = new Lexer(); + $lexer->addToken("/^(test:)/", 'T_TEST'); + + $expected = array( + 'T_TEST' => array('PO-123'), + ); + + $this->assertSame($expected, $lexer->tokenize('test:PO-123')); + + $lexer = new Lexer(); + $lexer->setDefaultToken('myDefaultToken'); + + $expected = array( + 'myDefaultToken' => array('PO-123'), + ); + + $this->assertSame($expected, $lexer->tokenize('PO-123')); + } + + public function testTokenizeWithUnderscore() + { + $lexer = new Lexer(); + $lexer->addToken("/^(test:)/", 'T_TEST'); + + $expected = array( + 'T_TEST' => array('PO_123'), + ); + + $this->assertSame($expected, $lexer->tokenize('test:PO_123')); + + $lexer = new Lexer(); + $lexer->addToken("/^(test:)/", 'T_TEST'); + $lexer->setDefaultToken('myDefaultToken'); + + $expected = array( + 'T_TEST' => array('ABC-123'), + 'myDefaultToken' => array('PO_123'), + ); + + $this->assertSame($expected, $lexer->tokenize('test:ABC-123 PO_123')); + } } |