55namespace Yiisoft \Input \Http \Tests ;
66
77use Closure ;
8+ use LogicException ;
89use PHPUnit \Framework \Attributes \DataProvider ;
910use PHPUnit \Framework \TestCase ;
1011use 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