Skip to content

Commit 20ab393

Browse files
fixup! Bump doctrine/dbal from 2.12.0 to 3.0.0
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent 1850cab commit 20ab393

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/lib/AppFramework/Db/MapperTestUtility.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323

2424
namespace Test\AppFramework\Db;
2525

26+
use OCP\DB\IPreparedStatement;
27+
use OCP\DB\IResult;
28+
2629
/**
2730
* Simple utility class for testing mappers
2831
*/
2932
abstract class MapperTestUtility extends \Test\TestCase {
3033
protected $db;
31-
private $query;
34+
private $statement;
3235
private $queryAt;
3336
private $prepareAt;
3437
private $fetchAt;
@@ -47,7 +50,7 @@ protected function setUp(): void {
4750
->disableOriginalConstructor()
4851
->getMock();
4952

50-
$this->query = $this->createMock('\PDOStatement');
53+
$this->statement = $this->createMock(IPreparedStatement::class);
5154
$this->queryAt = 0;
5255
$this->prepareAt = 0;
5356
$this->iterators = [];
@@ -94,34 +97,34 @@ protected function setMapperResult($sql, $arguments = [], $returnRows = [],
9497
$this->db->expects($this->at($this->prepareAt))
9598
->method('prepare')
9699
->with($this->equalTo($sql))
97-
->will(($this->returnValue($this->query)));
100+
->will(($this->returnValue($this->statement)));
98101
} elseif ($limit !== null && $offset === null) {
99102
$this->db->expects($this->at($this->prepareAt))
100103
->method('prepare')
101104
->with($this->equalTo($sql), $this->equalTo($limit))
102-
->will(($this->returnValue($this->query)));
105+
->will(($this->returnValue($this->statement)));
103106
} elseif ($limit === null && $offset !== null) {
104107
$this->db->expects($this->at($this->prepareAt))
105108
->method('prepare')
106109
->with($this->equalTo($sql),
107110
$this->equalTo(null),
108111
$this->equalTo($offset))
109-
->will(($this->returnValue($this->query)));
112+
->will(($this->returnValue($this->statement)));
110113
} else {
111114
$this->db->expects($this->at($this->prepareAt))
112115
->method('prepare')
113116
->with($this->equalTo($sql),
114117
$this->equalTo($limit),
115118
$this->equalTo($offset))
116-
->will(($this->returnValue($this->query)));
119+
->will(($this->returnValue($this->statement)));
117120
}
118121

119122
$this->iterators[] = new ArgumentIterator($returnRows);
120123

121124
$iterators = $this->iterators;
122125
$fetchAt = $this->fetchAt;
123126

124-
$this->query->expects($this->any())
127+
$this->statement->expects($this->any())
125128
->method('fetch')
126129
->willReturnCallback(
127130
function () use ($iterators, $fetchAt) {
@@ -141,7 +144,7 @@ function () use ($iterators, $fetchAt) {
141144
if ($this->isAssocArray($arguments)) {
142145
foreach ($arguments as $key => $argument) {
143146
$pdoConstant = $this->getPDOType($argument);
144-
$this->query->expects($this->at($this->queryAt))
147+
$this->statement->expects($this->at($this->queryAt))
145148
->method('bindValue')
146149
->with($this->equalTo($key),
147150
$this->equalTo($argument),
@@ -152,7 +155,7 @@ function () use ($iterators, $fetchAt) {
152155
$index = 1;
153156
foreach ($arguments as $argument) {
154157
$pdoConstant = $this->getPDOType($argument);
155-
$this->query->expects($this->at($this->queryAt))
158+
$this->statement->expects($this->at($this->queryAt))
156159
->method('bindValue')
157160
->with($this->equalTo($index),
158161
$this->equalTo($argument),
@@ -162,9 +165,10 @@ function () use ($iterators, $fetchAt) {
162165
}
163166
}
164167

165-
$this->query->expects($this->at($this->queryAt))
168+
$this->statement->expects($this->at($this->queryAt))
166169
->method('execute')
167170
->willReturnCallback(function ($sql, $p = null, $o = null, $s = null) {
171+
return $this->createMock(IResult::class);
168172
});
169173
$this->queryAt++;
170174

@@ -175,7 +179,7 @@ function () use ($iterators, $fetchAt) {
175179
} else {
176180
$closing = $this->any();
177181
}
178-
$this->query->expects($closing)->method('closeCursor');
182+
$this->statement->expects($closing)->method('closeCursor');
179183
$this->queryAt++;
180184

181185
$this->prepareAt++;

0 commit comments

Comments
 (0)