Add tests for XDBFormat.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 28 Sep 2010 08:18:29 +0000 (10:18 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 28 Sep 2010 08:18:29 +0000 (10:18 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ut/xdbtest.php

index 585b8f8..20fe8c6 100644 (file)
 
 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: