From d969eaac2ceb98c788a2cca6614fa2dc63116222 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 8 Dec 2021 08:58:42 +0000 Subject: [PATCH] Adds support for chaining `hasNoExpectations` to the test method. --- src/PendingCalls/TestCall.php | 7 +++++++ tests/Features/HasNoExpectations.php | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/Features/HasNoExpectations.php diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 0d1cd17c..7823cda6 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -160,6 +160,13 @@ final class TestCall return $this; } + public function hasNoExpectations(): TestCall + { + $this->testCaseMethod->proxies->add(Backtrace::file(), Backtrace::line(), 'expectNotToPerformAssertions', []); + + return $this; + } + /** * Saves the property accessors to be used on the target. */ diff --git a/tests/Features/HasNoExpectations.php b/tests/Features/HasNoExpectations.php new file mode 100644 index 00000000..a5804466 --- /dev/null +++ b/tests/Features/HasNoExpectations.php @@ -0,0 +1,11 @@ +expectNotToPerformAssertions(); + + $result = 1 + 1; +}); + +it('allows performing no expectations without being risky', function () { + $result = 1 + 1; +})->hasNoExpectations();