Skip to content

Commit

Permalink
ARW-1019 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
speckmaier committed Sep 30, 2024
1 parent 9b3d2cb commit caefc2e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function fromName(string $name): self
public function __toString(): string
{
return preg_replace(
'~[^a-zA-Z]~',
'~[^a-zA-Z]+~',
'-',
strtolower(
$this->name,
Expand Down
24 changes: 22 additions & 2 deletions tests/Unit/SlutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,30 @@ public function should_keep_a_to_z()
/**
* @test
*/
public function should_keep_capital_a_to_z()
public function should_change_capital_a_to_z_to_lowercase_a_to_z()
{
$slug = Slug::fromName('ABCDEFGHIJKLMNOPQRSTUVWXYZ');

$this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ', (string)$slug);
$this->assertEquals('abcdefghijklmnopqrstuvwxyz', (string)$slug);
}

/**
* @test
*/
public function should_change_anything_not_a_to_z_to_dash()
{
$slug = Slug::fromName('a b');

$this->assertEquals('a-b', (string)$slug);
}

/**
* @test
*/
public function should_reduce_multiple_dashes_to_single_dash()
{
$slug = Slug::fromName('a!@#b');

$this->assertEquals('a-b', (string)$slug);
}
}

0 comments on commit caefc2e

Please sign in to comment.