mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Add slugify method
This commit is contained in:
@ -661,7 +661,7 @@ final class Expectation
|
||||
{
|
||||
foreach ($keys as $k => $key) {
|
||||
if (is_array($key)) {
|
||||
$this->toHaveKeys(array_keys(Arr::dot($key, $k.'.')), $message);
|
||||
$this->toHaveKeys(array_keys(Arr::dot($key, $k . '.')), $message);
|
||||
} else {
|
||||
$this->toHaveKey($key, message: $message);
|
||||
}
|
||||
@ -1159,4 +1159,21 @@ final class Expectation
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value can be converted to a slug
|
||||
*
|
||||
* @return self<TValue>
|
||||
*/
|
||||
public function toBeSlug(string $message = ''): self
|
||||
{
|
||||
if ($message === '') {
|
||||
$message = "Failed asserting that {$this->value} can be converted to a slug.";
|
||||
}
|
||||
|
||||
$slug = Str::slugify((string) $this->value);
|
||||
Assert::assertNotEmpty($slug, $message);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user