mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
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:
@ -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.
|
||||
*/
|
||||
|
||||
11
tests/Features/ThrowsNoExceptions.php
Normal file
11
tests/Features/ThrowsNoExceptions.php
Normal 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();
|
||||
Reference in New Issue
Block a user