From 2779e65f509a1f04cb5976d245da9f3a9028934d Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 9 Mar 2010 22:09:39 +0100 Subject: [PATCH] Add XDB escaping unit tests. Signed-off-by: Florent Bruneau --- ut/xdbtest.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ut/xdbtest.php diff --git a/ut/xdbtest.php b/ut/xdbtest.php new file mode 100644 index 0000000..3cc96e6 --- /dev/null +++ b/ut/xdbtest.php @@ -0,0 +1,57 @@ +assertEquals("'blah'", XDB::format('{?}', 'blah')); + $this->assertEquals("'blah\\''", XDB::format('{?}', "blah'")); + $this->assertEquals("'bl\\'ah'", XDB::format('{?}', "bl'ah")); + $this->assertEquals("'\\'blah\\''", XDB::format('{?}', "'blah'")); + } + + public function testEscapeInt() + { + $this->assertEquals("1", XDB::format('{?}', 1)); + } + + public function testEscapeFlagSet() + { + $flagset = new PlFlagSet(); + $flagset->addFlag('toto'); + $this->assertEquals("'toto'", XDB::format('{?}', $flagset)); + $flagset->addFlag('titi'); + $this->assertEquals("'toto,titi'", XDB::format('{?}', $flagset)); + $flagset->addFlag('titi'); + $this->assertEquals("'toto,titi'", XDB::format('{?}', $flagset)); + } + + public function testEscapeArray() + { + $this->assertEquals("(1, 'toto')", XDB::format('{?}', array(1, 'toto'))); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> -- 2.1.4