@@ -435,16 +435,6 @@ public function testCanGetValidationMessages()
435
435
}
436
436
}
437
437
438
- /**
439
- * Idea for this one is that one input may only need to be validated if another input is present.
440
- *
441
- * Commenting out for now, as validation context may make this irrelevant, and unsure what API to expose.
442
- public function testCanConditionallyInvokeValidators()
443
- {
444
- $this->markTestIncomplete();
445
- }
446
- */
447
-
448
438
/*
449
439
* Idea for this one is that validation may need to rely on context -- e.g., a "password confirmation"
450
440
* field may need to know what the original password entered was in order to compare.
@@ -523,32 +513,6 @@ public function testContextIsTheSameWhenARequiredInputIsGivenAndOptionalInputIsM
523
513
);
524
514
}
525
515
526
- public function testValidationCanUseContext ()
527
- {
528
- $ filter = new InputFilter ();
529
-
530
- $ store = new stdClass ;
531
- $ foo = new Input ();
532
- $ foo ->getValidatorChain ()->attach (new Validator \Callback (function ($ value , $ context ) use ($ store ) {
533
- $ store ->value = $ value ;
534
- $ store ->context = $ context ;
535
- return true ;
536
- }));
537
-
538
- $ bar = new Input ();
539
- $ bar ->getValidatorChain ()->attach (new Validator \Digits ());
540
-
541
- $ filter ->add ($ foo , 'foo ' )
542
- ->add ($ bar , 'bar ' );
543
-
544
- $ data = ['foo ' => 'foo ' , 'bar ' => 123 ];
545
- $ filter ->setData ($ data );
546
-
547
- $ this ->assertTrue ($ filter ->isValid ());
548
- $ this ->assertEquals ('foo ' , $ store ->value );
549
- $ this ->assertEquals ($ data , $ store ->context );
550
- }
551
-
552
516
/**
553
517
* Idea here is that you can indicate that if validation for a particular input fails, we should not
554
518
* attempt any further validation of any other inputs.
@@ -714,48 +678,6 @@ public function testValidationMarksInputInvalidWhenRequiredAndAllowEmptyFlagIsFa
714
678
$ this ->assertFalse ($ filter ->isValid ());
715
679
}
716
680
717
- public static function contextDataProvider ()
718
- {
719
- return [
720
- ['' , 'y ' , true ],
721
- ['' , 'n ' , false ],
722
- ];
723
- }
724
-
725
- /**
726
- * Idea here is that an empty field may or may not be valid based on
727
- * context.
728
- */
729
- /**
730
- * @dataProvider contextDataProvider()
731
- */
732
- // @codingStandardsIgnoreStart
733
- public function testValidationMarksInputValidWhenAllowEmptyFlagIsTrueAndContinueIfEmptyIsTrueAndContextValidatesEmptyField ($ allowEmpty , $ blankIsValid , $ valid )
734
- {
735
- // @codingStandardsIgnoreEnd
736
- $ filter = new InputFilter ();
737
-
738
- $ data = [
739
- 'allowEmpty ' => $ allowEmpty ,
740
- 'blankIsValid ' => $ blankIsValid ,
741
- ];
742
-
743
- $ allowEmpty = new Input ();
744
- $ allowEmpty ->setAllowEmpty (true )
745
- ->setContinueIfEmpty (true );
746
-
747
- $ blankIsValid = new Input ();
748
- $ blankIsValid ->getValidatorChain ()->attach (new Validator \Callback (function ($ value , $ context ) {
749
- return ('y ' === $ value && empty ($ context ['allowEmpty ' ]));
750
- }));
751
-
752
- $ filter ->add ($ allowEmpty , 'allowEmpty ' )
753
- ->add ($ blankIsValid , 'blankIsValid ' );
754
- $ filter ->setData ($ data );
755
-
756
- $ this ->assertSame ($ valid , $ filter ->isValid ());
757
- }
758
-
759
681
public function testCanRetrieveRawValuesIndividuallyWithoutValidating ()
760
682
{
761
683
if (!extension_loaded ('intl ' )) {
0 commit comments