feat: toHaveAttribute expectation

This commit is contained in:
Thai Nguyen Hung
2023-08-24 14:26:54 +07:00
parent 14859a4c89
commit 678898efe7
6 changed files with 84 additions and 0 deletions

View File

@ -378,6 +378,21 @@ final class OppositeExpectation
);
}
/**
* Asserts that the given expectation target not to have the given attribute.
*
* @param class-string $attribute
*/
public function toHaveAttribute(string $attribute): ArchExpectation
{
return Targeted::make(
$this->original,
fn (ObjectDescription $object): bool => $object->reflectionClass->getAttributes($attribute) === [],
"to not have attribute '{$attribute}'",
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class'))
);
}
/**
* Handle dynamic method calls into the original expectation.
*