Merge pull request #1256 from mazesec/add-slugify-method

Add slugify Method to Str Class and toBeSlug Assertion to Expectation Class
This commit is contained in:
nuno maduro
2025-07-22 23:08:15 +01:00
committed by GitHub
3 changed files with 52 additions and 2 deletions

View File

@ -0,0 +1,24 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('This is a Test String!')->toBeSlug()
->and('Another Test String')->toBeSlug();
});
test('failures', function () {
expect('')->toBeSlug();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect('')->toBeSlug('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('failures with default message', function () {
expect('')->toBeSlug();
})->throws(ExpectationFailedException::class, 'Failed asserting that can be converted to a slug.');
test('not failures', function () {
expect('This is a Test String!')->not->toBeSlug();
})->throws(ExpectationFailedException::class);