1 : <?php
2 :
3 : require_once 'db.class.php';
4 : require_once 'PHPDS_db.class.php';
5 : require_once 'PHPDS_query.class.php';
6 :
7 : class TEST_mock_connector /*extends PHPDS_dependant*/ implements PHPDS_dbConnector
8 : {
9 : private $link;
10 :
11 : private $result;
12 :
13 : public $data = array();
14 : private $pointer = 0;
15 : private $lastid = 0;
16 :
17 : public function free()
18 : {
19 0 : if (!empty($this->result)) {
20 0 : $this->data = array();
21 0 : }
22 0 : }
23 :
24 : public function connect()
25 : {
26 1 : $this->link = true;
27 1 : }
28 :
29 : public function query($sql)
30 : {
31 1 : if (empty($this->link)) $this->connect();
32 1 : $this->pointer = 0;
33 1 : $this->lastid++;
34 1 : return true;
35 : }
36 :
37 : public function protect($param)
38 : {
39 0 : return mysql_real_escape_string($param);
40 : }
41 :
42 : public function fetchAssoc()
43 : {
44 1 : if ($this->pointer >= count($this->data)) return false;
45 1 : return $this->data[$this->pointer++];
46 : }
47 :
48 : public function seek($row_number)
49 : {
50 0 : $this->pointer = $row_number;
51 0 : if ($this->pointer < 0) $this->pointer = 0;
52 0 : if ($this->pointer > count($this->data)) $this->pointer = count($this->data) - 1;
53 0 : }
54 :
55 : public function numrows()
56 : {
57 0 : return count($this->data);
58 : }
59 :
60 : public function affectedRows()
61 : {
62 1 : return 0;
63 : }
64 :
65 : public function returnSqlError($query)
66 : {
67 0 : return '';
68 : }
69 :
70 : public function debugInstance ($domain = null)
71 : {
72 0 : return parent::debugInstance('db');
73 : }
74 :
75 : public function lastId($reset = false) {
76 0 : if ($reset) $this->lastid = 0;
77 0 : return $this->lastid;
78 : }
79 :
80 : public function rowResults($row = 0) {
81 0 : return $this->data[$row];
82 : }
83 :
84 : public function startTransaction()
85 : {
86 : // do nothing
87 0 : }
88 :
89 : public function endTransaction($commit = true)
90 : {
91 : // do nothing
92 0 : }
93 :
94 : }
95 :
96 :
97 :
98 : class TEST_stubQuery extends PHPDS_query
99 : {
100 : protected $sql = '';
101 :
102 : // allow easy access from the test scripts to the fields
103 : public $singleRow;
104 : public $singleValue;
105 : public $typecast;
106 : public $getLastID;
107 : }
|