mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 18:57:22 +01:00
feat: adds toBeUsedOnNothing and toBeUsed
This commit is contained in:
@ -8,6 +8,7 @@ use BadMethodCallException;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use Pest\Arch\Contracts\ArchExpectation;
|
use Pest\Arch\Contracts\ArchExpectation;
|
||||||
use Pest\Arch\Expectations\ToBeUsedOn;
|
use Pest\Arch\Expectations\ToBeUsedOn;
|
||||||
|
use Pest\Arch\Expectations\ToBeUsedOnNothing;
|
||||||
use Pest\Arch\Expectations\ToDependOn;
|
use Pest\Arch\Expectations\ToDependOn;
|
||||||
use Pest\Arch\Expectations\ToDependOnNothing;
|
use Pest\Arch\Expectations\ToDependOnNothing;
|
||||||
use Pest\Arch\Expectations\ToOnlyBeUsedOn;
|
use Pest\Arch\Expectations\ToOnlyBeUsedOn;
|
||||||
@ -16,6 +17,7 @@ use Pest\Concerns\Extendable;
|
|||||||
use Pest\Concerns\Pipeable;
|
use Pest\Concerns\Pipeable;
|
||||||
use Pest\Concerns\Retrievable;
|
use Pest\Concerns\Retrievable;
|
||||||
use Pest\Exceptions\ExpectationNotFound;
|
use Pest\Exceptions\ExpectationNotFound;
|
||||||
|
use Pest\Exceptions\InvalidExpectation;
|
||||||
use Pest\Exceptions\InvalidExpectationValue;
|
use Pest\Exceptions\InvalidExpectationValue;
|
||||||
use Pest\Expectations\EachExpectation;
|
use Pest\Expectations\EachExpectation;
|
||||||
use Pest\Expectations\HigherOrderExpectation;
|
use Pest\Expectations\HigherOrderExpectation;
|
||||||
@ -385,6 +387,11 @@ final class Expectation
|
|||||||
return ToDependOnNothing::make($this);
|
return ToDependOnNothing::make($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toBeUsed(): never
|
||||||
|
{
|
||||||
|
throw InvalidExpectation::fromMethods(['toBeUsed']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the given expectation dependency is used by the given targets.
|
* Asserts that the given expectation dependency is used by the given targets.
|
||||||
*
|
*
|
||||||
@ -404,4 +411,12 @@ final class Expectation
|
|||||||
{
|
{
|
||||||
return ToOnlyBeUsedOn::make($this, $targets);
|
return ToOnlyBeUsedOn::make($this, $targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation dependency is not used.
|
||||||
|
*/
|
||||||
|
public function toBeUsedOnNothing(): ArchExpectation
|
||||||
|
{
|
||||||
|
return ToBeUsedOnNothing::make($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace Pest\Expectations;
|
|||||||
|
|
||||||
use Pest\Arch\Contracts\ArchExpectation;
|
use Pest\Arch\Contracts\ArchExpectation;
|
||||||
use Pest\Arch\Expectations\ToBeUsedOn;
|
use Pest\Arch\Expectations\ToBeUsedOn;
|
||||||
|
use Pest\Arch\Expectations\ToBeUsedOnNothing;
|
||||||
use Pest\Arch\Expectations\ToDependOn;
|
use Pest\Arch\Expectations\ToDependOn;
|
||||||
use Pest\Arch\GroupArchExpectation;
|
use Pest\Arch\GroupArchExpectation;
|
||||||
use Pest\Arch\SingleArchExpectation;
|
use Pest\Arch\SingleArchExpectation;
|
||||||
@ -83,6 +84,14 @@ final class OppositeExpectation
|
|||||||
throw InvalidExpectation::fromMethods(['not', 'toDependOnNothing']);
|
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.
|
* 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']);
|
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.
|
* Handle dynamic method calls into the original expectation.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user