Skip to content

Commit b3327ed

Browse files
authored
Raise yiisoft/hydrator-validator to ^2.0 (#34)
1 parent 5b229f4 commit b3327ed

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"psr/http-server-middleware": "^1.0",
4040
"yiisoft/arrays": "^3.0",
4141
"yiisoft/hydrator": "^1.0",
42-
"yiisoft/hydrator-validator": "^1.0",
42+
"yiisoft/hydrator-validator": "^2.0",
4343
"yiisoft/middleware-dispatcher": "^5.1",
4444
"yiisoft/validator": "^1.1",
4545
"yiisoft/request-provider": "^1.0"

src/RequestInputParametersResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private function processValidation(mixed $value): void
7878
}
7979

8080
$result = $value->getValidationResult();
81-
if ($result !== null && !$result->isValid()) {
81+
if (!$result->isValid()) {
8282
throw new InputValidationException($result);
8383
}
8484
}

tests/RequestInputParametersResolverTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Yiisoft\Input\Http\Tests;
66

77
use Closure;
8+
use LogicException;
89
use PHPUnit\Framework\Attributes\DataProvider;
910
use PHPUnit\Framework\TestCase;
1011
use Psr\Http\Message\ServerRequestInterface;
@@ -98,8 +99,11 @@ public function testWithNonValidatingHydrator(): void
9899
$input = $result['input'];
99100

100101
$this->assertInstanceOf(PersonInput::class, $input);
101-
$this->assertNull($input->getValidationResult());
102102
$this->assertSame('Bo', $input->name);
103+
104+
$this->expectException(LogicException::class);
105+
$this->expectExceptionMessage('Validation result is not set.');
106+
$input->getValidationResult();
103107
}
104108

105109
public function testDoNotThrowExceptionForNonValidatedInput(): void
@@ -141,7 +145,7 @@ public function testDoNotThrowExceptionForValidInput(): void
141145
$this->assertSame('Bo', $result['input']->name);
142146
}
143147

144-
public function testDoNotThrowExceptionForValidatedInputWithoutValidation(): void
148+
public function testValidatedInputWithoutValidation(): void
145149
{
146150
$request = $this->createMock(ServerRequestInterface::class);
147151
$request->method('getQueryParams')->willReturn(['name' => 'Bo']);
@@ -153,9 +157,9 @@ public function testDoNotThrowExceptionForValidatedInputWithoutValidation(): voi
153157
);
154158
$parameters = TestHelper::getParameters(static fn(PersonInput $input) => null);
155159

156-
$result = $resolver->resolve($parameters, $request);
157-
158-
$this->assertSame('Bo', $result['input']->name);
160+
$this->expectException(LogicException::class);
161+
$this->expectExceptionMessage('Validation result is not set.');
162+
$resolver->resolve($parameters, $request);
159163
}
160164

161165
public function testThrowExceptionForInvalidInput(): void

0 commit comments

Comments
 (0)