From 0de1ce053a36e7ce23797dd452b09117ef2b6fd6 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sat, 27 May 2023 20:31:21 +0100 Subject: [PATCH] feat: `toBeFinal` --- src/Expectation.php | 11 +++++++++-- src/Expectations/OppositeExpectation.php | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index 8579da04..701eadc1 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -7,6 +7,7 @@ namespace Pest; use BadMethodCallException; use Closure; use Pest\Arch\Contracts\ArchExpectation; +use Pest\Arch\Expectations\ToBeFinal; use Pest\Arch\Expectations\ToBeUsedIn; use Pest\Arch\Expectations\ToBeUsedInNothing; 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. - * - * @param array|string $targets */ public function toUseStrictTypes(): ArchExpectation { 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. * diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index 57e0193d..b2932167 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -7,6 +7,7 @@ namespace Pest\Expectations; use Pest\Arch\Contracts\ArchExpectation; use Pest\Arch\Exceptions\ArchExpectationFailedException; use Pest\Arch\Expectations\NotToUseStrictTypes; +use Pest\Arch\Expectations\ToBeFinal; use Pest\Arch\Expectations\ToBeUsedIn; use Pest\Arch\Expectations\ToBeUsedInNothing; use Pest\Arch\Expectations\ToUse; @@ -83,6 +84,14 @@ final class OppositeExpectation 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|string $targets */