From c98d8ca26a5ed7d5a4c0b338ddb66d2f0eee369d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 15 Jun 2023 18:22:23 +0200 Subject: [PATCH] feat: more expectations --- src/Expectation.php | 21 +++++++++++++++++++++ tests/Arch.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Expectation.php b/src/Expectation.php index 7a8090f0..d237b567 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -479,6 +479,27 @@ final class Expectation return $this->toBeEnum(); } + /** + * Asserts that the given expectation targets is an class. + */ + public function toBeClass(): ArchExpectation + { + return Targeted::make( + $this, + fn (ObjectDescription $object): bool => class_exists($object->name), + 'to be class', + FileLineFinder::where(fn (string $line): bool => true), + ); + } + + /** + * Asserts that the given expectation targets are classes. + */ + public function toBeClasses(): ArchExpectation + { + return $this->toBeClass(); + } + /** * Asserts that the given expectation target is interface. */ diff --git a/tests/Arch.php b/tests/Arch.php index eb47a06e..a46c37b2 100644 --- a/tests/Arch.php +++ b/tests/Arch.php @@ -30,4 +30,4 @@ test('contracts') 'NunoMaduro\Collision\Contracts', 'Pest\Factories\TestCaseMethodFactory', 'Symfony\Component\Console', - ]); + ])->toBeInterfaces();