@@ -605,6 +605,50 @@ public function testCreateDocument()
605605 $ this ->assertEquals ([], $ document ->getAttribute ('empty ' ));
606606 $ this ->assertEquals ('Works ' , $ document ->getAttribute ('with-dash ' ));
607607
608+ // Test create document with manual internal id
609+ $ manualIdDocument = static ::getDatabase ()->createDocument ('documents ' , new Document ([
610+ '$internalId ' => '56000 ' ,
611+ '$permissions ' => [
612+ Permission::read (Role::any ()),
613+ Permission::read (Role::user (ID ::custom ('1 ' ))),
614+ Permission::read (Role::user (ID ::custom ('2 ' ))),
615+ Permission::create (Role::any ()),
616+ Permission::create (Role::user (ID ::custom ('1x ' ))),
617+ Permission::create (Role::user (ID ::custom ('2x ' ))),
618+ Permission::update (Role::any ()),
619+ Permission::update (Role::user (ID ::custom ('1x ' ))),
620+ Permission::update (Role::user (ID ::custom ('2x ' ))),
621+ Permission::delete (Role::any ()),
622+ Permission::delete (Role::user (ID ::custom ('1x ' ))),
623+ Permission::delete (Role::user (ID ::custom ('2x ' ))),
624+ ],
625+ 'string ' => 'text📝 ' ,
626+ 'integer ' => 5 ,
627+ 'bigint ' => 8589934592 , // 2^33
628+ 'float ' => 5.55 ,
629+ 'boolean ' => true ,
630+ 'colors ' => ['pink ' , 'green ' , 'blue ' ],
631+ 'empty ' => [],
632+ 'with-dash ' => 'Works ' ,
633+ ]));
634+
635+ $ this ->assertEquals ('56000 ' , $ manualIdDocument ->getInternalId ());
636+ $ this ->assertNotEmpty (true , $ manualIdDocument ->getId ());
637+ $ this ->assertIsString ($ manualIdDocument ->getAttribute ('string ' ));
638+ $ this ->assertEquals ('text📝 ' , $ manualIdDocument ->getAttribute ('string ' )); // Also makes sure an emoji is working
639+ $ this ->assertIsInt ($ manualIdDocument ->getAttribute ('integer ' ));
640+ $ this ->assertEquals (5 , $ manualIdDocument ->getAttribute ('integer ' ));
641+ $ this ->assertIsInt ($ manualIdDocument ->getAttribute ('bigint ' ));
642+ $ this ->assertEquals (8589934592 , $ manualIdDocument ->getAttribute ('bigint ' ));
643+ $ this ->assertIsFloat ($ manualIdDocument ->getAttribute ('float ' ));
644+ $ this ->assertEquals (5.55 , $ manualIdDocument ->getAttribute ('float ' ));
645+ $ this ->assertIsBool ($ manualIdDocument ->getAttribute ('boolean ' ));
646+ $ this ->assertEquals (true , $ manualIdDocument ->getAttribute ('boolean ' ));
647+ $ this ->assertIsArray ($ manualIdDocument ->getAttribute ('colors ' ));
648+ $ this ->assertEquals (['pink ' , 'green ' , 'blue ' ], $ manualIdDocument ->getAttribute ('colors ' ));
649+ $ this ->assertEquals ([], $ manualIdDocument ->getAttribute ('empty ' ));
650+ $ this ->assertEquals ('Works ' , $ manualIdDocument ->getAttribute ('with-dash ' ));
651+
608652 return $ document ;
609653 }
610654
@@ -2636,6 +2680,7 @@ public function testExceptionDuplicate(Document $document)
26362680 public function testExceptionCaseInsensitiveDuplicate (Document $ document )
26372681 {
26382682 $ document ->setAttribute ('$id ' , 'caseSensitive ' );
2683+ $ document ->setAttribute ('$internalId ' , '200 ' );
26392684 static ::getDatabase ()->createDocument ($ document ->getCollection (), $ document );
26402685
26412686 $ document ->setAttribute ('$id ' , 'CaseSensitive ' );
0 commit comments