@@ -734,7 +734,7 @@ public function testMatchingEmptyCriteria(): void
734734 $ this ->loadFixture ();
735735
736736 $ repository = $ this ->_em ->getRepository (CmsUser::class);
737- $ users = $ repository ->matching (new Criteria ( ));
737+ $ users = $ repository ->matching (Criteria:: create ( true ));
738738
739739 self ::assertCount (4 , $ users );
740740 }
@@ -745,7 +745,7 @@ public function testMatchingCriteriaEqComparison(): void
745745 $ this ->loadFixture ();
746746
747747 $ repository = $ this ->_em ->getRepository (CmsUser::class);
748- $ users = $ repository ->matching (new Criteria (
748+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
749749 Criteria::expr ()->eq ('username ' , 'beberlei ' )
750750 ));
751751
@@ -758,7 +758,7 @@ public function testMatchingCriteriaNeqComparison(): void
758758 $ this ->loadFixture ();
759759
760760 $ repository = $ this ->_em ->getRepository (CmsUser::class);
761- $ users = $ repository ->matching (new Criteria (
761+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
762762 Criteria::expr ()->neq ('username ' , 'beberlei ' )
763763 ));
764764
@@ -771,7 +771,7 @@ public function testMatchingCriteriaInComparison(): void
771771 $ this ->loadFixture ();
772772
773773 $ repository = $ this ->_em ->getRepository (CmsUser::class);
774- $ users = $ repository ->matching (new Criteria (
774+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
775775 Criteria::expr ()->in ('username ' , ['beberlei ' , 'gblanco ' ])
776776 ));
777777
@@ -784,7 +784,7 @@ public function testMatchingCriteriaNotInComparison(): void
784784 $ this ->loadFixture ();
785785
786786 $ repository = $ this ->_em ->getRepository (CmsUser::class);
787- $ users = $ repository ->matching (new Criteria (
787+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
788788 Criteria::expr ()->notIn ('username ' , ['beberlei ' , 'gblanco ' , 'asm89 ' ])
789789 ));
790790
@@ -797,7 +797,7 @@ public function testMatchingCriteriaLtComparison(): void
797797 $ firstUserId = $ this ->loadFixture ();
798798
799799 $ repository = $ this ->_em ->getRepository (CmsUser::class);
800- $ users = $ repository ->matching (new Criteria (
800+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
801801 Criteria::expr ()->lt ('id ' , $ firstUserId + 1 )
802802 ));
803803
@@ -810,7 +810,7 @@ public function testMatchingCriteriaLeComparison(): void
810810 $ firstUserId = $ this ->loadFixture ();
811811
812812 $ repository = $ this ->_em ->getRepository (CmsUser::class);
813- $ users = $ repository ->matching (new Criteria (
813+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
814814 Criteria::expr ()->lte ('id ' , $ firstUserId + 1 )
815815 ));
816816
@@ -823,7 +823,7 @@ public function testMatchingCriteriaGtComparison(): void
823823 $ firstUserId = $ this ->loadFixture ();
824824
825825 $ repository = $ this ->_em ->getRepository (CmsUser::class);
826- $ users = $ repository ->matching (new Criteria (
826+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
827827 Criteria::expr ()->gt ('id ' , $ firstUserId )
828828 ));
829829
@@ -836,7 +836,7 @@ public function testMatchingCriteriaGteComparison(): void
836836 $ firstUserId = $ this ->loadFixture ();
837837
838838 $ repository = $ this ->_em ->getRepository (CmsUser::class);
839- $ users = $ repository ->matching (new Criteria (
839+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (
840840 Criteria::expr ()->gte ('id ' , $ firstUserId )
841841 ));
842842
@@ -850,7 +850,7 @@ public function testMatchingCriteriaAssocationByObjectInMemory(): void
850850
851851 $ user = $ this ->_em ->find (CmsUser::class, $ userId );
852852
853- $ criteria = new Criteria (
853+ $ criteria = Criteria:: create ( true )-> where (
854854 Criteria::expr ()->eq ('user ' , $ user )
855855 );
856856
@@ -871,7 +871,7 @@ public function testMatchingCriteriaAssocationInWithArray(): void
871871
872872 $ user = $ this ->_em ->find (CmsUser::class, $ userId );
873873
874- $ criteria = new Criteria (
874+ $ criteria = Criteria:: create ( true )-> where (
875875 Criteria::expr ()->in ('user ' , [$ user ])
876876 );
877877
@@ -891,13 +891,13 @@ public function testMatchingCriteriaContainsComparison(): void
891891
892892 $ repository = $ this ->_em ->getRepository (CmsUser::class);
893893
894- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->contains ('name ' , 'Foobar ' )));
894+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (Criteria::expr ()->contains ('name ' , 'Foobar ' )));
895895 self ::assertCount (0 , $ users );
896896
897- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->contains ('name ' , 'Rom ' )));
897+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (Criteria::expr ()->contains ('name ' , 'Rom ' )));
898898 self ::assertCount (1 , $ users );
899899
900- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->contains ('status ' , 'dev ' )));
900+ $ users = $ repository ->matching (Criteria:: create ( true )-> where (Criteria::expr ()->contains ('status ' , 'dev ' )));
901901 self ::assertCount (2 , $ users );
902902 }
903903
@@ -907,13 +907,19 @@ public function testMatchingCriteriaStartsWithComparison(): void
907907
908908 $ repository = $ this ->_em ->getRepository (CmsUser::class);
909909
910- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->startsWith ('name ' , 'Foo ' )));
910+ $ users = $ repository ->matching (Criteria::create (true )->where (
911+ Criteria::expr ()->startsWith ('name ' , 'Foo ' )
912+ ));
911913 self ::assertCount (0 , $ users );
912914
913- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->startsWith ('name ' , 'R ' )));
915+ $ users = $ repository ->matching (Criteria::create (true )->where (
916+ Criteria::expr ()->startsWith ('name ' , 'R ' )
917+ ));
914918 self ::assertCount (1 , $ users );
915919
916- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->startsWith ('status ' , 'de ' )));
920+ $ users = $ repository ->matching (Criteria::create (true )->where (
921+ Criteria::expr ()->startsWith ('status ' , 'de ' )
922+ ));
917923 self ::assertCount (2 , $ users );
918924 }
919925
@@ -923,13 +929,19 @@ public function testMatchingCriteriaEndsWithComparison(): void
923929
924930 $ repository = $ this ->_em ->getRepository (CmsUser::class);
925931
926- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->endsWith ('name ' , 'foo ' )));
932+ $ users = $ repository ->matching (Criteria::create (true )->where (
933+ Criteria::expr ()->endsWith ('name ' , 'foo ' )
934+ ));
927935 self ::assertCount (0 , $ users );
928936
929- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->endsWith ('name ' , 'oman ' )));
937+ $ users = $ repository ->matching (Criteria::create (true )->where (
938+ Criteria::expr ()->endsWith ('name ' , 'oman ' )
939+ ));
930940 self ::assertCount (1 , $ users );
931941
932- $ users = $ repository ->matching (new Criteria (Criteria::expr ()->endsWith ('status ' , 'ev ' )));
942+ $ users = $ repository ->matching (Criteria::create (true )->where (
943+ Criteria::expr ()->endsWith ('status ' , 'ev ' )
944+ ));
933945 self ::assertCount (2 , $ users );
934946 }
935947
@@ -939,8 +951,8 @@ public function testMatchingCriteriaNullAssocComparison(): void
939951 $ fixtures = $ this ->loadFixtureUserEmail ();
940952 $ user = $ this ->_em ->find (CmsUser::class, $ fixtures [0 ]->id );
941953 $ repository = $ this ->_em ->getRepository (CmsUser::class);
942- $ criteriaIsNull = Criteria::create ()->where (Criteria::expr ()->isNull ('email ' ));
943- $ criteriaEqNull = Criteria::create ()->where (Criteria::expr ()->eq ('email ' , null ));
954+ $ criteriaIsNull = Criteria::create (true )->where (Criteria::expr ()->isNull ('email ' ));
955+ $ criteriaEqNull = Criteria::create (true )->where (Criteria::expr ()->eq ('email ' , null ));
944956
945957 $ user ->setEmail (null );
946958 $ this ->_em ->persist ($ user );
@@ -997,7 +1009,7 @@ public function testMatchingInjectionPrevented(): void
9971009 $ this ->expectExceptionMessage ('Unrecognized field: ' );
9981010
9991011 $ repository = $ this ->_em ->getRepository (CmsUser::class);
1000- $ result = $ repository ->matching (new Criteria (
1012+ $ result = $ repository ->matching (Criteria:: create ( true )-> where (
10011013 Criteria::expr ()->eq ('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1 ' , 'beberlei ' )
10021014 ));
10031015
0 commit comments