From d8a90f799540971f8a9376c0fb8d20d69c85f9a1 Mon Sep 17 00:00:00 2001 From: madmatt Date: Sat, 24 Oct 2015 01:25:15 +1300 Subject: [PATCH] - Add single test for \eTools\Utils\Slugify::cleanTeamName(), so that once we add Travis, it has something to do --- tests/eTools/Utils/SlugifyTest.php | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/eTools/Utils/SlugifyTest.php diff --git a/tests/eTools/Utils/SlugifyTest.php b/tests/eTools/Utils/SlugifyTest.php new file mode 100644 index 00000000..569703f0 --- /dev/null +++ b/tests/eTools/Utils/SlugifyTest.php @@ -0,0 +1,35 @@ +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('#$%^&*~|\'\\')); + } +} \ No newline at end of file