summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMitch <[email protected]>2014-06-19 20:02:49 +1000
committerMitch <[email protected]>2014-06-19 20:04:14 +1000
commit2aa5869fa6a6c27216077731974fc025f8a14df3 (patch)
tree0137e70c555f84ebf33d069d73f1a908ca132d94 /test
parent2126f362562bb9e9a88dae27951d6da3dbc42103 (diff)
parentffb4ef2d090223215687819763e335ebc319d716 (diff)
Fix merge conflicts
Diffstat (limited to 'test')
-rw-r--r--test/bootstrap.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/bootstrap.php b/test/bootstrap.php
index 32f0288..3b3cace 100644
--- a/test/bootstrap.php
+++ b/test/bootstrap.php
@@ -10,6 +10,7 @@ require_once dirname(__FILE__) . '/../idiorm.php';
class MockPDOStatement extends PDOStatement {
private $current_row = 0;
private $statement = NULL;
+ private $bindParams = array();
/**
* Store the statement that gets passed to the constructor
@@ -21,9 +22,10 @@ class MockPDOStatement extends PDOStatement {
/**
* Check that the array
*/
- public function execute($params = null) {
+ public function execute($params = NULL) {
$count = 0;
$m = array();
+ if (is_null($params)) $params = $this->bindParams;
if (preg_match_all('/"[^"\\\\]*(?:\\?)[^"\\\\]*"|\'[^\'\\\\]*(?:\\?)[^\'\\\\]*\'|(\\?)/', $this->statement, $m, PREG_SET_ORDER)) {
$count = count($m);
for ($v = 0; $v < $count; $v++) {
@@ -40,6 +42,20 @@ class MockPDOStatement extends PDOStatement {
}
}
}
+
+ /**
+ * Add data to arrays
+ */
+ public function bindParam($index, $value, $type)
+ {
+ // Do check on index, and type
+ if (!is_int($index)) throw new Exception('Incorrect parameter type. Expected $index to be an integer.');
+ if (!is_int($type) || ($type != PDO::PARAM_STR && $type != PDO::PARAM_NULL && $type != PDO::PARAM_BOOL && $type != PDO::PARAM_INT))
+ throw new Exception('Incorrect parameter type. Expected $type to be an integer.');
+
+ // Add param to array
+ $this->bindParams[$index - 1] = $value;
+ }
/**
* Return some dummy data