1
|
|
|
<?php |
2
|
|
|
namespace Mezon\PdoCrud\Tests; |
3
|
|
|
|
4
|
|
|
class PdoCrudMock extends \Mezon\PdoCrud\PdoCrud |
5
|
|
|
{ |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Selected result |
9
|
|
|
* |
10
|
|
|
* @var array |
11
|
|
|
*/ |
12
|
|
|
public $selectResult = []; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* |
16
|
|
|
* {@inheritdoc} |
17
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::select() |
18
|
|
|
*/ |
19
|
|
|
public function select( |
20
|
|
|
string $fields, |
21
|
|
|
string $tableNames, |
22
|
|
|
string $where = '1 = 1', |
23
|
|
|
int $from = 0, |
24
|
|
|
int $limit = 1000000): array |
25
|
|
|
{ |
26
|
|
|
return $this->selectResult; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Counter for update method calls |
31
|
|
|
* |
32
|
|
|
* @var integer |
33
|
|
|
*/ |
34
|
|
|
public $updateWasCalledCounter = 0; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::update() |
40
|
|
|
*/ |
41
|
|
|
public function update(string $tableName, array $record, string $where, int $limit = 10000000): int |
42
|
|
|
{ |
43
|
|
|
$this->updateWasCalledCounter ++; |
44
|
|
|
|
45
|
|
|
return 1; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Counter for delete method calls |
50
|
|
|
* |
51
|
|
|
* @var integer |
52
|
|
|
*/ |
53
|
|
|
public $deleteWasCalledCounter = 0; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::delete() |
59
|
|
|
*/ |
60
|
|
|
public function delete($tableName, $where, $limit = 10000000): int |
61
|
|
|
{ |
62
|
|
|
$this->deleteWasCalledCounter ++; |
63
|
|
|
|
64
|
|
|
return 1; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Locked tables |
69
|
|
|
* |
70
|
|
|
* @var array |
71
|
|
|
*/ |
72
|
|
|
public $lockedTables = []; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Locked tables modes |
76
|
|
|
* |
77
|
|
|
* @var array |
78
|
|
|
*/ |
79
|
|
|
public $lockedTablesModes = []; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* |
83
|
|
|
* {@inheritdoc} |
84
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::lock() |
85
|
|
|
*/ |
86
|
|
|
public function lock(array $tables, array $modes): void |
87
|
|
|
{ |
88
|
|
|
$this->lockedTables = $tables; |
89
|
|
|
$this->lockedTablesModes = $modes; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* |
94
|
|
|
* {@inheritdoc} |
95
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::unlock() |
96
|
|
|
*/ |
97
|
|
|
public function unlock(): void |
98
|
|
|
{ |
99
|
|
|
// nop |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Special flag wich shows that transaction was started |
104
|
|
|
* |
105
|
|
|
* @var boolean |
106
|
|
|
*/ |
107
|
|
|
public $transactionWasStarted = true; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::startTransaction() |
113
|
|
|
*/ |
114
|
|
|
public function startTransaction(): void |
115
|
|
|
{ |
116
|
|
|
$this->transactionWasStarted = true; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* |
121
|
|
|
* {@inheritdoc} |
122
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::rollback() |
123
|
|
|
*/ |
124
|
|
|
public function rollback(): void |
125
|
|
|
{ |
126
|
|
|
// nop |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Special flag wich shows that commit was performed |
131
|
|
|
* |
132
|
|
|
* @var boolean |
133
|
|
|
*/ |
134
|
|
|
public $commitWasPerformed = false; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* |
138
|
|
|
* {@inheritdoc} |
139
|
|
|
* @see \Mezon\PdoCrud\PdoCrud::commit() |
140
|
|
|
*/ |
141
|
|
|
public function commit(): void |
142
|
|
|
{ |
143
|
|
|
$this->commitWasPerformed = true; |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|