@@ -35,8 +35,6 @@ abstract class Base extends TestCase
3535 */
3636 abstract protected static function getDatabase (): Database ;
3737
38- abstract protected static function killDatabase (): void ;
39-
4038 /**
4139 * @return string
4240 */
@@ -1056,7 +1054,8 @@ public function testGetDocumentSelect(Document $document): Document
10561054 Query::select (['string ' , 'integer ' ]),
10571055 ]);
10581056
1059- $ this ->assertNotEmpty (true , $ document ->getId ());
1057+ $ this ->assertEmpty ($ document ->getId ());
1058+ $ this ->assertFalse ($ document ->isEmpty ());
10601059 $ this ->assertIsString ($ document ->getAttribute ('string ' ));
10611060 $ this ->assertEquals ('text📝 ' , $ document ->getAttribute ('string ' ));
10621061 $ this ->assertIsInt ($ document ->getAttribute ('integer ' ));
@@ -11691,6 +11690,89 @@ public function testLabels(): void
1169111690 $ this ->assertCount (1 , $ documents );
1169211691 }
1169311692
11693+ public function testEmptyOperatorValues (): void
11694+ {
11695+ try {
11696+ static ::getDatabase ()->findOne ('documents ' , [
11697+ Query::equal ('string ' , []),
11698+ ]);
11699+ $ this ->fail ('Failed to throw exception ' );
11700+ } catch (Exception $ e ) {
11701+ $ this ->assertInstanceOf (Exception::class, $ e );
11702+ $ this ->assertEquals ('Invalid query: Equal queries require at least one value. ' , $ e ->getMessage ());
11703+ }
11704+
11705+ try {
11706+ static ::getDatabase ()->findOne ('documents ' , [
11707+ Query::search ('string ' , null ),
11708+ ]);
11709+ $ this ->fail ('Failed to throw exception ' );
11710+ } catch (Exception $ e ) {
11711+ $ this ->assertInstanceOf (Exception::class, $ e );
11712+ $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11713+ }
11714+
11715+ try {
11716+ static ::getDatabase ()->findOne ('documents ' , [
11717+ Query::notEqual ('string ' , []),
11718+ ]);
11719+ $ this ->fail ('Failed to throw exception ' );
11720+ } catch (Exception $ e ) {
11721+ $ this ->assertInstanceOf (Exception::class, $ e );
11722+ $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11723+ }
11724+
11725+ try {
11726+ static ::getDatabase ()->findOne ('documents ' , [
11727+ Query::lessThan ('string ' , []),
11728+ ]);
11729+ $ this ->fail ('Failed to throw exception ' );
11730+ } catch (Exception $ e ) {
11731+ $ this ->assertInstanceOf (Exception::class, $ e );
11732+ $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11733+ }
11734+
11735+ try {
11736+ static ::getDatabase ()->findOne ('documents ' , [
11737+ Query::lessThanEqual ('string ' , []),
11738+ ]);
11739+ $ this ->fail ('Failed to throw exception ' );
11740+ } catch (Exception $ e ) {
11741+ $ this ->assertInstanceOf (Exception::class, $ e );
11742+ $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11743+ }
11744+
11745+ try {
11746+ static ::getDatabase ()->findOne ('documents ' , [
11747+ Query::greaterThan ('string ' , []),
11748+ ]);
11749+ $ this ->fail ('Failed to throw exception ' );
11750+ } catch (Exception $ e ) {
11751+ $ this ->assertInstanceOf (Exception::class, $ e );
11752+ $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11753+ }
11754+
11755+ try {
11756+ static ::getDatabase ()->findOne ('documents ' , [
11757+ Query::greaterThanEqual ('string ' , []),
11758+ ]);
11759+ $ this ->fail ('Failed to throw exception ' );
11760+ } catch (Exception $ e ) {
11761+ $ this ->assertInstanceOf (Exception::class, $ e );
11762+ $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11763+ }
11764+
11765+ try {
11766+ static ::getDatabase ()->findOne ('documents ' , [
11767+ Query::contains ('string ' , []),
11768+ ]);
11769+ $ this ->fail ('Failed to throw exception ' );
11770+ } catch (Exception $ e ) {
11771+ $ this ->assertInstanceOf (Exception::class, $ e );
11772+ $ this ->assertEquals ('Invalid query: Contains queries require at least one value. ' , $ e ->getMessage ());
11773+ }
11774+ }
11775+
1169411776 public function testEvents (): void
1169511777 {
1169611778 Authorization::skip (function () {
@@ -11782,93 +11864,4 @@ public function testEvents(): void
1178211864 $ database ->delete ('hellodb ' );
1178311865 });
1178411866 }
11785-
11786- public function testEmptyOperatorValues (): void
11787- {
11788- try {
11789- static ::getDatabase ()->findOne ('documents ' , [
11790- Query::equal ('string ' , []),
11791- ]);
11792- $ this ->fail ('Failed to throw exception ' );
11793- } catch (Exception $ e ) {
11794- $ this ->assertInstanceOf (Exception::class, $ e );
11795- $ this ->assertEquals ('Invalid query: Equal queries require at least one value. ' , $ e ->getMessage ());
11796- }
11797-
11798- try {
11799- static ::getDatabase ()->findOne ('documents ' , [
11800- Query::search ('string ' , null ),
11801- ]);
11802- $ this ->fail ('Failed to throw exception ' );
11803- } catch (Exception $ e ) {
11804- $ this ->assertInstanceOf (Exception::class, $ e );
11805- $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11806- }
11807-
11808- try {
11809- static ::getDatabase ()->findOne ('documents ' , [
11810- Query::notEqual ('string ' , []),
11811- ]);
11812- $ this ->fail ('Failed to throw exception ' );
11813- } catch (Exception $ e ) {
11814- $ this ->assertInstanceOf (Exception::class, $ e );
11815- $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11816- }
11817-
11818- try {
11819- static ::getDatabase ()->findOne ('documents ' , [
11820- Query::lessThan ('string ' , []),
11821- ]);
11822- $ this ->fail ('Failed to throw exception ' );
11823- } catch (Exception $ e ) {
11824- $ this ->assertInstanceOf (Exception::class, $ e );
11825- $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11826- }
11827-
11828- try {
11829- static ::getDatabase ()->findOne ('documents ' , [
11830- Query::lessThanEqual ('string ' , []),
11831- ]);
11832- $ this ->fail ('Failed to throw exception ' );
11833- } catch (Exception $ e ) {
11834- $ this ->assertInstanceOf (Exception::class, $ e );
11835- $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11836- }
11837-
11838- try {
11839- static ::getDatabase ()->findOne ('documents ' , [
11840- Query::greaterThan ('string ' , []),
11841- ]);
11842- $ this ->fail ('Failed to throw exception ' );
11843- } catch (Exception $ e ) {
11844- $ this ->assertInstanceOf (Exception::class, $ e );
11845- $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11846- }
11847-
11848- try {
11849- static ::getDatabase ()->findOne ('documents ' , [
11850- Query::greaterThanEqual ('string ' , []),
11851- ]);
11852- $ this ->fail ('Failed to throw exception ' );
11853- } catch (Exception $ e ) {
11854- $ this ->assertInstanceOf (Exception::class, $ e );
11855- $ this ->assertEquals ('Invalid query: Query type does not match expected: string ' , $ e ->getMessage ());
11856- }
11857-
11858- try {
11859- static ::getDatabase ()->findOne ('documents ' , [
11860- Query::contains ('string ' , []),
11861- ]);
11862- $ this ->fail ('Failed to throw exception ' );
11863- } catch (Exception $ e ) {
11864- $ this ->assertInstanceOf (Exception::class, $ e );
11865- $ this ->assertEquals ('Invalid query: Contains queries require at least one value. ' , $ e ->getMessage ());
11866- }
11867- }
11868-
11869- public function testLast (): void
11870- {
11871- $ this ->expectNotToPerformAssertions ();
11872- static ::killDatabase ();
11873- }
1187411867}
0 commit comments