From 2368d229022853e32faea80482b087fd89e122f6 Mon Sep 17 00:00:00 2001 From: Igor AC Date: Sat, 29 May 2021 22:31:19 -0300 Subject: [PATCH] add tests to equalTo with more than one condition and with the same key --- tests/Parse/ParseQueryTest.php | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/Parse/ParseQueryTest.php b/tests/Parse/ParseQueryTest.php index cbac05d5..b62db19a 100644 --- a/tests/Parse/ParseQueryTest.php +++ b/tests/Parse/ParseQueryTest.php @@ -2720,4 +2720,56 @@ public function testUnknownCondition() 'unrecognized' => 1 ]); } + + public function testEqualToWithSameKeyAndWithOthersConditionsReturnWrongResult() + { + $baz = new ParseObject('TestObject'); + $baz->setArray('fooStack', [ + [ + 'status' => 'baz' + ], + [ + 'status' => 'bar' + ] + ]); + $baz->save(); + + $bar = new ParseObject('TestObject'); + $bar->setArray('fooStack', [ + [ + 'status' => 'bar' + ] + ]); + $bar->save(); + + $qux = new ParseObject('TestObject'); + $qux->setArray('fooStack', [ + [ + 'status' => 'bar', + ], + [ + 'status' => 'qux' + ] + ]); + $qux->save(); + + $query = new ParseQuery('TestObject'); + $query->notEqualTo('fooStack.status', 'baz'); + $query->equalTo('fooStack.status', 'bar'); + + $this->assertEquals(3, $query->count(true)); + } + + public function testEqualToWithSameKeyAndOthersConditionsReturnStructQueryWrong() + { + $query = new ParseQuery('TestObject'); + $query->notEqualTo('key', 'value3'); + $query->equalTo('key', 'value'); + + $this->assertSame([ + 'where' => [ + 'key' => 'value' + ] + ], $query->_getOptions()); + } }