@@ -956,7 +956,32 @@ public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleIdentifie
956956 $ this ->assertNull ($ field ->getData ());
957957 }
958958
959- public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleIdentifierWithLimit ()
959+ public function testSingleIdentifierWithLimit ()
960+ {
961+ $ entity1 = new SingleIntIdEntity (1 , 'Foo ' );
962+ $ entity2 = new SingleIntIdEntity (2 , 'Bar ' );
963+ $ entity3 = new SingleIntIdEntity (3 , 'Baz ' );
964+
965+ $ this ->persist ([$ entity1 , $ entity2 , $ entity3 ]);
966+
967+ $ repository = $ this ->em ->getRepository (self ::SINGLE_IDENT_CLASS );
968+
969+ $ field = $ this ->factory ->createNamed ('name ' , static ::TESTED_TYPE , null , [
970+ 'em ' => 'default ' ,
971+ 'class ' => self ::SINGLE_IDENT_CLASS ,
972+ 'query_builder ' => $ repository ->createQueryBuilder ('e ' )
973+ ->where ('e.id IN (1, 2, 3) ' )
974+ ->setMaxResults (1 ),
975+ 'choice_label ' => 'name ' ,
976+ ]);
977+
978+ $ field ->submit ('1 ' );
979+
980+ $ this ->assertTrue ($ field ->isSynchronized ());
981+ $ this ->assertSame ($ entity1 , $ field ->getData ());
982+ }
983+
984+ public function testDisallowChoicesThatAreNotIncludedByQueryBuilderSingleIdentifierWithLimit ()
960985 {
961986 $ entity1 = new SingleIntIdEntity (1 , 'Foo ' );
962987 $ entity2 = new SingleIntIdEntity (2 , 'Bar ' );
0 commit comments