@@ -2654,8 +2654,8 @@ public function testGetAndSetConditions()
26542654 $ query ->select (['select1 ' ,'select2 ' ]);
26552655 $ query ->skip (24 );
26562656
2657- // sets count = 1 and limit = 0
2658- $ query ->count ();
2657+ // sets count = 1
2658+ $ query ->withCount ();
26592659 // reset limit up to 42
26602660 $ query ->limit (42 );
26612661
@@ -2695,6 +2695,45 @@ public function testGetAndSetConditions()
26952695 );
26962696 }
26972697
2698+ /**
2699+ * @group query-count-conditions
2700+ */
2701+ public function testCountDoesNotOverrideConditions ()
2702+ {
2703+ $ obj = new ParseObject ('TestObject ' );
2704+ $ obj ->set ('name ' , 'John ' );
2705+ $ obj ->set ('country ' , 'US ' );
2706+ $ obj ->save ();
2707+
2708+ $ obj = new ParseObject ('TestObject ' );
2709+ $ obj ->set ('name ' , 'Bob ' );
2710+ $ obj ->set ('country ' , 'US ' );
2711+ $ obj ->save ();
2712+
2713+ $ obj = new ParseObject ('TestObject ' );
2714+ $ obj ->set ('name ' , 'Mike ' );
2715+ $ obj ->set ('country ' , 'CA ' );
2716+ $ obj ->save ();
2717+
2718+ $ query = new ParseQuery ('TestObject ' );
2719+ $ query ->equalTo ('country ' , 'US ' );
2720+ $ query ->limit (1 );
2721+ $ count = $ query ->count ();
2722+ $ results = $ query ->find ();
2723+
2724+ $ this ->assertEquals (1 , count ($ results ));
2725+ $ this ->assertEquals (2 , $ count );
2726+
2727+ $ this ->assertSame ([
2728+ 'where ' => [
2729+ 'country ' => [
2730+ '$eq ' => 'US '
2731+ ]
2732+ ],
2733+ 'limit ' => 1 ,
2734+ ], $ query ->_getOptions ());
2735+ }
2736+
26982737 public function testNotArrayConditions ()
26992738 {
27002739 $ this ->expectException (
@@ -2770,8 +2809,6 @@ public function testEqualToWithSameKeyDoesNotOverrideOtherConditions()
27702809 '$eq ' => 'bar ' ,
27712810 ]
27722811 ],
2773- 'limit ' => 0 ,
2774- 'count ' => 1 ,
27752812 ], $ query ->_getOptions ());
27762813 }
27772814}
0 commit comments