Skip to content

Commit ffea44b

Browse files
committed
fix test, write should return the amount of signes it wrote on steam
1 parent 6b0b73f commit ffea44b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: tests/Unit/Middleware/ExceptionMiddlewareTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Chubbyphp\HttpException\HttpException;
99
use Chubbyphp\Mock\MockMethod\WithCallback;
1010
use Chubbyphp\Mock\MockMethod\WithException;
11-
use Chubbyphp\Mock\MockMethod\WithoutReturn;
1211
use Chubbyphp\Mock\MockMethod\WithReturn;
1312
use Chubbyphp\Mock\MockMethod\WithReturnSelf;
1413
use Chubbyphp\Mock\MockObjectBuilder;
@@ -212,7 +211,7 @@ public function testProcessWithClientHttpExceptionWithoutLogger(): void
212211

213212
/** @var MockObject|StreamInterface $responseBody */
214213
$responseBody = $builder->create(StreamInterface::class, [
215-
new WithoutReturn('write', [$expectedBody]),
214+
new WithReturn('write', [$expectedBody], \strlen($expectedBody)),
216215
]);
217216

218217
/** @var MockObject|ResponseInterface $response */
@@ -397,7 +396,7 @@ public function testProcessWithClientHttpExceptionWithLogger(): void
397396

398397
/** @var MockObject|StreamInterface $responseBody */
399398
$responseBody = $builder->create(StreamInterface::class, [
400-
new WithoutReturn('write', [$expectedBody]),
399+
new WithReturn('write', [$expectedBody], \strlen($expectedBody)),
401400
]);
402401

403402
/** @var MockObject|ResponseInterface $response */
@@ -616,7 +615,7 @@ public function testProcessWithServerHttpExceptionWithDebugWithLogger(): void
616615

617616
/** @var MockObject|StreamInterface $responseBody */
618617
$responseBody = $builder->create(StreamInterface::class, [
619-
new WithoutReturn('write', [$expectedBody]),
618+
new WithReturn('write', [$expectedBody], \strlen($expectedBody)),
620619
]);
621620

622621
/** @var MockObject|ResponseInterface $response */
@@ -688,7 +687,7 @@ public function testProcessWithExceptionWithDebugWithLogger(): void
688687

689688
/** @var MockObject|StreamInterface $responseBody */
690689
$responseBody = $builder->create(StreamInterface::class, [
691-
new WithCallback('write', static function (string $html): void {
690+
new WithCallback('write', static function (string $html): int {
692691
self::assertStringContainsString(
693692
'<p>A website error has occurred. Sorry for the temporary inconvenience.</p>',
694693
$html
@@ -706,6 +705,8 @@ public function testProcessWithExceptionWithDebugWithLogger(): void
706705
self::assertStringContainsString('<div class="md:col-span-7">logic exception</div>', $html);
707706
self::assertStringContainsString('<div><strong>Code</strong></div>', $html);
708707
self::assertStringContainsString('<div class="md:col-span-7">42</div>', $html);
708+
709+
return \strlen($html);
709710
}),
710711
]);
711712

0 commit comments

Comments
 (0)