Skip to content

Commit ff6c596

Browse files
committed
Test that OR queries use the correct parentheses
1 parent fe5c891 commit ff6c596

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

tests/Database/Base.php

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -915,17 +915,6 @@ public function testFind(Document $document)
915915
$documents = static::getDatabase()->find('movies', [], 2, 0, ['price', 'year'], [Database::ORDER_DESC, Database::ORDER_ASC], $movies[0], Database::CURSOR_BEFORE);
916916
$this->assertEmpty(count($documents));
917917

918-
/**
919-
* ORDER BY - After Exception
920-
*/
921-
922-
$document = new Document([
923-
'$collection' => 'other collection'
924-
]);
925-
926-
$this->expectException(Exception::class);
927-
static::getDatabase()->find('movies', [], 2, 0, [], [], $document);
928-
929918
/**
930919
* Limit
931920
*/
@@ -947,6 +936,26 @@ public function testFind(Document $document)
947936
$this->assertEquals('Frozen II', $documents[1]['name']);
948937
$this->assertEquals('Work in Progress', $documents[2]['name']);
949938
$this->assertEquals('Work in Progress 2', $documents[3]['name']);
939+
940+
/**
941+
* Test that OR queries are handled correctly
942+
*/
943+
$documents = static::getDatabase()->find('movies', [
944+
new Query('director', Query::TYPE_EQUAL, ['TBD', 'Joe Johnston']),
945+
new Query('year', Query::TYPE_EQUAL, [2025]),
946+
]);
947+
$this->assertEquals(1, count($documents));
948+
949+
/**
950+
* ORDER BY - After Exception
951+
* Must be last assertion in test
952+
*/
953+
$document = new Document([
954+
'$collection' => 'other collection'
955+
]);
956+
957+
$this->expectException(Exception::class);
958+
static::getDatabase()->find('movies', [], 2, 0, [], [], $document);
950959
}
951960

952961
/**
@@ -985,6 +994,17 @@ public function testCount()
985994
$count = static::getDatabase()->count('movies', [], 3);
986995
$this->assertEquals(3, $count);
987996
Authorization::reset();
997+
998+
/**
999+
* Test that OR queries are handled correctly
1000+
*/
1001+
Authorization::disable();
1002+
$count = static::getDatabase()->count('movies', [
1003+
new Query('director', Query::TYPE_EQUAL, ['TBD', 'Joe Johnston']),
1004+
new Query('year', Query::TYPE_EQUAL, [2025]),
1005+
]);
1006+
$this->assertEquals(1, $count);
1007+
Authorization::reset();
9881008
}
9891009

9901010
/**

0 commit comments

Comments
 (0)