summaryrefslogtreecommitdiff
path: root/test/bootstrap.php
diff options
context:
space:
mode:
Diffstat (limited to 'test/bootstrap.php')
-rw-r--r--test/bootstrap.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/bootstrap.php b/test/bootstrap.php
new file mode 100644
index 0000000..da97d2f
--- /dev/null
+++ b/test/bootstrap.php
@@ -0,0 +1,41 @@
+<?php
+
+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