diff --git a/composer.json b/composer.json index 22b0327e..70821399 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "php": "~8.1.0 || ~8.2.0", "laminas/laminas-servicemanager": "^3.21.0", "laminas/laminas-stdlib": "^3.13", - "psr/http-message": "^1.0.1" + "psr/http-message": "^1.0.1 || ^2.0.0" }, "require-dev": { "laminas/laminas-coding-standard": "^2.5", diff --git a/composer.lock b/composer.lock index fa55e404..0934d181 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "671699eed93da1cc140c6748469431c6", + "content-hash": "eb37ce2f739caa3d260d01a63bf8a692", "packages": [ { "name": "laminas/laminas-servicemanager", @@ -206,16 +206,16 @@ }, { "name": "psr/http-message", - "version": "1.1", + "version": "2.0", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", - "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", "shasum": "" }, "require": { @@ -224,7 +224,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -239,7 +239,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for HTTP messages", @@ -253,9 +253,9 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-message/tree/1.1" + "source": "https://github.com/php-fig/http-message/tree/2.0" }, - "time": "2023-04-04T09:50:52+00:00" + "time": "2023-04-04T09:54:51+00:00" } ], "packages-dev": [ diff --git a/test/UndisclosedPasswordTest.php b/test/UndisclosedPasswordTest.php index 4da0e462..1b829004 100644 --- a/test/UndisclosedPasswordTest.php +++ b/test/UndisclosedPasswordTest.php @@ -15,6 +15,7 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; use ReflectionClass; use stdClass; @@ -26,16 +27,11 @@ final class UndisclosedPasswordTest extends TestCase { - /** @var ClientInterface&MockObject */ - private ClientInterface $httpClient; - - /** @var RequestFactoryInterface&MockObject */ - private RequestFactoryInterface $httpRequest; - - /** @var ResponseInterface&MockObject */ - private ResponseInterface $httpResponse; - + private ClientInterface&MockObject $httpClient; + private RequestFactoryInterface&MockObject $httpRequest; + private ResponseInterface&MockObject $httpResponse; private UndisclosedPassword $validator; + private StreamInterface&MockObject $stream; /** {@inheritDoc} */ protected function setUp(): void @@ -45,8 +41,8 @@ protected function setUp(): void $this->httpClient = $this->createMock(ClientInterface::class); $this->httpRequest = $this->createMock(RequestFactoryInterface::class); $this->httpResponse = $this->createMock(ResponseInterface::class); - - $this->validator = new UndisclosedPassword($this->httpClient, $this->httpRequest); + $this->validator = new UndisclosedPassword($this->httpClient, $this->httpRequest); + $this->stream = $this->createMock(StreamInterface::class); } /** @@ -114,7 +110,7 @@ public function testStrongUnseenPasswordsPassValidation(string $password): void $this->httpResponse ->expects(self::once()) ->method('getBody') - ->willReturnCallback(function (): string { + ->willReturnCallback(function (): StreamInterface { $hash = sha1('laminas-validator'); $constant = $this->getConstant( @@ -123,11 +119,14 @@ public function testStrongUnseenPasswordsPassValidation(string $password): void ); self::assertIsInt($constant); - return sprintf( - '%s:%d', - strtoupper(substr($hash, $constant)), - random_int(0, 100000) - ); + $this->stream->method('__toString') + ->willReturn(sprintf( + '%s:%d', + strtoupper(substr($hash, $constant)), + random_int(0, 100000) + )); + + return $this->stream; }); $this->httpClient @@ -148,7 +147,7 @@ public function testBreachedPasswordsDoNotPassValidation(string $password): void $this->httpResponse ->expects(self::once()) ->method('getBody') - ->willReturnCallback(function () use ($password): string { + ->willReturnCallback(function () use ($password): StreamInterface { $hash = sha1($password); $constant = $this->getConstant( @@ -158,11 +157,14 @@ public function testBreachedPasswordsDoNotPassValidation(string $password): void self::assertIsInt($constant); - return sprintf( - '%s:%d', - strtoupper(substr($hash, $constant)), - random_int(0, 100000) - ); + $this->stream->method('__toString') + ->willReturn(sprintf( + '%s:%d', + strtoupper(substr($hash, $constant)), + random_int(0, 100000) + )); + + return $this->stream; }); $this->httpClient