summaryrefslogtreecommitdiff
path: root/test/bootstrap.php
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2013-01-17 17:33:13 +0000
committerSimon Holywell <[email protected]>2013-01-17 17:33:13 +0000
commitef2e9078dfc23d1b14b25b8d0d22206ef61d5167 (patch)
tree3ce55c5af4100c8caf97acb27711f9a53faaba4a /test/bootstrap.php
parent5edfadfc5a9aa535d5c3f0991f3dcff5df7380ba (diff)
Begin moving query building tests into phpunit
Diffstat (limited to 'test/bootstrap.php')
-rw-r--r--test/bootstrap.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/test/bootstrap.php b/test/bootstrap.php
index 6f42c87..da97d2f 100644
--- a/test/bootstrap.php
+++ b/test/bootstrap.php
@@ -1,3 +1,41 @@
<?php
-require_once dirname(__FILE__) . '/../idiorm.php'; \ No newline at end of file
+require_once dirname(__FILE__) . '/../idiorm.php';
+
+/**
+ *
+ * Mock version of the PDOStatement class.
+ *
+ */
+class MockPDOStatement extends PDOStatement {
+
+ private $current_row = 0;
+ /**
+ * Return some dummy data
+ */
+ public function fetch($fetch_style=PDO::FETCH_BOTH, $cursor_orientation=PDO::FETCH_ORI_NEXT, $cursor_offset=0) {
+ if ($this->current_row == 5) {
+ return false;
+ } else {
+ $this->current_row++;
+ return array('name' => 'Fred', 'age' => 10, 'id' => '1');
+ }
+ }
+}
+
+/**
+ *
+ * Mock database class implementing a subset
+ * of the PDO API.
+ *
+ */
+class MockPDO extends PDO {
+
+ /**
+ * Return a dummy PDO statement
+ */
+ public function prepare($statement, $driver_options=array()) {
+ $this->last_query = new MockPDOStatement($statement);
+ return $this->last_query;
+ }
+} \ No newline at end of file