Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit dea31b2

Browse files
committed
Remove test about Input setters permutation
These tests asserts the state of Input is always the same not matter the order when invoke the setters. Sometime ago there was specific tweaks where setterA change the default value for propertieB. This feature was removed so this tests are verifyng "Feature X" not longer exists. PD: setRequired is already verified by testRequiredFlagIsMutable
1 parent eccaff9 commit dea31b2

File tree

1 file changed

+8
-152
lines changed

1 file changed

+8
-152
lines changed

test/InputTest.php

+8-152
Original file line numberDiff line numberDiff line change
@@ -411,34 +411,6 @@ public function testMergeRetainsAllowEmptyFlag()
411411
$this->assertTrue($input2->allowEmpty());
412412
}
413413

414-
/**
415-
* @group 7445
416-
*/
417-
public function testInputIsValidWhenUsingSetRequiredAtStart()
418-
{
419-
$input = new Input();
420-
$input->setName('foo')
421-
->setRequired(false)
422-
->setAllowEmpty(false)
423-
->setContinueIfEmpty(false);
424-
425-
$this->assertTrue($input->isValid());
426-
}
427-
428-
/**
429-
* @group 7445
430-
*/
431-
public function testInputIsValidWhenUsingSetRequiredAtEnd()
432-
{
433-
$input = new Input();
434-
$input->setName('foo')
435-
->setAllowEmpty(false)
436-
->setContinueIfEmpty(false)
437-
->setRequired(false);
438-
439-
$this->assertTrue($input->isValid());
440-
}
441-
442414
public function whenRequiredAndAllowEmptyAndNotContinueIfEmptyValidatorsAreNotRun()
443415
{
444416
$validator = new Validator\Callback(function ($value) {
@@ -451,19 +423,10 @@ public function whenRequiredAndAllowEmptyAndNotContinueIfEmptyValidatorsAreNotRu
451423
->setContinueIfEmpty(false)
452424
->getValidatorChain()->attach($validator);
453425

454-
$requiredLast = new Input('foo');
455-
$requiredLast->setAllowEmpty(true)
456-
->setContinueIfEmpty(false)
457-
->setRequired(true)
458-
->getValidatorChain()->attach($validator);
459-
460426
return [
461427
'required-first-null' => [$requiredFirst, null],
462-
'required-last-null' => [$requiredLast, null],
463428
'required-first-empty' => [$requiredFirst, ''],
464-
'required-last-empty' => [$requiredLast, ''],
465429
'required-first-array' => [$requiredFirst, []],
466-
'required-last-array' => [$requiredLast, []],
467430
];
468431
}
469432

@@ -494,42 +457,22 @@ public function whenRequiredAndAllowEmptyAndContinueIfEmptyValidatorsAreRun()
494457
});
495458

496459
$requiredFirstInvalid = new Input('foo');
460+
$requiredFirstInvalid->getValidatorChain()->attach($alwaysInvalid);
497461
$requiredFirstValid = new Input('foo');
462+
$requiredFirstValid->getValidatorChain()->attach($emptyIsValid);
498463
foreach ([$requiredFirstValid, $requiredFirstInvalid] as $input) {
499464
$input->setRequired(true)
500465
->setAllowEmpty(true)
501466
->setContinueIfEmpty(true);
502467
}
503468

504-
$requiredLastInvalid = new Input('foo');
505-
$requiredLastValid = new Input('foo');
506-
foreach ([$requiredLastValid, $requiredLastInvalid] as $input) {
507-
$input->setAllowEmpty(true)
508-
->setContinueIfEmpty(true)
509-
->setRequired(true);
510-
}
511-
512-
foreach ([$requiredFirstValid, $requiredLastValid] as $input) {
513-
$input->getValidatorChain()->attach($emptyIsValid);
514-
}
515-
516-
foreach ([$requiredFirstInvalid, $requiredLastInvalid] as $input) {
517-
$input->getValidatorChain()->attach($alwaysInvalid);
518-
}
519-
520469
return [
521470
'required-first-null-valid' => [$requiredFirstValid, null, 'assertTrue'],
522471
'required-first-null-invalid' => [$requiredFirstInvalid, null, 'assertFalse'],
523-
'required-last-null-valid' => [$requiredLastValid, null, 'assertTrue'],
524-
'required-last-null-invalid' => [$requiredLastInvalid, null, 'assertFalse'],
525472
'required-first-empty-valid' => [$requiredFirstValid, '', 'assertTrue'],
526473
'required-first-empty-invalid' => [$requiredFirstInvalid, '', 'assertFalse'],
527-
'required-last-empty-valid' => [$requiredLastValid, '', 'assertTrue'],
528-
'required-last-empty-invalid' => [$requiredLastInvalid, '', 'assertFalse'],
529474
'required-first-array-valid' => [$requiredFirstValid, [], 'assertTrue'],
530475
'required-first-array-invalid' => [$requiredFirstInvalid, [], 'assertFalse'],
531-
'required-last-array-valid' => [$requiredLastValid, [], 'assertTrue'],
532-
'required-last-array-invalid' => [$requiredLastInvalid, [], 'assertFalse'],
533476
];
534477
}
535478

@@ -555,19 +498,10 @@ public function whenRequiredAndNotAllowEmptyAndNotContinueIfEmptyValidatorsAreNo
555498
->setContinueIfEmpty(false)
556499
->getValidatorChain()->attach($validator);
557500

558-
$requiredLast = new Input('foo');
559-
$requiredLast->setAllowEmpty(false)
560-
->setContinueIfEmpty(false)
561-
->setRequired(true)
562-
->getValidatorChain()->attach($validator);
563-
564501
return [
565502
'required-first-null' => [$requiredFirst, null],
566-
'required-last-null' => [$requiredLast, null],
567503
'required-first-empty' => [$requiredFirst, ''],
568-
'required-last-empty' => [$requiredLast, ''],
569504
'required-first-array' => [$requiredFirst, []],
570-
'required-last-array' => [$requiredLast, []],
571505
];
572506
}
573507

@@ -598,42 +532,22 @@ public function whenRequiredAndNotAllowEmptyAndContinueIfEmptyValidatorsAreRun()
598532
});
599533

600534
$requiredFirstInvalid = new Input('foo');
535+
$requiredFirstInvalid->getValidatorChain()->attach($alwaysInvalid);
601536
$requiredFirstValid = new Input('foo');
537+
$requiredFirstValid->getValidatorChain()->attach($emptyIsValid);
602538
foreach ([$requiredFirstValid, $requiredFirstInvalid] as $input) {
603539
$input->setRequired(true)
604540
->setAllowEmpty(false)
605541
->setContinueIfEmpty(true);
606542
}
607543

608-
$requiredLastInvalid = new Input('foo');
609-
$requiredLastValid = new Input('foo');
610-
foreach ([$requiredLastValid, $requiredLastInvalid] as $input) {
611-
$input->setAllowEmpty(false)
612-
->setContinueIfEmpty(true)
613-
->setRequired(true);
614-
}
615-
616-
foreach ([$requiredFirstValid, $requiredLastValid] as $input) {
617-
$input->getValidatorChain()->attach($emptyIsValid);
618-
}
619-
620-
foreach ([$requiredFirstInvalid, $requiredLastInvalid] as $input) {
621-
$input->getValidatorChain()->attach($alwaysInvalid);
622-
}
623-
624544
return [
625545
'required-first-null-valid' => [$requiredFirstValid, null, 'assertTrue'],
626546
'required-first-null-invalid' => [$requiredFirstInvalid, null, 'assertFalse'],
627-
'required-last-null-valid' => [$requiredLastValid, null, 'assertTrue'],
628-
'required-last-null-invalid' => [$requiredLastInvalid, null, 'assertFalse'],
629547
'required-first-empty-valid' => [$requiredFirstValid, '', 'assertTrue'],
630548
'required-first-empty-invalid' => [$requiredFirstInvalid, '', 'assertFalse'],
631-
'required-last-empty-valid' => [$requiredLastValid, '', 'assertTrue'],
632-
'required-last-empty-invalid' => [$requiredLastInvalid, '', 'assertFalse'],
633549
'required-first-array-valid' => [$requiredFirstValid, [], 'assertTrue'],
634550
'required-first-array-invalid' => [$requiredFirstInvalid, [], 'assertFalse'],
635-
'required-last-array-valid' => [$requiredLastValid, [], 'assertTrue'],
636-
'required-last-array-invalid' => [$requiredLastInvalid, [], 'assertFalse'],
637551
];
638552
}
639553

@@ -659,19 +573,10 @@ public function whenNotRequiredAndAllowEmptyAndNotContinueIfEmptyValidatorsAreNo
659573
->setContinueIfEmpty(false)
660574
->getValidatorChain()->attach($validator);
661575

662-
$requiredLast = new Input('foo');
663-
$requiredLast->setAllowEmpty(true)
664-
->setContinueIfEmpty(false)
665-
->setRequired(false)
666-
->getValidatorChain()->attach($validator);
667-
668576
return [
669577
'required-first-null' => [$requiredFirst, null],
670-
'required-last-null' => [$requiredLast, null],
671578
'required-first-empty' => [$requiredFirst, ''],
672-
'required-last-empty' => [$requiredLast, ''],
673579
'required-first-array' => [$requiredFirst, []],
674-
'required-last-array' => [$requiredLast, []],
675580
];
676581
}
677582

@@ -697,19 +602,10 @@ public function whenNotRequiredAndNotAllowEmptyAndNotContinueIfEmptyValidatorsAr
697602
->setContinueIfEmpty(false)
698603
->getValidatorChain()->attach($validator);
699604

700-
$requiredLast = new Input('foo');
701-
$requiredLast->setAllowEmpty(false)
702-
->setContinueIfEmpty(false)
703-
->setRequired(false)
704-
->getValidatorChain()->attach($validator);
705-
706605
return [
707606
'required-first-null' => [$requiredFirst, null],
708-
'required-last-null' => [$requiredLast, null],
709607
'required-first-empty' => [$requiredFirst, ''],
710-
'required-last-empty' => [$requiredLast, ''],
711608
'required-first-array' => [$requiredFirst, []],
712-
'required-last-array' => [$requiredLast, []],
713609
];
714610
}
715611

@@ -740,42 +636,22 @@ public function whenNotRequiredAndAllowEmptyAndContinueIfEmptyValidatorsAreRun()
740636
});
741637

742638
$requiredFirstInvalid = new Input('foo');
639+
$requiredFirstInvalid->getValidatorChain()->attach($alwaysInvalid);
743640
$requiredFirstValid = new Input('foo');
641+
$requiredFirstValid->getValidatorChain()->attach($emptyIsValid);
744642
foreach ([$requiredFirstValid, $requiredFirstInvalid] as $input) {
745643
$input->setRequired(false)
746644
->setAllowEmpty(true)
747645
->setContinueIfEmpty(true);
748646
}
749647

750-
$requiredLastInvalid = new Input('foo');
751-
$requiredLastValid = new Input('foo');
752-
foreach ([$requiredLastValid, $requiredLastInvalid] as $input) {
753-
$input->setAllowEmpty(true)
754-
->setContinueIfEmpty(true)
755-
->setRequired(false);
756-
}
757-
758-
foreach ([$requiredFirstValid, $requiredLastValid] as $input) {
759-
$input->getValidatorChain()->attach($emptyIsValid);
760-
}
761-
762-
foreach ([$requiredFirstInvalid, $requiredLastInvalid] as $input) {
763-
$input->getValidatorChain()->attach($alwaysInvalid);
764-
}
765-
766648
return [
767649
'required-first-null-valid' => [$requiredFirstValid, null, 'assertTrue'],
768650
'required-first-null-invalid' => [$requiredFirstInvalid, null, 'assertFalse'],
769-
'required-last-null-valid' => [$requiredLastValid, null, 'assertTrue'],
770-
'required-last-null-invalid' => [$requiredLastInvalid, null, 'assertFalse'],
771651
'required-first-empty-valid' => [$requiredFirstValid, '', 'assertTrue'],
772652
'required-first-empty-invalid' => [$requiredFirstInvalid, '', 'assertFalse'],
773-
'required-last-empty-valid' => [$requiredLastValid, '', 'assertTrue'],
774-
'required-last-empty-invalid' => [$requiredLastInvalid, '', 'assertFalse'],
775653
'required-first-array-valid' => [$requiredFirstValid, [], 'assertTrue'],
776654
'required-first-array-invalid' => [$requiredFirstInvalid, [], 'assertFalse'],
777-
'required-last-array-valid' => [$requiredLastValid, [], 'assertTrue'],
778-
'required-last-array-invalid' => [$requiredLastInvalid, [], 'assertFalse'],
779655
];
780656
}
781657

@@ -806,42 +682,22 @@ public function whenNotRequiredAndNotAllowEmptyAndContinueIfEmptyValidatorsAreRu
806682
});
807683

808684
$requiredFirstInvalid = new Input('foo');
685+
$requiredFirstInvalid->getValidatorChain()->attach($alwaysInvalid);
809686
$requiredFirstValid = new Input('foo');
687+
$requiredFirstValid->getValidatorChain()->attach($emptyIsValid);
810688
foreach ([$requiredFirstValid, $requiredFirstInvalid] as $input) {
811689
$input->setRequired(false)
812690
->setAllowEmpty(false)
813691
->setContinueIfEmpty(true);
814692
}
815693

816-
$requiredLastInvalid = new Input('foo');
817-
$requiredLastValid = new Input('foo');
818-
foreach ([$requiredLastValid, $requiredLastInvalid] as $input) {
819-
$input->setAllowEmpty(false)
820-
->setContinueIfEmpty(true)
821-
->setRequired(false);
822-
}
823-
824-
foreach ([$requiredFirstValid, $requiredLastValid] as $input) {
825-
$input->getValidatorChain()->attach($emptyIsValid);
826-
}
827-
828-
foreach ([$requiredFirstInvalid, $requiredLastInvalid] as $input) {
829-
$input->getValidatorChain()->attach($alwaysInvalid);
830-
}
831-
832694
return [
833695
'required-first-null-valid' => [$requiredFirstValid, null, 'assertTrue'],
834696
'required-first-null-invalid' => [$requiredFirstInvalid, null, 'assertFalse'],
835-
'required-last-null-valid' => [$requiredLastValid, null, 'assertTrue'],
836-
'required-last-null-invalid' => [$requiredLastInvalid, null, 'assertFalse'],
837697
'required-first-empty-valid' => [$requiredFirstValid, '', 'assertTrue'],
838698
'required-first-empty-invalid' => [$requiredFirstInvalid, '', 'assertFalse'],
839-
'required-last-empty-valid' => [$requiredLastValid, '', 'assertTrue'],
840-
'required-last-empty-invalid' => [$requiredLastInvalid, '', 'assertFalse'],
841699
'required-first-array-valid' => [$requiredFirstValid, [], 'assertTrue'],
842700
'required-first-array-invalid' => [$requiredFirstInvalid, [], 'assertFalse'],
843-
'required-last-array-valid' => [$requiredLastValid, [], 'assertTrue'],
844-
'required-last-array-invalid' => [$requiredLastInvalid, [], 'assertFalse'],
845701
];
846702
}
847703

0 commit comments

Comments
 (0)