change: refactors DependOn to Use

This commit is contained in:
Nuno Maduro
2022-12-29 16:34:15 +00:00
parent 227d32a1fd
commit 39ee5b9b08
2 changed files with 21 additions and 21 deletions

View File

@ -9,10 +9,10 @@ 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\ToBeUsedOnNothing;
use Pest\Arch\Expectations\ToDependOn; use Pest\Arch\Expectations\ToUse;
use Pest\Arch\Expectations\ToDependOnNothing; use Pest\Arch\Expectations\ToUseNothing;
use Pest\Arch\Expectations\ToOnlyBeUsedOn; use Pest\Arch\Expectations\ToOnlyBeUsedOn;
use Pest\Arch\Expectations\ToOnlyDependOn; use Pest\Arch\Expectations\ToOnlyUse;
use Pest\Concerns\Extendable; use Pest\Concerns\Extendable;
use Pest\Concerns\Pipeable; use Pest\Concerns\Pipeable;
use Pest\Concerns\Retrievable; use Pest\Concerns\Retrievable;
@ -360,31 +360,31 @@ final class Expectation
} }
/** /**
* Asserts that the given expectation target depends on the given dependencies. * Asserts that the given expectation target use the given dependencies.
* *
* @param array<int, string>|string $targets * @param array<int, string>|string $targets
*/ */
public function toDependOn(array|string $targets): ArchExpectation public function toUse(array|string $targets): ArchExpectation
{ {
return ToDependOn::make($this, $targets); return ToUse::make($this, $targets);
} }
/** /**
* Asserts that the given expectation target "only" depends on the given dependencies. * Asserts that the given expectation target "only" use on the given dependencies.
* *
* @param array<int, string>|string $targets * @param array<int, string>|string $targets
*/ */
public function toOnlyDependOn(array|string $targets): ArchExpectation public function toOnlyUse(array|string $targets): ArchExpectation
{ {
return ToOnlyDependOn::make($this, $targets); return ToOnlyUse::make($this, $targets);
} }
/** /**
* Asserts that the given expectation target does not have any dependencies. * Asserts that the given expectation target does not use any dependencies.
*/ */
public function toDependOnNothing(): ArchExpectation public function toUseNothing(): ArchExpectation
{ {
return ToDependOnNothing::make($this); return ToUseNothing::make($this);
} }
public function toBeUsed(): never public function toBeUsed(): never

View File

@ -7,7 +7,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\ToBeUsedOnNothing;
use Pest\Arch\Expectations\ToDependOn; use Pest\Arch\Expectations\ToUse;
use Pest\Arch\GroupArchExpectation; use Pest\Arch\GroupArchExpectation;
use Pest\Arch\SingleArchExpectation; use Pest\Arch\SingleArchExpectation;
use Pest\Exceptions\InvalidExpectation; use Pest\Exceptions\InvalidExpectation;
@ -60,28 +60,28 @@ final class OppositeExpectation
} }
/** /**
* Asserts that the given expectation target does not depend on any of the given dependencies. * Asserts that the given expectation target does not use any of the given dependencies.
* *
* @param array<int, string>|string $targets * @param array<int, string>|string $targets
*/ */
public function toDependOn(array|string $targets): ArchExpectation public function toUse(array|string $targets): ArchExpectation
{ {
return GroupArchExpectation::fromExpectations($this->original, array_map(fn (string $target): SingleArchExpectation => ToDependOn::make($this->original, $target)->opposite( return GroupArchExpectation::fromExpectations($this->original, array_map(fn (string $target): SingleArchExpectation => ToUse::make($this->original, $target)->opposite(
fn () => $this->throwExpectationFailedException('toDependOn', $target), fn () => $this->throwExpectationFailedException('toUse', $target),
), is_string($targets) ? [$targets] : $targets)); ), is_string($targets) ? [$targets] : $targets));
} }
/** /**
* @param array<int, string>|string $targets * @param array<int, string>|string $targets
*/ */
public function toOnlyDependOn(array|string $targets): never public function toOnlyUse(array|string $targets): never
{ {
throw InvalidExpectation::fromMethods(['not', 'toOnlyDependOn']); throw InvalidExpectation::fromMethods(['not', 'toOnlyUse']);
} }
public function toDependOnNothing(): never public function toUseNothing(): never
{ {
throw InvalidExpectation::fromMethods(['not', 'toDependOnNothing']); throw InvalidExpectation::fromMethods(['not', 'toUseNothing']);
} }
/** /**