--TEST-- MongoDB\Driver\Session::getTransactionState() --SKIPIF-- --FILE-- COLLECTION_NAME, ]); $manager->executeCommand(DATABASE_NAME, $cmd); /* Start a session */ $session = $manager->startSession(); echo "Test case: Empty transaction, and aborted empty transaction\n"; var_dump($session->getTransactionState()); $session->startTransaction(); var_dump($session->getTransactionState()); $session->abortTransaction(); var_dump($session->getTransactionState()); echo "\n"; echo "Test case: Empty transaction, and committed empty transaction\n"; $session->startTransaction(); var_dump($session->getTransactionState()); $session->commitTransaction(); var_dump($session->getTransactionState()); echo "\n"; echo "Test case: Aborted transaction with one operation\n"; $session->startTransaction(); var_dump($session->getTransactionState()); $bw = new \MongoDB\Driver\BulkWrite(); $bw->insert( [ '_id' => 0, 'msg' => 'Initial Value' ] ); $manager->executeBulkWrite(NS, $bw, ['session' => $session]); var_dump($session->getTransactionState()); $session->abortTransaction(); var_dump($session->getTransactionState()); echo "\n"; echo "Test case: Committed transaction with one operation\n"; $session->startTransaction(); var_dump($session->getTransactionState()); $bw = new \MongoDB\Driver\BulkWrite(); $bw->insert( [ '_id' => 0, 'msg' => 'Initial Value' ] ); $manager->executeBulkWrite(NS, $bw, ['session' => $session]); var_dump($session->getTransactionState()); $session->commitTransaction(); var_dump($session->getTransactionState()); ?> ===DONE=== --EXPECTF-- Test case: Empty transaction, and aborted empty transaction string(4) "none" string(8) "starting" string(7) "aborted" Test case: Empty transaction, and committed empty transaction string(8) "starting" string(9) "committed" Test case: Aborted transaction with one operation string(8) "starting" string(11) "in_progress" string(7) "aborted" Test case: Committed transaction with one operation string(8) "starting" string(11) "in_progress" string(9) "committed" ===DONE===