77use PHPUnit \Framework \Attributes \Test ;
88use Tempest \Http \Session \FormSession ;
99use Tempest \Http \Session \Session ;
10+ use Tempest \Validation \FailingRule ;
1011use Tempest \Validation \Rules \HasLength ;
1112use Tests \Tempest \Integration \FrameworkIntegrationTestCase ;
1213
@@ -27,8 +28,8 @@ final class FormSessionTest extends FrameworkIntegrationTestCase
2728 public function flash_errors_stores_errors (): void
2829 {
2930 $ errors = [
30- 'name ' => [new HasLength (min: 3 )],
31- 'email ' => [new HasLength (min: 5 )],
31+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
32+ 'email ' => [new FailingRule ( new HasLength (min: 5 ) )],
3233 ];
3334
3435 $ this ->formSession ->setErrors ($ errors );
@@ -39,8 +40,8 @@ public function flash_errors_stores_errors(): void
3940 #[Test]
4041 public function errors_for_returns_field_specific_errors (): void
4142 {
42- $ nameError = new HasLength (min: 3 );
43- $ emailError = new HasLength (min: 5 );
43+ $ nameError = new FailingRule ( new HasLength (min: 3 ) );
44+ $ emailError = new FailingRule ( new HasLength (min: 5 ) );
4445
4546 $ this ->formSession ->setErrors ([
4647 'name ' => [$ nameError ],
@@ -55,7 +56,7 @@ public function errors_for_returns_field_specific_errors(): void
5556 public function errors_for_returns_empty_array_when_field_has_no_errors (): void
5657 {
5758 $ this ->formSession ->setErrors ([
58- 'name ' => [new HasLength (min: 3 )],
59+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
5960 ]);
6061
6162 $ this ->assertEquals ([], $ this ->formSession ->getErrorsFor ('email ' ));
@@ -65,7 +66,7 @@ public function errors_for_returns_empty_array_when_field_has_no_errors(): void
6566 public function has_errors_returns_true_when_errors_exist (): void
6667 {
6768 $ this ->formSession ->setErrors ([
68- 'name ' => [new HasLength (min: 3 )],
69+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
6970 ]);
7071
7172 $ this ->assertTrue ($ this ->formSession ->hasErrors ());
@@ -81,7 +82,7 @@ public function has_errors_returns_false_when_no_errors(): void
8182 public function has_error_returns_true_when_field_has_errors (): void
8283 {
8384 $ this ->formSession ->setErrors ([
84- 'name ' => [new HasLength (min: 3 )],
85+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
8586 ]);
8687
8788 $ this ->assertTrue ($ this ->formSession ->hasError ('name ' ));
@@ -91,7 +92,7 @@ public function has_error_returns_true_when_field_has_errors(): void
9192 public function has_error_returns_false_when_field_has_no_errors (): void
9293 {
9394 $ this ->formSession ->setErrors ([
94- 'name ' => [new HasLength (min: 3 )],
95+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
9596 ]);
9697
9798 $ this ->assertFalse ($ this ->formSession ->hasError ('email ' ));
@@ -143,7 +144,7 @@ public function value_returns_default_when_field_not_found(): void
143144 public function clear_removes_errors_and_values (): void
144145 {
145146 $ this ->formSession ->setErrors ([
146- 'name ' => [new HasLength (min: 3 )],
147+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
147148 ]);
148149 $ this ->formSession ->setOriginalValues ([
149150 'name ' => 'John ' ,
@@ -159,7 +160,7 @@ public function clear_removes_errors_and_values(): void
159160 public function errors_are_flashed_and_cleared_after_next_request (): void
160161 {
161162 $ this ->formSession ->setErrors ([
162- 'name ' => [new HasLength (min: 3 )],
163+ 'name ' => [new FailingRule ( new HasLength (min: 3 ) )],
163164 ]);
164165
165166 // First access - errors exist
0 commit comments