|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Admingenerator\GeneratorBundle\Tests\Mocks\Doctrine; |
|
4
|
|
|
|
|
5
|
|
|
class ConnectionMock extends \Doctrine\DBAL\Connection |
|
6
|
|
|
{ |
|
7
|
|
|
private $_fetchOneResult; |
|
8
|
|
|
private $_platformMock; |
|
9
|
|
|
private $_lastInsertId = 0; |
|
10
|
|
|
private $_inserts = array(); |
|
11
|
|
|
private $_executeUpdates = array(); |
|
12
|
|
|
|
|
13
|
|
|
public function __construct(array $params, $driver, $config = null, $eventManager = null) |
|
14
|
|
|
{ |
|
15
|
|
|
$this->_platformMock = new DatabasePlatformMock(); |
|
16
|
|
|
|
|
17
|
|
|
parent::__construct($params, $driver, $config, $eventManager); |
|
18
|
|
|
|
|
19
|
|
|
// Override possible assignment of platform to database platform mock |
|
20
|
|
|
$this->_platform = $this->_platformMock; |
|
|
|
|
|
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @override |
|
25
|
|
|
*/ |
|
26
|
|
|
public function getDatabasePlatform() |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->_platformMock; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @override |
|
33
|
|
|
*/ |
|
34
|
|
|
public function insert($tableName, array $data, array $types = array()) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->_inserts[$tableName][] = $data; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @override |
|
41
|
|
|
*/ |
|
42
|
|
|
public function executeUpdate($query, array $params = array(), array $types = array()) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->_executeUpdates[] = array('query' => $query, 'params' => $params, 'types' => $types); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @override |
|
49
|
|
|
*/ |
|
50
|
|
|
public function lastInsertId($seqName = null) |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->_lastInsertId; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @override |
|
57
|
|
|
*/ |
|
58
|
|
|
public function fetchColumn($statement, array $params = array(), $colnum = 0, array $types = array()) |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->_fetchOneResult; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @override |
|
65
|
|
|
*/ |
|
66
|
|
|
public function quote($input, $type = null) |
|
67
|
|
|
{ |
|
68
|
|
|
if (is_string($input)) { |
|
69
|
|
|
return "'" . $input . "'"; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return $input; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/* Mock API */ |
|
76
|
|
|
|
|
77
|
|
|
public function setFetchOneResult($fetchOneResult) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->_fetchOneResult = $fetchOneResult; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function setDatabasePlatform($platform) |
|
83
|
|
|
{ |
|
84
|
|
|
$this->_platformMock = $platform; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function setLastInsertId($id) |
|
88
|
|
|
{ |
|
89
|
|
|
$this->_lastInsertId = $id; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function getInserts() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->_inserts; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getExecuteUpdates() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->_executeUpdates; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function reset() |
|
103
|
|
|
{ |
|
104
|
|
|
$this->_inserts = array(); |
|
105
|
|
|
$this->_lastInsertId = 0; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.