diff options
author | Stefan Andres Charsley <[email protected]> | 2014-01-12 11:07:34 +1300 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2014-04-26 13:27:54 +0100 |
commit | 7b29b766fbe4b3db7601ef045b9c29e6b91736ea (patch) | |
tree | a05e8acfbb4e08b868c0a3e356da279e16e3d5b7 /test/bootstrap.php | |
parent | 779f1ba4306c51f1366cdcab1a130e3da1627414 (diff) |
Added parameter array checking
Testing:
Checks the parameter array to ensure the correct number of values inside
the parameter with sequential integer indexes.
Production:
Strips out any non-integer indexes from the parameter array inside the
_log_query function.
Diffstat (limited to 'test/bootstrap.php')
-rw-r--r-- | test/bootstrap.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/bootstrap.php b/test/bootstrap.php index 0e489bd..97f497f 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -9,9 +9,28 @@ require_once dirname(__FILE__) . '/../idiorm.php'; */ class MockPDOStatement extends PDOStatement { private $current_row = 0; + private $statement = NULL; - public function __construct() {} - public function execute($params) {} + /** + * Store the statement that gets passed to the constructor + */ + public function __construct($statement) { + $this->statement = $statement; + } + + /** + * Check that the array + */ + public function execute($params) { + $count = 0; + $m = array(); + if (preg_match_all('\\?', $this->statement, $m)) { + $count = count($m); + for ($i = 0; $i < $count; $i++) { + if ($params[$i] == NULL) throw new Exception('Incorrect parameter count.'); + } + } + } /** * Return some dummy data |