Skip to content

Commit

Permalink
Merge pull request #73 from laminas/renovate/psr-http-message-2.x
Browse files Browse the repository at this point in the history
Verify `psr/http-message:^2` compatibility
  • Loading branch information
Ocramius committed Jul 24, 2023
2 parents 32076e2 + 4e0a599 commit f07ff33
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"laminas/laminas-validator": "^2.30.1",
"phpunit/phpunit": "^9.6.10",
"psalm/plugin-phpunit": "^0.18.4",
"psr/http-message": "^1.1",
"psr/http-message": "^2.0",
"vimeo/psalm": "^5.13.1"
},
"conflict": {
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

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

16 changes: 4 additions & 12 deletions test/Reader/Http/Psr7ResponseDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Laminas\Feed\Reader\Http\HeaderAwareResponseInterface;
use Laminas\Feed\Reader\Http\Psr7ResponseDecorator;
use Laminas\Feed\Reader\Http\ResponseInterface;
use LaminasTest\Feed\Reader\TestAsset\Psr7Stream;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface as Psr7ResponseInterface;
use Psr\Http\Message\StreamInterface;

/**
* @covers \Laminas\Feed\Reader\Http\Psr7ResponseDecorator
Expand Down Expand Up @@ -56,21 +56,13 @@ public function testProxiesToDecoratedResponseToRetrieveStatusCode(): void

public function testProxiesToDecoratedResponseToRetrieveBody(): void
{
$originalResponse = $this->createMock(Psr7ResponseInterface::class);
$originalResponse
->method('getBody')
$body = $this->createMock(StreamInterface::class);
$body->method('__toString')
->willReturn('BODY');
$decorator = new Psr7ResponseDecorator($originalResponse);
$this->assertSame('BODY', $decorator->getBody());
}

public function testCastsStreamToStringWhenReturningPsr7Body(): void
{
$stream = new Psr7Stream('BODY');
$originalResponse = $this->createMock(Psr7ResponseInterface::class);
$originalResponse
->method('getBody')
->willReturn($stream);
->willReturn($body);
$decorator = new Psr7ResponseDecorator($originalResponse);
$this->assertSame('BODY', $decorator->getBody());
}
Expand Down
12 changes: 3 additions & 9 deletions test/Reader/TestAsset/Psr7Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@
*/
class Psr7Stream
{
/** @var mixed */
private $streamValue;

/** @param mixed $streamValue */
public function __construct($streamValue)
public function __construct(private string $streamValue)
{
$this->streamValue = $streamValue;
}

/** @return string */
public function __toString()
public function __toString(): string
{
return (string) $this->streamValue;
return $this->streamValue;
}
}

0 comments on commit f07ff33

Please sign in to comment.