2
0

SluggerTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Test\PhpDevCommunity\PaperORM\Common;
  3. use PhpDevCommunity\PaperORM\Parser\DSNParser;
  4. use PhpDevCommunity\PaperORM\Tools\Slugger;
  5. use PhpDevCommunity\UniTester\TestCase;
  6. class SluggerTest extends TestCase
  7. {
  8. protected function setUp(): void
  9. {
  10. // TODO: Implement setUp() method.
  11. }
  12. protected function tearDown(): void
  13. {
  14. // TODO: Implement tearDown() method.
  15. }
  16. protected function execute(): void
  17. {
  18. $slugTests = [
  19. ['input' => ['Hello', 'World'], 'expected' => 'hello-world'],
  20. ['input' => ['Jean', 'Dupont'], 'expected' => 'jean-dupont'],
  21. ['input' => ['PHP', 'ORM', 'Slug'], 'expected' => 'php-orm-slug'],
  22. ['input' => [' Hello ', ' World '], 'expected' => 'hello-world'],
  23. ['input' => [' Multi Space ', ' Test '], 'expected' => 'multi-space-test'],
  24. ['input' => [' Hello ', '', 'World '], 'expected' => 'hello-world'],
  25. ['input' => ['À l\'ombre', 'du cœur'], 'expected' => 'a-l-ombre-du-coeur'],
  26. ['input' => ['Café', 'Crème'], 'expected' => 'cafe-creme'],
  27. ['input' => ['École', 'publique'], 'expected' => 'ecole-publique'],
  28. ['input' => ['Über', 'mensch'], 'expected' => 'uber-mensch'],
  29. ['input' => ['Hello!', 'World?'], 'expected' => 'hello-world'],
  30. ['input' => ['Slug@Email.com'], 'expected' => 'slug-email-com'],
  31. ['input' => ['Dollar$', 'Sign$'], 'expected' => 'dollar-sign'],
  32. ['input' => ['Hash#Tag'], 'expected' => 'hash-tag'],
  33. ['input' => ['C++', 'Language'], 'expected' => 'c-language'],
  34. ['input' => ['Node.js', 'Framework'], 'expected' => 'node-js-framework'],
  35. ['input' => ['100%', 'Working'], 'expected' => '100-working'],
  36. ['input' => ['Hello', null, 'World'], 'expected' => 'hello-world'],
  37. ['input' => ['0', 'Value'], 'expected' => '0-value'],
  38. ['input' => ['False', 'Start'], 'expected' => 'false-start'],
  39. ['input' => ['Hello', 123, 'World'], 'expected' => 'hello-123-world'],
  40. ['input' => ['snake_case_example'], 'expected' => 'snake-case-example'],
  41. ['input' => ['kebab-case-example'], 'expected' => 'kebab-case-example'],
  42. ['input' => ['mix_case_Example'], 'expected' => 'mix-case-example'],
  43. ['input' => ['Hello___World'], 'expected' => 'hello-world'],
  44. ['input' => ['Hello --- World'], 'expected' => 'hello-world'],
  45. ['input' => ['___Hello', 'World___'], 'expected' => 'hello-world'],
  46. ['input' => ['123', '456'], 'expected' => '123-456'],
  47. ['input' => ['Version', '2.0'], 'expected' => 'version-2-0'],
  48. ['input' => ['A+B=C'], 'expected' => 'a-b-c'],
  49. ['input' => ['NULL'], 'expected' => 'null'],
  50. ['input' => ['Éléphant', '', ''], 'expected' => 'elephant'],
  51. ['input' => [null, null, 'Test'], 'expected' => 'test'],
  52. ['input' => ['Long String With Many Spaces'], 'expected' => 'long-string-with-many-spaces'],
  53. ['input' => ['---Leading', 'And', 'Trailing---'], 'expected' => 'leading-and-trailing'],
  54. ['input' => ['This_is_a_very_long_text_with_many_parts'], 'expected' => 'this-is-a-very-long-text-with-many-parts'],
  55. ];
  56. foreach ($slugTests as $test) {
  57. $slug = Slugger::slugify($test['input']);
  58. $this->assertStrictEquals($test['expected'], $slug);
  59. }
  60. }
  61. }