Skip to content

add tests to equalTo with more than one condition and with the same key #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/Parse/ParseQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2719,4 +2719,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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the expected results? Should these test fail instead of passing?

Copy link
Author

@igor-mobapps igor-mobapps Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, they must fail.

Only tests have been done, once the fix cited in #476 is implemented, they should fail

}

public function testEqualToWithSameKeyAndOthersConditionsReturnStructQueryWrong()
{
$query = new ParseQuery('TestObject');
$query->notEqualTo('key', 'value3');
$query->equalTo('key', 'value');

$this->assertSame([
'where' => [
'key' => 'value'
]
], $query->_getOptions());
}
}