@@ -648,6 +648,264 @@ public function test_mysqli_multi_query_procedural(): void
648648        $ this assertDatabaseAttributesForAllSpans ($ offset
649649    }
650650
651+     public  function  test_mysqli_transaction_rollback_objective (): void 
652+     {
653+         mysqli_report (MYSQLI_REPORT_ERROR  | MYSQLI_REPORT_STRICT );
654+ 
655+         $ mysqlinew  mysqli ($ this mysqlHost , $ this user , $ this passwd , $ this database );
656+ 
657+         $ offset0 ;
658+         $ this assertSame ('mysqli::__construct ' , $ this storage ->offsetGet ($ offsetgetName ());
659+ 
660+         $ mysqliquery ('DROP TABLE IF EXISTS language; ' );
661+         $ offset
662+ 
663+         $ mysqliquery ('CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ' );
664+         $ offset
665+ 
666+         $ mysqlibegin_transaction (name: 'supertransaction ' );
667+         $ offset
668+         $ this assertSame ('mysqli::begin_transaction ' , $ this storage ->offsetGet ($ offsetgetName ());
669+         $ this assertAttributes ($ offset
670+             'db.transaction.name '  => 'supertransaction ' ,
671+         ]);
672+ 
673+         try  {
674+             // Insert some values 
675+             $ mysqliquery ("INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123) " );
676+ 
677+             $ offset
678+             $ this assertSame ('mysqli::query ' , $ this storage ->offsetGet ($ offsetgetName ());
679+             $ this assertAttributes ($ offset
680+                 TraceAttributes::DB_STATEMENT  => "INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123) " ,
681+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
682+             ]);
683+ 
684+             // Try to insert invalid values 
685+             $ language_code'FR ' ;
686+             $ native_speakers'Unknown ' ;
687+             $ stmt$ mysqliprepare ('INSERT INTO language(Code, Speakers) VALUES (?,?) ' );
688+ 
689+             $ stmtbind_param ('ss ' , $ language_code$ native_speakers
690+             $ stmtexecute (); // THROWS HERE 
691+ 
692+             $ this fail ('Should never reach this point ' );
693+         } catch  (mysqli_sql_exception $ exception
694+             $ offset
695+             $ this assertSame ('mysqli_stmt::execute ' , $ this storage ->offsetGet ($ offsetgetName ());
696+             $ this assertAttributes ($ offset
697+                 TraceAttributes::DB_STATEMENT  => 'INSERT INTO language(Code, Speakers) VALUES (?,?) ' ,
698+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
699+             ]);
700+ 
701+             $ mysqlirollback (name: 'supertransaction ' );
702+             $ offset
703+             $ this assertSame ('mysqli::rollback ' , $ this storage ->offsetGet ($ offsetgetName ());
704+             $ this assertAttributes ($ offset
705+                 'db.transaction.name '  => 'supertransaction ' ,
706+             ]);
707+ 
708+         }
709+ 
710+         $ offset
711+         $ this assertCount ($ offset$ this storage );
712+         $ this assertDatabaseAttributesForAllSpans ($ offset
713+     }
714+ 
715+     public  function  test_mysqli_transaction_rollback_procedural (): void 
716+     {
717+         mysqli_report (MYSQLI_REPORT_ERROR );
718+ 
719+         $ mysqlimysqli_connect ($ this mysqlHost , $ this user , $ this passwd , $ this database );
720+ 
721+         $ offset0 ;
722+         $ this assertSame ('mysqli_connect ' , $ this storage ->offsetGet ($ offsetgetName ());
723+ 
724+         mysqli_query ($ mysqli'DROP TABLE IF EXISTS language; ' );
725+         $ offset
726+ 
727+         mysqli_query ($ mysqli'CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ' );
728+         $ offset
729+ 
730+         mysqli_begin_transaction ($ mysqli'supertransaction ' );
731+         $ offset
732+         $ this assertSame ('mysqli_begin_transaction ' , $ this storage ->offsetGet ($ offsetgetName ());
733+         $ this assertAttributes ($ offset
734+             'db.transaction.name '  => 'supertransaction ' ,
735+         ]);
736+ 
737+         try  {
738+             // Insert some values 
739+             mysqli_query ($ mysqli"INSERT INTO language(Code, Speakers) VALUES ('DE', 76000001) " );
740+ 
741+             $ offset
742+             $ this assertSame ('mysqli_query ' , $ this storage ->offsetGet ($ offsetgetName ());
743+             $ this assertAttributes ($ offset
744+                 TraceAttributes::DB_STATEMENT  => "INSERT INTO language(Code, Speakers) VALUES ('DE', 76000001) " ,
745+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
746+             ]);
747+ 
748+             // Try to insert invalid values 
749+             $ language_code'FR ' ;
750+             $ native_speakers'Unknown ' ;
751+             $ stmtmysqli_prepare ($ mysqli'INSERT INTO language(Code, Speakers) VALUES (?,?) ' );
752+ 
753+             mysqli_stmt_bind_param ($ stmt'ss ' , $ language_code$ native_speakers
754+ 
755+             try  {
756+                 mysqli_stmt_execute ($ stmt
757+             } catch  (\PHPUnit \Framework \Error \Warning   $ e
758+                 $ offset
759+                 $ this assertSame ('mysqli_stmt_execute ' , $ this storage ->offsetGet ($ offsetgetName ());
760+                 $ this assertAttributes ($ offset
761+                     TraceAttributes::DB_STATEMENT  => 'INSERT INTO language(Code, Speakers) VALUES (?,?) ' ,
762+                     TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
763+                 ]);
764+ 
765+                 mysqli_rollback ($ mysqli'supertransaction ' );
766+                 $ offset
767+                 $ this assertSame ('mysqli_rollback ' , $ this storage ->offsetGet ($ offsetgetName ());
768+                 $ this assertAttributes ($ offset
769+                     'db.transaction.name '  => 'supertransaction ' ,
770+                 ]);
771+             }
772+         } catch  (mysqli_sql_exception $ exception
773+             $ this fail ('Should never reach this point ' );
774+         }
775+ 
776+         $ offset
777+         $ this assertCount ($ offset$ this storage );
778+         $ this assertDatabaseAttributesForAllSpans ($ offset
779+     }
780+ 
781+     public  function  test_mysqli_transaction_commit_objective (): void 
782+     {
783+         mysqli_report (MYSQLI_REPORT_ERROR  | MYSQLI_REPORT_STRICT );
784+ 
785+         $ mysqlinew  mysqli ($ this mysqlHost , $ this user , $ this passwd , $ this database );
786+ 
787+         $ offset0 ;
788+         $ this assertSame ('mysqli::__construct ' , $ this storage ->offsetGet ($ offsetgetName ());
789+ 
790+         $ mysqliquery ('DROP TABLE IF EXISTS language; ' );
791+         $ offset
792+ 
793+         $ mysqliquery ('CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ' );
794+         $ offset
795+ 
796+         $ mysqlibegin_transaction (name: 'supertransaction ' );
797+         $ offset
798+         $ this assertSame ('mysqli::begin_transaction ' , $ this storage ->offsetGet ($ offsetgetName ());
799+         $ this assertAttributes ($ offset
800+             'db.transaction.name '  => 'supertransaction ' ,
801+         ]);
802+ 
803+         try  {
804+             // Insert some values 
805+             $ mysqliquery ("INSERT INTO language(Code, Speakers) VALUES ('DE', 76000001) " );
806+ 
807+             $ offset
808+             $ this assertSame ('mysqli::query ' , $ this storage ->offsetGet ($ offsetgetName ());
809+             $ this assertAttributes ($ offset
810+                 TraceAttributes::DB_STATEMENT  => "INSERT INTO language(Code, Speakers) VALUES ('DE', 76000001) " ,
811+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
812+             ]);
813+ 
814+             // Try to insert invalid values 
815+             $ language_code'FR ' ;
816+             $ native_speakers66000002 ;
817+             $ stmt$ mysqliprepare ('INSERT INTO language(Code, Speakers) VALUES (?,?) ' );
818+ 
819+             $ stmtbind_param ('ss ' , $ language_code$ native_speakers
820+             $ stmtexecute ();
821+ 
822+             $ offset
823+             $ this assertSame ('mysqli_stmt::execute ' , $ this storage ->offsetGet ($ offsetgetName ());
824+             $ this assertAttributes ($ offset
825+                 TraceAttributes::DB_STATEMENT  => 'INSERT INTO language(Code, Speakers) VALUES (?,?) ' ,
826+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
827+             ]);
828+ 
829+             $ mysqlicommit (name: 'supertransaction ' );
830+ 
831+             $ offset
832+             $ this assertSame ('mysqli::commit ' , $ this storage ->offsetGet ($ offsetgetName ());
833+             $ this assertAttributes ($ offset
834+                 'db.transaction.name '  => 'supertransaction ' ,
835+             ]);
836+         } catch  (mysqli_sql_exception $ exception
837+             $ this fail ('Unexpected exception was thrown:  '  . $ exceptiongetMessage ());
838+         }
839+ 
840+         $ offset
841+         $ this assertCount ($ offset$ this storage );
842+         $ this assertDatabaseAttributesForAllSpans ($ offset
843+     }
844+ 
845+     public  function  test_mysqli_transaction_commit_procedural (): void 
846+     {
847+         mysqli_report (MYSQLI_REPORT_ERROR );
848+ 
849+         $ mysqlimysqli_connect ($ this mysqlHost , $ this user , $ this passwd , $ this database );
850+ 
851+         $ offset0 ;
852+         $ this assertSame ('mysqli_connect ' , $ this storage ->offsetGet ($ offsetgetName ());
853+ 
854+         mysqli_query ($ mysqli'DROP TABLE IF EXISTS language; ' );
855+         $ offset
856+ 
857+         mysqli_query ($ mysqli'CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ' );
858+         $ offset
859+ 
860+         mysqli_begin_transaction ($ mysqli'supertransaction ' );
861+         $ offset
862+         $ this assertSame ('mysqli_begin_transaction ' , $ this storage ->offsetGet ($ offsetgetName ());
863+         $ this assertAttributes ($ offset
864+             'db.transaction.name '  => 'supertransaction ' ,
865+         ]);
866+ 
867+         try  {
868+             // Insert some values 
869+             mysqli_query ($ mysqli"INSERT INTO language(Code, Speakers) VALUES ('DE', 76000001) " );
870+ 
871+             $ offset
872+             $ this assertSame ('mysqli_query ' , $ this storage ->offsetGet ($ offsetgetName ());
873+             $ this assertAttributes ($ offset
874+                 TraceAttributes::DB_STATEMENT  => "INSERT INTO language(Code, Speakers) VALUES ('DE', 76000001) " ,
875+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
876+             ]);
877+ 
878+             // Try to insert invalid values 
879+             $ language_code'FR ' ;
880+             $ native_speakers66000002 ;
881+             $ stmtmysqli_prepare ($ mysqli'INSERT INTO language(Code, Speakers) VALUES (?,?) ' );
882+ 
883+             mysqli_stmt_bind_param ($ stmt'ss ' , $ language_code$ native_speakers
884+             mysqli_stmt_execute ($ stmt
885+ 
886+             $ offset
887+             $ this assertSame ('mysqli_stmt_execute ' , $ this storage ->offsetGet ($ offsetgetName ());
888+             $ this assertAttributes ($ offset
889+                 TraceAttributes::DB_STATEMENT  => 'INSERT INTO language(Code, Speakers) VALUES (?,?) ' ,
890+                 TraceAttributes::DB_OPERATION_NAME  => 'INSERT ' ,
891+             ]);
892+ 
893+             mysqli_commit ($ mysqli'supertransaction ' );
894+ 
895+             $ offset
896+             $ this assertSame ('mysqli_commit ' , $ this storage ->offsetGet ($ offsetgetName ());
897+             $ this assertAttributes ($ offset
898+                 'db.transaction.name '  => 'supertransaction ' ,
899+             ]);
900+         } catch  (mysqli_sql_exception $ exception
901+             $ this fail ('Unexpected exception was thrown:  '  . $ exceptiongetMessage ());
902+         }
903+ 
904+         $ offset
905+         $ this assertCount ($ offset$ this storage );
906+         $ this assertDatabaseAttributesForAllSpans ($ offset
907+     }
908+ 
651909    public  function  test_mysqli_stmt_execute_objective (): void 
652910    {
653911        mysqli_report (MYSQLI_REPORT_ERROR  | MYSQLI_REPORT_STRICT );
0 commit comments