Add toHaveMethod arch expectation

This commit is contained in:
ludoguenet
2023-09-01 18:32:40 +02:00
parent 04fa6b6372
commit 9dabecacbf
10 changed files with 121 additions and 22 deletions

View File

@ -501,6 +501,19 @@ final class Expectation
);
}
/**
* Asserts that the given expectation target have a specific method.
*/
public function toHaveMethod(string $method): ArchExpectation
{
return Targeted::make(
$this,
fn (ObjectDescription $object): bool => $object->reflectionClass->hasMethod($method),
'to have method',
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
);
}
/**
* Asserts that the given expectation target is enum.
*/