Skip to content

Commit f62e14d

Browse files
committed
Update test
1 parent 8932340 commit f62e14d

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

tests/Functional/BlobTest.php

+24-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,36 @@ 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[0], Types::INTEGER);
234+
$row[1] = $this->connection->convertToPHPValue($row[1], Types::STRING);
235+
236+
return $row;
237+
},
238+
$this->connection->fetchAllNumeric('SELECT id, blobcolumn FROM blob_table'),
239+
);
240+
241+
self::assertSame([[1, 'test'], [2, 'test'], [3, 'test']], $rows);
224242
}
225243

226244
private function assertBlobContains(string $text): void

0 commit comments

Comments
 (0)