Merge pull request #449 from pestphp/performs_no_expectations

[2.x] Adds support for chaining `hasNoExpectations` to the test method.
This commit is contained in:
Luke Downing
2022-03-22 13:23:08 +00:00
committed by GitHub
2 changed files with 23 additions and 0 deletions

View File

@ -229,6 +229,18 @@ final class TestCall
return $this;
}
/**
* Informs the test runner that no expectations happen in this test,
* and its purpose is simply to check whether the given code can
* be executed without throwing exceptions.
*/
public function throwsNoExceptions(): TestCall
{
$this->testCaseMethod->proxies->add(Backtrace::file(), Backtrace::line(), 'expectNotToPerformAssertions', []);
return $this;
}
/**
* Saves the property accessors to be used on the target.
*/

View File

@ -0,0 +1,11 @@
<?php
it('allows access to the underlying expectNotToPerformAssertions method', function () {
$this->expectNotToPerformAssertions();
$result = 1 + 1;
});
it('allows performing no expectations without being risky', function () {
$result = 1 + 1;
})->throwsNoExceptions();