cvs: pear /MDB2/tests MDB2_usage_testcase.php
| From: | Lorenzo Alberton | Date: | Wed, 25 Oct 2006 15:39:58 +0000 |
| Subject: | cvs: pear /MDB2/tests MDB2_usage_testcase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-42817@lists.php.net to get a copy of this message | ||
quipo Wed Oct 25 15:39:58 2006 UTC
Modified files:
/pear/MDB2/tests MDB2_usage_testcase.php
Log:
test _skipDelimitedStrings() method
http://cvs.php.net/viewvc.cgi/pear/MDB2/tests/MDB2_usage_testcase.php?r1=1.96&r2=1.97&diff_format=u
Index: pear/MDB2/tests/MDB2_usage_testcase.php
diff -u pear/MDB2/tests/MDB2_usage_testcase.php:1.96 pear/MDB2/tests/MDB2_usage_testcase.php:1.97
--- pear/MDB2/tests/MDB2_usage_testcase.php:1.96 Sun Oct 22 19:09:59 2006
+++ pear/MDB2/tests/MDB2_usage_testcase.php Wed Oct 25 15:39:58 2006
@@ -41,7 +41,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2_usage_testcase.php,v 1.96 2006/10/22 19:09:59 lsmith Exp $
+// $Id: MDB2_usage_testcase.php,v 1.97 2006/10/25 15:39:58 quipo Exp $
require_once 'MDB2_testcase.php';
@@ -445,7 +445,7 @@
$this->assertTrue(empty($diff), 'Prepared SELECT failed for fields:
'.implode(', ', array_keys($diff)));
}
$stmt->free();
-}
+ }
$row_data = reset($data);
$query = 'SELECT user_name, user_password, user_id FROM users WHERE
user_name=:username OR user_password=:username';
@@ -466,6 +466,38 @@
}
/**
+ * Test _skipDelimitedStrings(), used by prepare()
+ *
+ * If the placeholder is contained within a delimited string, it must be skipped,
+ * and the cursor position must be advanced
+ */
+ function testSkipDelimitedStrings() {
+ //test correct placeholder
+ $query = 'SELECT what FROM tbl WHERE x = ?';
+ $position = 0;
+ $p_position = strpos($query, '?');
+ $this->assertEquals($position, $this->db->_skipDelimitedStrings($query, $position,
$p_position), 'Error: the cursor position has changed');
+
+ //test placeholder within a quoted string
+ $query = 'SELECT what FROM tbl WHERE x = '.
$this->db->string_quoting['start'] .'blah?blah'.
$this->db->string_quoting['end'] .' AND y = ?';
+ $position = 0;
+ $p_position = strpos($query, '?');
+ $new_pos = $this->db->_skipDelimitedStrings($query, $position, $p_position);
+ $this->assertTrue($position != $new_pos, 'Error: the cursor position was not
advanced');
+
+ //test placeholder within a comment
+ foreach ($this->db->sql_comments as $comment) {
+ $query = 'SELECT what FROM tbl WHERE x = '. $comment['start']
.'blah?blah'. $comment['end'] .' AND y = ?';
+ $position = 0;
+ $p_position = strpos($query, '?');
+ $new_pos = $this->db->_skipDelimitedStrings($query, $position, $p_position);
+ $this->assertTrue($position != $new_pos, 'Error: the cursor position was not
advanced');
+ }
+
+ //add some tests for named placeholders and for identifier_quoting
+ }
+
+ /**
* Test retrieval of result metadata
*
* This tests the result metadata by executing a prepared query and