feat: toBeFinal

This commit is contained in:
Nuno Maduro
2023-05-27 20:31:21 +01:00
parent be9056f978
commit 0de1ce053a
2 changed files with 18 additions and 2 deletions

View File

@ -7,6 +7,7 @@ namespace Pest;
use BadMethodCallException; use BadMethodCallException;
use Closure; use Closure;
use Pest\Arch\Contracts\ArchExpectation; use Pest\Arch\Contracts\ArchExpectation;
use Pest\Arch\Expectations\ToBeFinal;
use Pest\Arch\Expectations\ToBeUsedIn; use Pest\Arch\Expectations\ToBeUsedIn;
use Pest\Arch\Expectations\ToBeUsedInNothing; use Pest\Arch\Expectations\ToBeUsedInNothing;
use Pest\Arch\Expectations\ToOnlyBeUsedIn; use Pest\Arch\Expectations\ToOnlyBeUsedIn;
@ -372,14 +373,20 @@ final class Expectation
/** /**
* Asserts that the given expectation target use the "declare(strict_types=1)" declaration. * Asserts that the given expectation target use the "declare(strict_types=1)" declaration.
*
* @param array<int, string>|string $targets
*/ */
public function toUseStrictTypes(): ArchExpectation public function toUseStrictTypes(): ArchExpectation
{ {
return ToUseStrictTypes::make($this); return ToUseStrictTypes::make($this);
} }
/**
* Asserts that the given expectation target is final.
*/
public function toBeFinal(): ArchExpectation
{
return ToBeFinal::make($this);
}
/** /**
* Asserts that the given expectation target "only" use on the given dependencies. * Asserts that the given expectation target "only" use on the given dependencies.
* *

View File

@ -7,6 +7,7 @@ namespace Pest\Expectations;
use Pest\Arch\Contracts\ArchExpectation; use Pest\Arch\Contracts\ArchExpectation;
use Pest\Arch\Exceptions\ArchExpectationFailedException; use Pest\Arch\Exceptions\ArchExpectationFailedException;
use Pest\Arch\Expectations\NotToUseStrictTypes; use Pest\Arch\Expectations\NotToUseStrictTypes;
use Pest\Arch\Expectations\ToBeFinal;
use Pest\Arch\Expectations\ToBeUsedIn; use Pest\Arch\Expectations\ToBeUsedIn;
use Pest\Arch\Expectations\ToBeUsedInNothing; use Pest\Arch\Expectations\ToBeUsedInNothing;
use Pest\Arch\Expectations\ToUse; use Pest\Arch\Expectations\ToUse;
@ -83,6 +84,14 @@ final class OppositeExpectation
return ToUseStrictTypes::make($this->original, false); return ToUseStrictTypes::make($this->original, false);
} }
/**
* Asserts that the given expectation target is final.
*/
public function toBeFinal(): ArchExpectation
{
return ToBeFinal::make($this->original, false);
}
/** /**
* @param array<int, string>|string $targets * @param array<int, string>|string $targets
*/ */