mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
(test): add e2e test for $sequence query type validation per adapter
This commit is contained in:
@@ -3518,6 +3518,62 @@ trait DatabasesBase
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
public function testQueryBySequenceType(): void
|
||||
{
|
||||
$data = $this->setupDocuments();
|
||||
$databaseId = $data['databaseId'];
|
||||
|
||||
$documents = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $data['moviesId']), array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::equal('$id', $data['documentIds'])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $documents['headers']['status-code']);
|
||||
$this->assertGreaterThan(0, count($documents['body'][$this->getRecordResource()]));
|
||||
|
||||
$sequence = $documents['body'][$this->getRecordResource()][0]['$sequence'];
|
||||
$this->assertIsString($sequence);
|
||||
|
||||
// Query with string $sequence value (supported by all adapters)
|
||||
$response = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $data['moviesId']), array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::equal('$sequence', [$sequence])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertCount(1, $response['body'][$this->getRecordResource()]);
|
||||
$this->assertIsString($response['body'][$this->getRecordResource()][0]['$sequence']);
|
||||
$this->assertSame($sequence, $response['body'][$this->getRecordResource()][0]['$sequence']);
|
||||
|
||||
// Query with int $sequence value (supported by SQL adapters, rejected by MongoDB)
|
||||
$intSequence = (int)$sequence;
|
||||
$response = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $data['moviesId']), array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::equal('$sequence', [$intSequence])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$adapter = getenv('_APP_DB_ADAPTER');
|
||||
if ($adapter === 'mongodb') {
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
} else {
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertCount(1, $response['body'][$this->getRecordResource()]);
|
||||
$this->assertIsString($response['body'][$this->getRecordResource()][0]['$sequence']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testListDocumentsAfterPagination(): void
|
||||
{
|
||||
$data = $this->setupDocuments();
|
||||
|
||||
Reference in New Issue
Block a user