@@ -446,6 +446,34 @@ public function test_rollback_no_active_transaction(): void {
446446 $ this ->driver ->rollBack ();
447447 }
448448
449+ public function test_transaction_methods_flush_operation_state (): void {
450+ $ this ->driver ->query ( 'CREATE TABLE t (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ' );
451+ $ this ->driver ->query ( 'INSERT INTO t (id) VALUES (NULL) ' );
452+
453+ $ this ->assertSame ( '1 ' , $ this ->driver ->lastInsertId () );
454+ $ this ->assertTrue ( $ this ->driver ->beginTransaction () );
455+ $ this ->assertSame ( '0 ' , $ this ->driver ->lastInsertId () );
456+ $ this ->assertSame ( '' , $ this ->driver ->get_last_mysql_query () );
457+ $ this ->assertSame ( array ( 'BEGIN IMMEDIATE ' ), array_column ( $ this ->driver ->get_last_sqlite_queries (), 'sql ' ) );
458+
459+ $ this ->driver ->query ( 'INSERT INTO t (id) VALUES (NULL) ' );
460+
461+ $ this ->assertSame ( '2 ' , $ this ->driver ->lastInsertId () );
462+ $ this ->assertTrue ( $ this ->driver ->commit () );
463+ $ this ->assertSame ( '0 ' , $ this ->driver ->lastInsertId () );
464+ $ this ->assertSame ( '' , $ this ->driver ->get_last_mysql_query () );
465+ $ this ->assertSame ( array ( 'COMMIT ' ), array_column ( $ this ->driver ->get_last_sqlite_queries (), 'sql ' ) );
466+
467+ $ this ->driver ->beginTransaction ();
468+ $ this ->driver ->query ( 'INSERT INTO t (id) VALUES (NULL) ' );
469+
470+ $ this ->assertSame ( '3 ' , $ this ->driver ->lastInsertId () );
471+ $ this ->assertTrue ( $ this ->driver ->rollBack () );
472+ $ this ->assertSame ( '0 ' , $ this ->driver ->lastInsertId () );
473+ $ this ->assertSame ( '' , $ this ->driver ->get_last_mysql_query () );
474+ $ this ->assertSame ( array ( 'ROLLBACK ' ), array_column ( $ this ->driver ->get_last_sqlite_queries (), 'sql ' ) );
475+ }
476+
449477 public function test_fetch_default (): void {
450478 // Default fetch mode is PDO::FETCH_BOTH.
451479 $ result = $ this ->driver ->query ( "SELECT 1, 'abc', 2 " );
0 commit comments