55use Utopia \Database \Database ;
66use Utopia \Database \DateTime ;
77use Utopia \Database \Document ;
8- use Utopia \Database \Exception as DatabaseException ;
8+ use Utopia \Database \Exception \ Operator as OperatorException ;
99use Utopia \Database \Exception \Structure as StructureException ;
1010use Utopia \Database \Exception \Type as TypeException ;
1111use Utopia \Database \Helpers \Permission ;
@@ -459,7 +459,7 @@ public function testOperatorErrorHandling(): void
459459 ]));
460460
461461 // Test increment on non-numeric field
462- $ this ->expectException (DatabaseException ::class);
462+ $ this ->expectException (StructureException ::class);
463463 $ this ->expectExceptionMessage ("Cannot apply increment operator to non-numeric field 'text_field' " );
464464
465465 $ database ->updateDocument ($ collectionId , 'error_test_doc ' , new Document ([
@@ -496,7 +496,7 @@ public function testOperatorArrayErrorHandling(): void
496496 ]));
497497
498498 // Test append on non-array field
499- $ this ->expectException (DatabaseException ::class);
499+ $ this ->expectException (StructureException ::class);
500500 $ this ->expectExceptionMessage ("Cannot apply arrayAppend operator to non-array field 'text_field' " );
501501
502502 $ database ->updateDocument ($ collectionId , 'array_error_test_doc ' , new Document ([
@@ -531,7 +531,7 @@ public function testOperatorInsertErrorHandling(): void
531531 ]));
532532
533533 // Test insert with negative index
534- $ this ->expectException (DatabaseException ::class);
534+ $ this ->expectException (StructureException ::class);
535535 $ this ->expectExceptionMessage ("Cannot apply arrayInsert operator: index must be a non-negative integer " );
536536
537537 $ database ->updateDocument ($ collectionId , 'insert_error_test_doc ' , new Document ([
@@ -585,7 +585,7 @@ public function testOperatorValidationEdgeCases(): void
585585 'string_field ' => Operator::increment (5 )
586586 ]));
587587 $ this ->fail ('Expected exception for increment on string field ' );
588- } catch (DatabaseException $ e ) {
588+ } catch (StructureException $ e ) {
589589 $ this ->assertStringContainsString ("Cannot apply increment operator to non-numeric field 'string_field' " , $ e ->getMessage ());
590590 }
591591
@@ -595,7 +595,7 @@ public function testOperatorValidationEdgeCases(): void
595595 'int_field ' => Operator::stringConcat (' suffix ' )
596596 ]));
597597 $ this ->fail ('Expected exception for concat on integer field ' );
598- } catch (DatabaseException $ e ) {
598+ } catch (StructureException $ e ) {
599599 $ this ->assertStringContainsString ("Cannot apply stringConcat operator " , $ e ->getMessage ());
600600 }
601601
@@ -605,7 +605,7 @@ public function testOperatorValidationEdgeCases(): void
605605 'string_field ' => Operator::arrayAppend (['new ' ])
606606 ]));
607607 $ this ->fail ('Expected exception for arrayAppend on string field ' );
608- } catch (DatabaseException $ e ) {
608+ } catch (StructureException $ e ) {
609609 $ this ->assertStringContainsString ("Cannot apply arrayAppend operator to non-array field 'string_field' " , $ e ->getMessage ());
610610 }
611611
@@ -615,7 +615,7 @@ public function testOperatorValidationEdgeCases(): void
615615 'int_field ' => Operator::toggle ()
616616 ]));
617617 $ this ->fail ('Expected exception for toggle on integer field ' );
618- } catch (DatabaseException $ e ) {
618+ } catch (StructureException $ e ) {
619619 $ this ->assertStringContainsString ("Cannot apply toggle operator to non-boolean field 'int_field' " , $ e ->getMessage ());
620620 }
621621
@@ -625,7 +625,7 @@ public function testOperatorValidationEdgeCases(): void
625625 'string_field ' => Operator::dateAddDays (5 )
626626 ]));
627627 $ this ->fail ('Expected exception for dateAddDays on string field ' );
628- } catch (DatabaseException $ e ) {
628+ } catch (StructureException $ e ) {
629629 // Date operators check if string can be parsed as date
630630 $ this ->assertStringContainsString ("Cannot apply dateAddDays operator to non-datetime field 'string_field' " , $ e ->getMessage ());
631631 }
@@ -660,7 +660,7 @@ public function testOperatorDivisionModuloByZero(): void
660660 'number ' => Operator::divide (0 )
661661 ]));
662662 $ this ->fail ('Expected exception for division by zero ' );
663- } catch (DatabaseException $ e ) {
663+ } catch (OperatorException $ e ) {
664664 $ this ->assertStringContainsString ("Division by zero is not allowed " , $ e ->getMessage ());
665665 }
666666
@@ -670,7 +670,7 @@ public function testOperatorDivisionModuloByZero(): void
670670 'number ' => Operator::modulo (0 )
671671 ]));
672672 $ this ->fail ('Expected exception for modulo by zero ' );
673- } catch (DatabaseException $ e ) {
673+ } catch (OperatorException $ e ) {
674674 $ this ->assertStringContainsString ("Modulo by zero is not allowed " , $ e ->getMessage ());
675675 }
676676
@@ -716,7 +716,7 @@ public function testOperatorArrayInsertOutOfBounds(): void
716716 'items ' => Operator::arrayInsert (10 , 'new ' ) // Index 10 > length 3
717717 ]));
718718 $ this ->fail ('Expected exception for out of bounds insert ' );
719- } catch (DatabaseException $ e ) {
719+ } catch (StructureException $ e ) {
720720 $ this ->assertStringContainsString ("Cannot apply arrayInsert operator: index 10 is out of bounds for array of length 3 " , $ e ->getMessage ());
721721 }
722722
@@ -865,7 +865,7 @@ public function testOperatorReplaceValidation(): void
865865 'number ' => Operator::stringReplace ('4 ' , '5 ' )
866866 ]));
867867 $ this ->fail ('Expected exception for replace on integer field ' );
868- } catch (DatabaseException $ e ) {
868+ } catch (StructureException $ e ) {
869869 $ this ->assertStringContainsString ("Cannot apply stringReplace operator to non-string field 'number' " , $ e ->getMessage ());
870870 }
871871
@@ -1687,7 +1687,7 @@ public function testOperatorArraySizeLimit(): void
16871687 try {
16881688 $ database ->updateDocument ($ collectionId , 'doc ' , new Document (['tags ' => $ operator ]));
16891689 $ this ->fail ("Expected an exception for {$ name } exceeding the array operator size limit " );
1690- } catch (DatabaseException $ e ) {
1690+ } catch (StructureException $ e ) {
16911691 $ this ->assertStringContainsString ('exceeds maximum allowed size ' , $ e ->getMessage ());
16921692 }
16931693 }
@@ -1723,7 +1723,7 @@ public function testOperatorArrayFilterRejectsUnknownCondition(): void
17231723 'tags ' => Operator::arrayFilter ('bogusCondition ' , 'x ' ),
17241724 ]));
17251725 $ this ->fail ('Expected an exception for an invalid array filter condition ' );
1726- } catch (DatabaseException $ e ) {
1726+ } catch (StructureException $ e ) {
17271727 $ this ->assertStringContainsString ('filter condition ' , $ e ->getMessage ());
17281728 }
17291729
@@ -3799,7 +3799,7 @@ public function testOperatorArrayInsertAtExactBoundaries(): void
37993799 'items ' => Operator::arrayInsert (10 , 'z ' )
38003800 ]));
38013801 $ this ->fail ('Expected exception for out of bounds insert ' );
3802- } catch (DatabaseException $ e ) {
3802+ } catch (StructureException $ e ) {
38033803 $ this ->assertStringContainsString ('out of bounds ' , $ e ->getMessage ());
38043804 }
38053805
0 commit comments