File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -444,12 +444,14 @@ public function commit(array $options = []): Timestamp
444444 'requestOptions ' => $ this ->requestOptions ,
445445 'transactionOptions ' => $ this ->transactionOptions ,
446446 'singleUse ' => $ this ->transactionSelector ['singleUse ' ] ?? null ,
447+ 'tag ' => $ this ->tag ?? null ,
447448 ]);
448449 if (!empty ($ mutations )) {
449450 // Set the mutation key if we have mutations but do not have a precommit token
450451 $ mutationKey = $ mutations [array_rand ($ mutations )];
451452 $ operationTransactionOptions ['mutationKey ' ] = $ mutationKey ;
452453 }
454+
453455 // Execute the beginTransaction RPC.
454456 $ transaction = $ this ->operation ->transaction ($ this ->session , $ operationTransactionOptions );
455457 // Set the transaction ID of the current transaction.
Original file line number Diff line number Diff line change @@ -921,6 +921,32 @@ public function testRunTransactionAborted()
921921 });
922922 }
923923
924+ public function testRunTransactionWithTagOption ()
925+ {
926+ $ this ->spannerClient ->beginTransaction (
927+ Argument::that (function (BeginTransactionRequest $ request ) {
928+ $ reqOptions = $ request ->getRequestOptions ();
929+ $ this ->assertNotNull ($ reqOptions );
930+ $ this ->assertEquals (self ::TRANSACTION_TAG , $ reqOptions ->getTransactionTag ());
931+ return true ;
932+ }),
933+ Argument::type ('array ' )
934+ )
935+ ->shouldBeCalledOnce ()
936+ ->willReturn (new TransactionProto (['id ' => self ::TRANSACTION ]));
937+
938+ $ this ->spannerClient ->commit (
939+ Argument::type (CommitRequest::class),
940+ Argument::type ('array ' )
941+ )
942+ ->shouldBeCalled ()
943+ ->willReturn ($ this ->commitResponse ());
944+
945+ $ this ->database ->runTransaction (function (Transaction $ t ) {
946+ $ t ->commit ();
947+ }, ['tag ' => self ::TRANSACTION_TAG ]);
948+ }
949+
924950 public function testTransaction ()
925951 {
926952 $ this ->spannerClient ->beginTransaction (
You can’t perform that action at this time.
0 commit comments