@@ -44,7 +44,7 @@ final class FiltererTest extends TestCase
4444 . "</books> \n"
4545 );
4646
47- public function setUp ()
47+ public function setUp (): void
4848 {
4949 Filterer::setFilterAliases (Filterer::DEFAULT_FILTER_ALIASES );
5050 }
@@ -690,35 +690,35 @@ public function setBadFilterAliases()
690690 * @test
691691 * @covers ::filter
692692 * @covers ::execute
693- * @expectedException Exception
694- * @expectedExceptionMessage Function 'boo' for field 'foo' is not callable
695693 */
696694 public function notCallable ()
697695 {
696+ $ this ->expectException (Exception::class);
697+ $ this ->expectExceptionMessage ("Function 'boo' for field 'foo' is not callable " );
698698 Filterer::filter (['foo ' => [['boo ' ]]], ['foo ' => 0 ]);
699699 }
700700
701701 /**
702702 * @test
703703 * @covers ::filter
704704 * @covers ::execute
705- * @expectedException InvalidArgumentException
706- * @expectedExceptionMessage 'allowUnknowns' option was not a bool
707705 */
708706 public function allowUnknownsNotBool ()
709707 {
708+ $ this ->expectException (InvalidArgumentException::class);
709+ $ this ->expectExceptionMessage ("'allowUnknowns' option was not a bool " );
710710 Filterer::filter ([], [], ['allowUnknowns ' => 1 ]);
711711 }
712712
713713 /**
714714 * @test
715715 * @covers ::filter
716716 * @covers ::execute
717- * @expectedException InvalidArgumentException
718- * @expectedExceptionMessage 'defaultRequired' option was not a bool
719717 */
720718 public function defaultRequiredNotBool ()
721719 {
720+ $ this ->expectException (InvalidArgumentException::class);
721+ $ this ->expectExceptionMessage ("'defaultRequired' option was not a bool " );
722722 Filterer::filter ([], [], ['defaultRequired ' => 1 ]);
723723 }
724724
@@ -739,69 +739,69 @@ public function filterThrowsExceptionOnInvalidResponseType()
739739 * @test
740740 * @covers ::filter
741741 * @covers ::execute
742- * @expectedException InvalidArgumentException
743- * @expectedExceptionMessage filters for field 'boo' was not a array
744742 */
745743 public function filtersNotArrayInLeftOverSpec ()
746744 {
745+ $ this ->expectException (InvalidArgumentException::class);
746+ $ this ->expectExceptionMessage ("filters for field 'boo' was not a array " );
747747 Filterer::filter (['boo ' => 1 ], []);
748748 }
749749
750750 /**
751751 * @test
752752 * @covers ::filter
753753 * @covers ::execute
754- * @expectedException InvalidArgumentException
755- * @expectedExceptionMessage filters for field 'boo' was not a array
756754 */
757755 public function filtersNotArrayWithInput ()
758756 {
757+ $ this ->expectException (InvalidArgumentException::class);
758+ $ this ->expectExceptionMessage ("filters for field 'boo' was not a array " );
759759 Filterer::filter (['boo ' => 1 ], ['boo ' => 'notUnderTest ' ]);
760760 }
761761
762762 /**
763763 * @test
764764 * @covers ::filter
765765 * @covers ::execute
766- * @expectedException InvalidArgumentException
767- * @expectedExceptionMessage filter for field 'boo' was not a array
768766 */
769767 public function filterNotArray ()
770768 {
769+ $ this ->expectException (InvalidArgumentException::class);
770+ $ this ->expectExceptionMessage ("filter for field 'boo' was not a array " );
771771 Filterer::filter (['boo ' => [1 ]], ['boo ' => 'notUnderTest ' ]);
772772 }
773773
774774 /**
775775 * @test
776776 * @covers ::filter
777777 * @covers ::execute
778- * @expectedException InvalidArgumentException
779- * @expectedExceptionMessage 'required' for field 'boo' was not a bool
780778 */
781779 public function requiredNotBool ()
782780 {
781+ $ this ->expectException (InvalidArgumentException::class);
782+ $ this ->expectExceptionMessage ("'required' for field 'boo' was not a bool " );
783783 Filterer::filter (['boo ' => ['required ' => 1 ]], []);
784784 }
785785
786786 /**
787787 * @test
788788 * @covers ::registerAlias
789- * @expectedException InvalidArgumentException
790- * @expectedExceptionMessage $alias was not a string or int
791789 */
792790 public function registerAliasAliasNotString ()
793791 {
792+ $ this ->expectException (InvalidArgumentException::class);
793+ $ this ->expectExceptionMessage ('$alias was not a string or int ' );
794794 Filterer::registerAlias (true , 'strtolower ' );
795795 }
796796
797797 /**
798798 * @test
799799 * @covers ::registerAlias
800- * @expectedException Exception
801- * @expectedExceptionMessage Alias 'upper' exists
802800 */
803801 public function registerExistingAliasOverwriteFalse ()
804802 {
803+ $ this ->expectException (Exception::class);
804+ $ this ->expectExceptionMessage ("Alias 'upper' exists " );
805805 Filterer::setFilterAliases ([]);
806806 Filterer::registerAlias ('upper ' , 'strtoupper ' );
807807 Filterer::registerAlias ('upper ' , 'strtoupper ' , false );
@@ -834,13 +834,13 @@ public static function passingFilter($value)
834834 * @test
835835 * @covers ::filter
836836 * @covers ::execute
837- * @expectedException InvalidArgumentException
838- * @expectedExceptionMessage error for field 'fieldOne' was not a non-empty string
839837 *
840838 * @return void
841839 */
842840 public function filterWithNonStringError ()
843841 {
842+ $ this ->expectException (InvalidArgumentException::class);
843+ $ this ->expectExceptionMessage ("error for field 'fieldOne' was not a non-empty string " );
844844 Filterer::filter (
845845 ['fieldOne ' => [['strtoupper ' ], 'error ' => new stdClass ()]],
846846 ['fieldOne ' => 'valueOne ' ]
@@ -853,13 +853,13 @@ public function filterWithNonStringError()
853853 * @test
854854 * @covers ::filter
855855 * @covers ::execute
856- * @expectedException InvalidArgumentException
857- * @expectedExceptionMessage error for field 'fieldOne' was not a non-empty string
858856 *
859857 * @return void
860858 */
861859 public function filterWithEmptyStringError ()
862860 {
861+ $ this ->expectException (InvalidArgumentException::class);
862+ $ this ->expectExceptionMessage ("error for field 'fieldOne' was not a non-empty string " );
863863 Filterer::filter (
864864 ['fieldOne ' => [['strtoupper ' ], 'error ' => "\n \t" ]],
865865 ['fieldOne ' => 'valueOne ' ]
@@ -907,9 +907,9 @@ public function ofScalarsFail()
907907Field '1' with value 'array (
908908)' failed filtering, message 'Value 'array (
909909)' is not a string'
910- Field '2' with value 'stdClass::__set_state( array(
911- )) ' failed filtering, message 'Value 'stdClass::__set_state( array(
912- )) ' is not a string'
910+ Field '2' with value '(object) array(
911+ )' failed filtering, message 'Value '(object) array(
912+ )' is not a string'
913913TXT ;
914914 $ this ->assertSame ($ expected , $ e ->getMessage ());
915915 }
@@ -965,9 +965,9 @@ public function ofArraysFail()
965965 $ this ->fail ();
966966 } catch (FilterException $ e ) {
967967 $ expected = <<<TXT
968- Field 'key' with value 'stdClass::__set_state( array(
969- )) ' failed filtering, message 'Value 'stdClass::__set_state( array(
970- )) ' is not a string'
968+ Field 'key' with value '(object) array(
969+ )' failed filtering, message 'Value '(object) array(
970+ )' is not a string'
971971Field 'key' with value 'array (
972972)' failed filtering, message 'Value 'array (
973973)' is not a string'
0 commit comments