99use MongoDB \Driver \ReadPreference ;
1010use MongoDB \Driver \WriteConcern ;
1111use MongoDB \Exception \InvalidArgumentException ;
12+ use MongoDB \Exception \UnsupportedException ;
1213use MongoDB \Operation \Count ;
1314use MongoDB \Operation \MapReduce ;
1415use MongoDB \Tests \CommandObserver ;
@@ -619,8 +620,6 @@ function(array $event) {
619620
620621 /**
621622 * @dataProvider collectionWriteMethodClosures
622- * @expectedException MongoDB\Exception\UnsupportedException
623- * @expectedExceptionMessage "writeConcern" option cannot be specified within a transaction
624623 */
625624 public function testMethodInTransactionWithWriteConcernOption ($ method )
626625 {
@@ -631,6 +630,9 @@ public function testMethodInTransactionWithWriteConcernOption($method)
631630 $ session = $ this ->manager ->startSession ();
632631 $ session ->startTransaction ();
633632
633+ $ this ->expectException (UnsupportedException::class);
634+ $ this ->expectExceptionMessage ('"writeConcern" option cannot be specified within a transaction ' );
635+
634636 try {
635637 call_user_func ($ method , $ this ->collection , $ session , ['writeConcern ' => new WriteConcern (1 )]);
636638 } finally {
@@ -640,8 +642,6 @@ public function testMethodInTransactionWithWriteConcernOption($method)
640642
641643 /**
642644 * @dataProvider collectionReadMethodClosures
643- * @expectedException MongoDB\Exception\UnsupportedException
644- * @expectedExceptionMessage "readConcern" option cannot be specified within a transaction
645645 */
646646 public function testMethodInTransactionWithReadConcernOption ($ method )
647647 {
@@ -652,6 +652,9 @@ public function testMethodInTransactionWithReadConcernOption($method)
652652 $ session = $ this ->manager ->startSession ();
653653 $ session ->startTransaction ();
654654
655+ $ this ->expectException (UnsupportedException::class);
656+ $ this ->expectExceptionMessage ('"readConcern" option cannot be specified within a transaction ' );
657+
655658 try {
656659 call_user_func ($ method , $ this ->collection , $ session , ['readConcern ' => new ReadConcern (ReadConcern::LOCAL )]);
657660 } finally {
0 commit comments