feat: more expectations

This commit is contained in:
Nuno Maduro
2023-06-15 18:22:23 +02:00
parent d5334f96a4
commit c98d8ca26a
2 changed files with 22 additions and 1 deletions

View File

@ -479,6 +479,27 @@ final class Expectation
return $this->toBeEnum(); 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. * Asserts that the given expectation target is interface.
*/ */

View File

@ -30,4 +30,4 @@ test('contracts')
'NunoMaduro\Collision\Contracts', 'NunoMaduro\Collision\Contracts',
'Pest\Factories\TestCaseMethodFactory', 'Pest\Factories\TestCaseMethodFactory',
'Symfony\Component\Console', 'Symfony\Component\Console',
]); ])->toBeInterfaces();