/** @todo belongs in TokenizerTestCase? */ public function testBracktExplode() { $tokenizer = new Doctrine_Query_Tokenizer(); $str = "item OR item OR item"; $parts = $tokenizer->bracketExplode($str, array(' OR '), "(", ")"); $this->assertEqual($parts, array('item', 'item', 'item')); }
public function testAdditionalTokenizerFeatures() { // These tests all pass with the old tokenizer, they were developed wile // working on the patch $tokenizer = new Doctrine_Query_Tokenizer(); $delimiters = array(' ', '+', '-', '*', '/', '<', '>', '=', '>=', '<=', '&', '|'); $res = $tokenizer->bracketExplode("(age < 20 AND age > 18) AND email LIKE '*****@*****.**'", ' AND ', '(', ')'); $this->assertEqual($res, array("(age < 20 AND age > 18)", "email LIKE '*****@*****.**'")); $res = $tokenizer->sqlExplode("sentence OR 'term'", ' OR '); $this->assertEqual($res, array("sentence", "'term'")); $res = $tokenizer->clauseExplode("'a + b'+c", $delimiters); $this->assertEqual($res, array(array("'a + b'", '+'), array('c', ''))); $res = $tokenizer->quoteExplode('"a"."b"', ' '); $this->assertEqual($res, array('"a"."b"')); }
public function testBracketExplode() { $tokenizer = new Doctrine_Query_Tokenizer(); $str = 'foo.field AND bar.field'; $a = $tokenizer->bracketExplode($str, array(' \&\& ', ' AND '), '(', ')'); $this->assertEqual($a, array('foo.field', 'bar.field')); // delimiters should be case insensitive $str = 'foo.field and bar.field'; $a = $tokenizer->bracketExplode($str, array(' \&\& ', ' AND '), '(', ')'); $this->assertEqual($a, array('foo.field', 'bar.field')); }
public function testBracketExplode() { $tokenizer = new Doctrine_Query_Tokenizer(); $str = 'foo.field AND bar.field'; $a = $tokenizer->bracketExplode($str, array(' \\&\\& ', ' AND '), '(', ')'); $this->assertEqual($a, array('foo.field', 'bar.field')); // delimiters should be case insensitive $str = 'foo.field and bar.field'; $a = $tokenizer->bracketExplode($str, array(' \\&\\& ', ' AND '), '(', ')'); $this->assertEqual($a, array('foo.field', 'bar.field')); // test the JOIN splitter as used in Doctrine_Query_From::parse() $str = 'foo.field join bar.field'; $a = $tokenizer->bracketExplode($str, 'JOIN'); $this->assertEqual($a, array('foo.field', 'bar.field')); // test that table names including the split string are unaffected $str = 'foojointable.field join bar.field'; $a = $tokenizer->bracketExplode($str, 'JOIN'); $this->assertEqual($a, array('foojointable.field', 'bar.field')); }