From 090bd6c3945603328fdd447367a8703b7360f358 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 28 Sep 2010 10:18:29 +0200 Subject: [PATCH] Add tests for XDBFormat. Signed-off-by: Florent Bruneau --- ut/xdbtest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ut/xdbtest.php b/ut/xdbtest.php index 585b8f8..20fe8c6 100644 --- a/ut/xdbtest.php +++ b/ut/xdbtest.php @@ -21,6 +21,21 @@ require_once dirname(__FILE__) . '/../include/test.inc.php'; +class FormatBlah implements XDBFormat +{ + private $text; + + public function __construct($text) + { + $this->text = $text; + } + + public function format() + { + return 'blah' . $this->text . 'blah'; + } +} + class XDBTest extends PlTestCase { public function testEscapeString() @@ -51,6 +66,13 @@ class XDBTest extends PlTestCase { $this->assertSame("(1, 'toto')", XDB::format('{?}', array(1, 'toto'))); } + + public function testEscapeFormat() + { + $this->assertSame('blahblah', XDB::format('{?}', new FormatBlah(''))); + $this->assertSame('blahblahblah', XDB::format('{?}', new FormatBlah('blah'))); + $this->assertSame('blahBloumblah', XDB::format('{?}', new FormatBlah('Bloum'))); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -- 2.1.4