. */ /** * Doctrine_Tokenizer_TestCase * This class tests the functinality of Doctrine_Tokenizer component * * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 * @version $Revision: 1181 $ * @author Konsta Vesterinen */ class Doctrine_Tokenizer_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { } public function testSqlExplode() { $str = "word1 word2 word3"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "word2", "word3")); $str = "word1 (word2 word3)"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "(word2 word3)")); $str = "word1 'word2 word3'"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "'word2 word3'")); $str = "word1 'word2 word3'"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "'word2 word3'")); $str = "word1 \"word2 word3\""; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "\"word2 word3\"")); $str = "word1 ((word2) word3)"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "((word2) word3)")); $str = "word1 ( (word2) 'word3')"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "( (word2) 'word3')")); $str = "word1 ( \"(word2) 'word3')"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "( \"(word2) 'word3')")); $str = "word1 ( ''(word2) 'word3')"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "( ''(word2) 'word3')")); $str = "word1 ( '()()'(word2) 'word3')"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "( '()()'(word2) 'word3')")); $str = "word1 'word2)() word3'"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "'word2)() word3'")); $str = "word1 (word2() word3)"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "(word2() word3)")); $str = "word1 \"word2)() word3\""; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("word1", "\"word2)() word3\"")); $str = "something (subquery '')"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("something", "(subquery '')")); $str = "something (( ))"; $a = Doctrine_Tokenizer::sqlExplode($str); $this->assertEqual($a, array("something", "(( ))")); } }