@@ -1645,6 +1645,7 @@ public function testCreateDocument(array $data): array
1645
1645
$ this ->assertEquals ($ document1 ['body ' ]['actors ' ][0 ], 'Chris Evans ' );
1646
1646
$ this ->assertEquals ($ document1 ['body ' ]['actors ' ][1 ], 'Samuel Jackson ' );
1647
1647
$ this ->assertEquals ($ document1 ['body ' ]['birthDay ' ], '1975-06-12T12:12:55.000+00:00 ' );
1648
+ $ this ->assertTrue (array_key_exists ('$internalId ' , $ document1 ['body ' ]));
1648
1649
1649
1650
$ this ->assertEquals (201 , $ document2 ['headers ' ]['status-code ' ]);
1650
1651
$ this ->assertEquals ($ data ['moviesId ' ], $ document2 ['body ' ]['$collectionId ' ]);
@@ -1662,6 +1663,7 @@ public function testCreateDocument(array $data): array
1662
1663
$ this ->assertEquals ($ document2 ['body ' ]['birthDay ' ], null );
1663
1664
$ this ->assertEquals ($ document2 ['body ' ]['integers ' ][0 ], 50 );
1664
1665
$ this ->assertEquals ($ document2 ['body ' ]['integers ' ][1 ], 60 );
1666
+ $ this ->assertTrue (array_key_exists ('$internalId ' , $ document2 ['body ' ]));
1665
1667
1666
1668
$ this ->assertEquals (201 , $ document3 ['headers ' ]['status-code ' ]);
1667
1669
$ this ->assertEquals ($ data ['moviesId ' ], $ document3 ['body ' ]['$collectionId ' ]);
@@ -1676,6 +1678,7 @@ public function testCreateDocument(array $data): array
1676
1678
$ this ->assertEquals ($ document3 ['body ' ]['actors ' ][0 ], 'Tom Holland ' );
1677
1679
$ this ->assertEquals ($ document3 ['body ' ]['actors ' ][1 ], 'Zendaya Maree Stoermer ' );
1678
1680
$ this ->assertEquals ($ document3 ['body ' ]['birthDay ' ], '1975-06-12T18:12:55.000+00:00 ' ); // UTC for NY
1681
+ $ this ->assertTrue (array_key_exists ('$internalId ' , $ document3 ['body ' ]));
1679
1682
1680
1683
$ this ->assertEquals (400 , $ document4 ['headers ' ]['status-code ' ]);
1681
1684
@@ -2003,9 +2006,9 @@ public function testListDocuments(array $data): array
2003
2006
$ this ->assertEquals (1944 , $ documents ['body ' ]['documents ' ][0 ]['releaseYear ' ]);
2004
2007
$ this ->assertEquals (2017 , $ documents ['body ' ]['documents ' ][1 ]['releaseYear ' ]);
2005
2008
$ this ->assertEquals (2019 , $ documents ['body ' ]['documents ' ][2 ]['releaseYear ' ]);
2006
- $ this ->assertFalse (array_key_exists ('$sequence ' , $ documents ['body ' ]['documents ' ][0 ]));
2007
- $ this ->assertFalse (array_key_exists ('$sequence ' , $ documents ['body ' ]['documents ' ][1 ]));
2008
- $ this ->assertFalse (array_key_exists ('$sequence ' , $ documents ['body ' ]['documents ' ][2 ]));
2009
+ $ this ->assertTrue (array_key_exists ('$sequence ' , $ documents ['body ' ]['documents ' ][0 ]));
2010
+ $ this ->assertTrue (array_key_exists ('$sequence ' , $ documents ['body ' ]['documents ' ][1 ]));
2011
+ $ this ->assertTrue (array_key_exists ('$sequence ' , $ documents ['body ' ]['documents ' ][2 ]));
2009
2012
$ this ->assertCount (3 , $ documents ['body ' ]['documents ' ]);
2010
2013
2011
2014
foreach ($ documents ['body ' ]['documents ' ] as $ document ) {
@@ -2098,7 +2101,7 @@ public function testGetDocument(array $data): void
2098
2101
$ this ->assertEquals ($ response ['body ' ]['releaseYear ' ], $ document ['releaseYear ' ]);
2099
2102
$ this ->assertEquals ($ response ['body ' ]['$permissions ' ], $ document ['$permissions ' ]);
2100
2103
$ this ->assertEquals ($ response ['body ' ]['birthDay ' ], $ document ['birthDay ' ]);
2101
- $ this ->assertFalse (array_key_exists ('$sequence ' , $ response ['body ' ]));
2104
+ $ this ->assertTrue (array_key_exists ('$sequence ' , $ response ['body ' ]));
2102
2105
$ this ->assertFalse (array_key_exists ('$tenant ' , $ response ['body ' ]));
2103
2106
}
2104
2107
}
@@ -2111,6 +2114,7 @@ public function testGetDocumentWithQueries(array $data): void
2111
2114
$ databaseId = $ data ['databaseId ' ];
2112
2115
$ document = $ data ['documents ' ][0 ];
2113
2116
2117
+ // not selecting internal id
2114
2118
$ response = $ this ->client ->call (Client::METHOD_GET , '/databases/ ' . $ databaseId . '/collections/ ' . $ document ['$collectionId ' ] . '/documents/ ' . $ document ['$id ' ], array_merge ([
2115
2119
'content-type ' => 'application/json ' ,
2116
2120
'x-appwrite-project ' => $ this ->getProject ()['$id ' ],
@@ -2124,6 +2128,39 @@ public function testGetDocumentWithQueries(array $data): void
2124
2128
$ this ->assertEquals ($ document ['title ' ], $ response ['body ' ]['title ' ]);
2125
2129
$ this ->assertEquals ($ document ['releaseYear ' ], $ response ['body ' ]['releaseYear ' ]);
2126
2130
$ this ->assertArrayNotHasKey ('birthDay ' , $ response ['body ' ]);
2131
+ $ this ->assertFalse (array_key_exists ('$internalId ' , $ response ['body ' ]));
2132
+
2133
+ // selecting internal id as well
2134
+ $ response = $ this ->client ->call (Client::METHOD_GET , '/databases/ ' . $ databaseId . '/collections/ ' . $ document ['$collectionId ' ] . '/documents/ ' . $ document ['$id ' ], array_merge ([
2135
+ 'content-type ' => 'application/json ' ,
2136
+ 'x-appwrite-project ' => $ this ->getProject ()['$id ' ],
2137
+ ], $ this ->getHeaders ()), [
2138
+ 'queries ' => [
2139
+ Query::select (['title ' , 'releaseYear ' , '$id ' ,'$internalId ' ])->toString (),
2140
+ ],
2141
+ ]);
2142
+
2143
+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
2144
+ $ this ->assertEquals ($ document ['title ' ], $ response ['body ' ]['title ' ]);
2145
+ $ this ->assertEquals ($ document ['releaseYear ' ], $ response ['body ' ]['releaseYear ' ]);
2146
+ $ this ->assertArrayNotHasKey ('birthDay ' , $ response ['body ' ]);
2147
+ $ this ->assertTrue (array_key_exists ('$internalId ' , $ response ['body ' ]));
2148
+ $ internalId = $ response ['body ' ]['$internalId ' ];
2149
+
2150
+ // Query by internalId
2151
+ $ response = $ this ->client ->call (Client::METHOD_GET , '/databases/ ' . $ databaseId . '/collections/ ' . $ document ['$collectionId ' ] . '/documents/ ' . $ document ['$id ' ], array_merge ([
2152
+ 'content-type ' => 'application/json ' ,
2153
+ 'x-appwrite-project ' => $ this ->getProject ()['$id ' ],
2154
+ ], $ this ->getHeaders ()), [
2155
+ 'queries ' => [
2156
+ Query::equal ('$internalId ' , [$ internalId ])
2157
+ ],
2158
+ ]);
2159
+
2160
+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
2161
+ $ this ->assertEquals ($ document ['title ' ], $ response ['body ' ]['title ' ]);
2162
+ $ this ->assertEquals ($ document ['releaseYear ' ], $ response ['body ' ]['releaseYear ' ]);
2163
+ $ this ->assertTrue (array_key_exists ('$internalId ' , $ response ['body ' ]));
2127
2164
}
2128
2165
2129
2166
/**
@@ -4361,8 +4398,8 @@ public function testOneToOneRelationship(array $data): array
4361
4398
4362
4399
$ this ->assertArrayNotHasKey ('$collection ' , $ person1 ['body ' ]);
4363
4400
$ this ->assertArrayNotHasKey ('$collection ' , $ person1 ['body ' ]['library ' ]);
4364
- $ this ->assertArrayNotHasKey ('$sequence ' , $ person1 ['body ' ]);
4365
- $ this ->assertArrayNotHasKey ('$sequence ' , $ person1 ['body ' ]['library ' ]);
4401
+ $ this ->assertArrayHasKey ('$sequence ' , $ person1 ['body ' ]);
4402
+ $ this ->assertArrayHasKey ('$sequence ' , $ person1 ['body ' ]['library ' ]);
4366
4403
4367
4404
$ documents = $ this ->client ->call (Client::METHOD_GET , '/databases/ ' . $ databaseId . '/collections/ ' . $ person ['body ' ]['$id ' ] . '/documents ' , array_merge ([
4368
4405
'content-type ' => 'application/json ' ,
0 commit comments