Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first PHPUnit test #51

Open
wants to merge 1 commit into
base: threads
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/eTools/Utils/SlugifyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace eTools\Tests\Utils;

class SlugifyTest extends \PHPUnit_Framework_TestCase {
public function testCleanTeamName() {
$slugify = new \eTools\Utils\Slugify();

// Test standard name should be strtolower()'d
$this->assertEquals('madman', $slugify->cleanTeamName('Madman'));

// Brackets should be removed
$this->assertEquals('ipt-madman', $slugify->cleanTeamName('<[{(IPT)}]>Madman'));

// Spaces at the start/end of string should be trimmed
$this->assertEquals('madman', $slugify->cleanTeamName(' madman '));

// Spaces inside the string should be converted to hyphens
$this->assertEquals('m-a-d-m-a-n', $slugify->cleanTeamName(' m a d m a n '));

// Certain accented characters should be transliterated into standard ASCII
$this->assertEquals("aaeeeiu", $slugify->cleanTeamName("àâéèêîù"));

// Certain invalid characters should be removed, replaced with spaces, which are trimmed away to just a hyphen
$this->assertEquals("-", $slugify->cleanTeamName("'-:!?;,`|."));

// If all characters are removed, the name is a single hyphen
$this->assertEquals("-", $slugify->cleanTeamName("[]"));

// If the name is entirely spaces, it is replaced with a single hyphen
$this->assertEquals("-", $slugify->cleanTeamName(' '));

// preg_replace removes any non-ASCII or numeric character with nothing
$this->assertEquals("-", $slugify->cleanTeamName('#$%^&*~|\'\\'));
}
}