Skip to content

Commit

Permalink
Merge pull request #180 from laminas/renovate/psr-http-message-2.x
Browse files Browse the repository at this point in the history
Allow `psr/http-message:^2`
  • Loading branch information
Ocramius committed May 19, 2023
2 parents 48b755f + 490f16a commit 7dc274a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
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.

48 changes: 25 additions & 23 deletions test/UndisclosedPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 7dc274a

Please sign in to comment.