blob: ec13cc7d5e7bdfb5cb6d00c53a62d5688f66378f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?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');
}
}
}
/**
* Another mock PDOStatement class, used for testing multiple connections
*/
class MockDifferentPDOStatement extends MockPDOStatement { }
/**
*
* 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;
}
}
/**
* A different mock database class, for testing multiple connections
* Mock database class implementing a subset of the PDO API.
*/
class MockDifferentPDO extends MockPDO {
/**
* Return a dummy PDO statement
*/
public function prepare($statement, $driver_options = array()) {
$this->last_query = new MockDifferentPDOStatement($statement);
return $this->last_query;
}
}
|