feat: adds toBeUsedOnNothing and toBeUsed

This commit is contained in:
Nuno Maduro
2022-12-28 16:27:08 +00:00
parent 174a9ca60b
commit 476f56b617
2 changed files with 32 additions and 0 deletions

View File

@ -6,6 +6,7 @@ namespace Pest\Expectations;
use Pest\Arch\Contracts\ArchExpectation;
use Pest\Arch\Expectations\ToBeUsedOn;
use Pest\Arch\Expectations\ToBeUsedOnNothing;
use Pest\Arch\Expectations\ToDependOn;
use Pest\Arch\GroupArchExpectation;
use Pest\Arch\SingleArchExpectation;
@ -83,6 +84,14 @@ final class OppositeExpectation
throw InvalidExpectation::fromMethods(['not', 'toDependOnNothing']);
}
/**
* Asserts that the given expectation dependency is not used.
*/
public function toBeUsed(): ArchExpectation
{
return ToBeUsedOnNothing::make($this->original);
}
/**
* Asserts that the given expectation dependency is not used by any of the given targets.
*
@ -100,6 +109,14 @@ final class OppositeExpectation
throw InvalidExpectation::fromMethods(['not', 'toOnlyBeUsedOn']);
}
/**
* Asserts that the given expectation dependency is not used.
*/
public function toBeUsedOnNothing(): ArchExpectation
{
throw InvalidExpectation::fromMethods(['not', 'toBeUsedOnNothing']);
}
/**
* Handle dynamic method calls into the original expectation.
*