Skip to content

Commit 4bf2bab

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

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
@@ -93,22 +93,27 @@ public static function provideDsn()
9393
public function testCreatesTableInTransaction(string $platform)
9494
{
9595
$conn = $this->createMock(Connection::class);
96+
97+
$series = [
98+
[$this->stringContains('INSERT INTO'), $this->createMock(TableNotFoundException::class)],
99+
[$this->matches('create sql stmt'), 1],
100+
[$this->stringContains('INSERT INTO'), 1],
101+
];
102+
96103
$conn->expects($this->atLeast(3))
97104
->method('executeStatement')
98-
->withConsecutive(
99-
[$this->stringContains('INSERT INTO')],
100-
[$this->matches('create sql stmt')],
101-
[$this->stringContains('INSERT INTO')]
102-
)
103-
->will(
104-
$this->onConsecutiveCalls(
105-
$this->throwException(
106-
$this->createMock(TableNotFoundException::class)
107-
),
108-
1,
109-
1
110-
)
111-
);
105+
->willReturnCallback(function ($sql) use (&$series) {
106+
if ([$constraint, $return] = array_shift($series)) {
107+
$constraint->evaluate($sql);
108+
}
109+
110+
if ($return instanceof \Exception) {
111+
throw $return;
112+
}
113+
114+
return $return ?? 1;
115+
})
116+
;
112117

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

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

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

0 commit comments

Comments
 (0)