Skip to content

Commit

Permalink
Merge pull request #49 from laminas/renovate/lock-file-maintenance
Browse files Browse the repository at this point in the history
Lock file maintenance
  • Loading branch information
Ocramius authored Aug 7, 2023
2 parents 0879fef + c51a436 commit 634284b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions test/Emitter/SapiStreamEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ static function (int $bufferLength) use (&$peakBufferLength): void {
$stream
->expects($this->atLeastOnce())
->method('rewind')
->will($this->returnCallback([$streamHelper, 'handleRewind']));
$stream->method('seek')->will($this->returnCallback([$streamHelper, 'handleSeek']));
->willReturnCallback([$streamHelper, 'handleRewind']);
$stream->method('seek')->willReturnCallback([$streamHelper, 'handleSeek']);
}

if (! $seekable) {
Expand All @@ -243,8 +243,8 @@ static function (int $bufferLength) use (&$peakBufferLength): void {

if ($readable) {
$stream->expects($this->never())->method('__toString');
$stream->method('eof')->will($this->returnCallback([$streamHelper, 'handleEof']));
$stream->method('read')->will($this->returnCallback([$streamHelper, 'handleRead']));
$stream->method('eof')->willReturnCallback([$streamHelper, 'handleEof']);
$stream->method('read')->willReturnCallback([$streamHelper, 'handleRead']);
}

if (! $readable) {
Expand All @@ -254,10 +254,10 @@ static function (int $bufferLength) use (&$peakBufferLength): void {
$seekable
? $stream
->method('getContents')
->will($this->returnCallback([$streamHelper, 'handleGetContents']))
->willReturnCallback([$streamHelper, 'handleGetContents'])
: $stream->expects($this->never())->method('getContents');

$stream->method('__toString')->will($this->returnCallback([$streamHelper, 'handleToString']));
$stream->method('__toString')->willReturnCallback([$streamHelper, 'handleToString']);
}

$response = (new Response())
Expand Down Expand Up @@ -380,15 +380,15 @@ public function testEmitRangeStreamResponse(
$stream->method('isSeekable')->willReturn($seekable);
$stream->method('isReadable')->willReturn($readable);
$stream->method('getSize')->willReturn($size);
$stream->method('tell')->will($this->returnCallback([$streamHelper, 'handleTell']));
$stream->method('tell')->willReturnCallback([$streamHelper, 'handleTell']);

$stream->expects($this->never())->method('rewind');

if ($seekable) {
$stream
->expects($this->atLeastOnce())
->method('seek')
->will($this->returnCallback([$streamHelper, 'handleSeek']));
->willReturnCallback([$streamHelper, 'handleSeek']);
} else {
$stream->expects($this->never())->method('seek');
}
Expand All @@ -400,19 +400,19 @@ public function testEmitRangeStreamResponse(
->expects($this->atLeastOnce())
->method('read')
->with($this->isType('int'))
->will($this->returnCallback([$streamHelper, 'handleRead']));
->willReturnCallback([$streamHelper, 'handleRead']);
$stream
->expects($this->atLeastOnce())
->method('eof')
->will($this->returnCallback([$streamHelper, 'handleEof']));
->willReturnCallback([$streamHelper, 'handleEof']);
$stream->expects($this->never())->method('getContents');
} else {
$stream->expects($this->never())->method('read');
$stream->expects($this->never())->method('eof');
$stream
->expects($this->atLeastOnce())
->method('getContents')
->will($this->returnCallback([$streamHelper, 'handleGetContents']));
->willReturnCallback([$streamHelper, 'handleGetContents']);
}

$response = (new Response())
Expand Down Expand Up @@ -539,24 +539,24 @@ public function testEmitMemoryUsage(
$stream = $this->createMock(StreamInterface::class);
$stream->method('isSeekable')->willReturn($seekable);
$stream->method('isReadable')->willReturn($readable);
$stream->method('eof')->will($this->returnCallback([$streamHelper, 'handleEof']));
$stream->method('eof')->willReturnCallback([$streamHelper, 'handleEof']);

if ($seekable) {
$stream
->method('seek')
->will($this->returnCallback([$streamHelper, 'handleSeek']));
->willReturnCallback([$streamHelper, 'handleSeek']);
}

if ($readable) {
$stream
->method('read')
->will($this->returnCallback([$streamHelper, 'handleRead']));
->willReturnCallback([$streamHelper, 'handleRead']);
}

if (! $readable) {
$stream
->method('getContents')
->will($this->returnCallback([$streamHelper, 'handleGetContents']));
->willReturnCallback([$streamHelper, 'handleGetContents']);
}

$response = (new Response())
Expand Down
10 changes: 9 additions & 1 deletion test/TestAsset/MockStreamHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use const SEEK_SET;

/**
* @psalm-suppress PossiblyUnusedMethod,PossiblyUnusedParam,PossiblyUnusedReturnValue
* @psalm-suppress PossiblyUnusedMethod
* @psalm-suppress PossiblyUnusedParam
*/
class MockStreamHelper
{
Expand All @@ -35,22 +36,26 @@ public function __construct(
$this->trackPeakBufferLength = $trackPeakBufferLength;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleToString(): string
{
$this->position = $this->size;
return is_callable($this->contents) ? ($this->contents)(0) : $this->contents;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleTell(): int
{
return $this->position;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleEof(): bool
{
return $this->position >= $this->size;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleSeek(int $offset, ?int $whence = SEEK_SET): bool
{
if ($offset >= $this->size) {
Expand All @@ -61,12 +66,14 @@ public function handleSeek(int $offset, ?int $whence = SEEK_SET): bool
return true;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleRewind(): bool
{
$this->position = 0;
return true;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleRead(int $length): string
{
if ($this->trackPeakBufferLength) {
Expand All @@ -82,6 +89,7 @@ public function handleRead(int $length): string
return $data;
}

/** @psalm-suppress PossiblyUnusedReturnValue */
public function handleGetContents(): string
{
$remainingContents = is_callable($this->contents)
Expand Down

0 comments on commit 634284b

Please sign in to comment.