Skip to content

Commit e755ec2

Browse files
Merge branch '6.2' into 6.3
* 6.2: [Tests] Remove occurrences of `withConsecutive()` Fix support binary values in parameters. [Dotenv] Improve Dotenv::usePutenv phpdoc
2 parents 3fb8929 + 4bf2bab commit e755ec2

File tree

1 file changed

+54
-41
lines changed

1 file changed

+54
-41
lines changed

Tests/Store/DoctrineDbalStoreTest.php

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,27 @@ public static function provideDsn()
9494
public function testCreatesTableInTransaction(string $platform)
9595
{
9696
$conn = $this->createMock(Connection::class);
97+
98+
$series = [
99+
[$this->stringContains('INSERT INTO'), $this->createMock(TableNotFoundException::class)],
100+
[$this->matches('create sql stmt'), 1],
101+
[$this->stringContains('INSERT INTO'), 1],
102+
];
103+
97104
$conn->expects($this->atLeast(3))
98105
->method('executeStatement')
99-
->withConsecutive(
100-
[$this->stringContains('INSERT INTO')],
101-
[$this->matches('create sql stmt')],
102-
[$this->stringContains('INSERT INTO')]
103-
)
104-
->will(
105-
$this->onConsecutiveCalls(
106-
$this->throwException(
107-
$this->createMock(TableNotFoundException::class)
108-
),
109-
1,
110-
1
111-
)
112-
);
106+
->willReturnCallback(function ($sql) use (&$series) {
107+
if ([$constraint, $return] = array_shift($series)) {
108+
$constraint->evaluate($sql);
109+
}
110+
111+
if ($return instanceof \Exception) {
112+
throw $return;
113+
}
114+
115+
return $return ?? 1;
116+
})
117+
;
113118

114119
$conn->method('isTransactionActive')
115120
->willReturn(true);
@@ -140,21 +145,25 @@ public static function providePlatforms()
140145
public function testTableCreationInTransactionNotSupported()
141146
{
142147
$conn = $this->createMock(Connection::class);
148+
149+
$series = [
150+
[$this->stringContains('INSERT INTO'), $this->createMock(TableNotFoundException::class)],
151+
[$this->stringContains('INSERT INTO'), 1],
152+
];
153+
143154
$conn->expects($this->atLeast(2))
144155
->method('executeStatement')
145-
->withConsecutive(
146-
[$this->stringContains('INSERT INTO')],
147-
[$this->stringContains('INSERT INTO')]
148-
)
149-
->will(
150-
$this->onConsecutiveCalls(
151-
$this->throwException(
152-
$this->createMock(TableNotFoundException::class)
153-
),
154-
1,
155-
1
156-
)
157-
);
156+
->willReturnCallback(function ($sql) use (&$series) {
157+
[$constraint, $return] = array_shift($series);
158+
$constraint->evaluate($sql);
159+
160+
if ($return instanceof \Exception) {
161+
throw $return;
162+
}
163+
164+
return $return;
165+
})
166+
;
158167

159168
$conn->method('isTransactionActive')
160169
->willReturn(true);
@@ -176,22 +185,26 @@ public function testTableCreationInTransactionNotSupported()
176185
public function testCreatesTableOutsideTransaction()
177186
{
178187
$conn = $this->createMock(Connection::class);
188+
189+
$series = [
190+
[$this->stringContains('INSERT INTO'), $this->createMock(TableNotFoundException::class)],
191+
[$this->matches('create sql stmt'), 1],
192+
[$this->stringContains('INSERT INTO'), 1],
193+
];
194+
179195
$conn->expects($this->atLeast(3))
180196
->method('executeStatement')
181-
->withConsecutive(
182-
[$this->stringContains('INSERT INTO')],
183-
[$this->matches('create sql stmt')],
184-
[$this->stringContains('INSERT INTO')]
185-
)
186-
->will(
187-
$this->onConsecutiveCalls(
188-
$this->throwException(
189-
$this->createMock(TableNotFoundException::class)
190-
),
191-
1,
192-
1
193-
)
194-
);
197+
->willReturnCallback(function ($sql) use (&$series) {
198+
[$constraint, $return] = array_shift($series);
199+
$constraint->evaluate($sql);
200+
201+
if ($return instanceof \Exception) {
202+
throw $return;
203+
}
204+
205+
return $return;
206+
})
207+
;
195208

196209
$conn->method('isTransactionActive')
197210
->willReturn(false);

0 commit comments

Comments
 (0)