Import PR #334 from GitHub.

Add verification before execute verifyInOrder

PiperOrigin-RevId: 358883295
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 139cc63..c61683a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
 * `verifyInOrder` now returns a `List<VerificationResult>` which stores
   arguments which were captured in a call to `verifiyInOrder`.
 * **Breaking change:** Remove the public constructor for `VerificationResult`.
+* Doesn't allow `verify` been used inside the `verifyInOrder`.
 
 ## 5.0.0-nullsafety.7
 
diff --git a/lib/src/mock.dart b/lib/src/mock.dart
index 115bc8b..76b88a9 100644
--- a/lib/src/mock.dart
+++ b/lib/src/mock.dart
@@ -939,6 +939,10 @@
     }
     throw StateError(message);
   }
+  if (_verificationInProgress) {
+    fail('There is already a verification in progress, '
+        'check if it was not called with a verify argument(s)');
+  }
   _verificationInProgress = true;
   return <T>(T mock) {
     _verificationInProgress = false;
diff --git a/test/verify_test.dart b/test/verify_test.dart
index c4e0018..59c2575 100644
--- a/test/verify_test.dart
+++ b/test/verify_test.dart
@@ -457,6 +457,19 @@
       });
     });
 
+    test('verify been used as an argument fails', () {
+      mock.methodWithoutArgs();
+      mock.getter;
+      expectFail(
+          'There is already a verification in progress, '
+          'check if it was not called with a verify argument(s)', () {
+        verifyInOrder([
+          verify(mock.getter),
+          verify(mock.methodWithoutArgs()),
+        ]);
+      });
+    });
+
     test('incomplete fails', () {
       mock.methodWithoutArgs();
       expectFail(