Skip to content

Commit 904f4b5

Browse files
committed
Update test
1 parent 8932340 commit 904f4b5

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

tests/Functional/BlobTest.php

+28-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
use Doctrine\DBAL\Types\Type;
1010
use Doctrine\DBAL\Types\Types;
1111

12+
use function array_map;
13+
use function assert;
1214
use function fopen;
1315
use function fseek;
14-
use function ftell;
1516
use function fwrite;
1617
use function str_repeat;
1718
use function stream_get_contents;
@@ -208,19 +209,40 @@ public function testBindValueResetsStream(): void
208209
}
209210

210211
$stmt = $this->connection->prepare(
211-
"INSERT INTO blob_table(id, clobcolumn, blobcolumn) VALUES (1, 'ignored', ?)",
212+
"INSERT INTO blob_table(id, clobcolumn, blobcolumn) VALUES (?, 'ignored', ?)",
212213
);
213214

214215
$stream = fopen('php://temp', 'rb+');
216+
assert($stream !== false);
217+
215218
fwrite($stream, 'a test');
216219
fseek($stream, 2);
217-
$stmt->bindValue(1, $stream, ParameterType::LARGE_OBJECT);
220+
$stmt->bindValue(1, 1, ParameterType::INTEGER);
221+
$stmt->bindValue(2, $stream, ParameterType::LARGE_OBJECT);
218222

219-
$stmt->execute();
223+
$stmt->executeStatement();
220224

221-
self::assertEquals(2, ftell($stream), 'Resource parameter should be reset to position before execute.');
225+
$stmt->bindValue(1, 2, ParameterType::INTEGER);
226+
$stmt->executeStatement();
222227

223-
$this->assertBlobContains('test');
228+
$stmt->bindValue(1, 3, ParameterType::INTEGER);
229+
$stmt->executeStatement();
230+
231+
$rows = array_map(
232+
function (array $row): array {
233+
$row[0] = $this->connection->convertToPHPValue($row[1], Types::INTEGER);
234+
235+
$resource = $this->connection->convertToPHPValue($row[1], Types::BLOB);
236+
237+
self::assertIsResource($resource);
238+
$row[1] = stream_get_contents($resource);
239+
240+
return $row;
241+
},
242+
$this->connection->fetchAllNumeric('SELECT id, blobcolumn FROM blob_table'),
243+
);
244+
245+
self::assertSame([[1, 'test'], [2, 'test'], [3, 'test']], $rows);
224246
}
225247

226248
private function assertBlobContains(string $text): void

0 commit comments

Comments
 (0)