StrTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Yansongda\Supports\Tests;
  3. use PHPUnit\Framework\TestCase;
  4. use Yansongda\Supports\Str;
  5. class StrTest extends TestCase
  6. {
  7. public function testCamel()
  8. {
  9. self::assertSame('helloWorld', Str::camel('HelloWorld'));
  10. self::assertSame('helloWorld', Str::camel('hello_world'));
  11. self::assertSame('helloWorld', Str::camel('hello-world'));
  12. self::assertSame('helloWorld', Str::camel('hello world'));
  13. }
  14. public function testSnake()
  15. {
  16. self::assertSame('hello_world', Str::snake('HelloWorld'));
  17. self::assertSame('hello_world', Str::snake('hello_world'));
  18. self::assertSame('hello_world', Str::snake('hello world'));
  19. }
  20. public function testStudly()
  21. {
  22. self::assertSame('HelloWorld', Str::studly('helloWorld'));
  23. self::assertSame('HelloWorld', Str::studly('hello_world'));
  24. self::assertSame('HelloWorld', Str::studly('hello-world'));
  25. self::assertSame('HelloWorld', Str::studly('hello world'));
  26. self::assertSame('Hello-World', Str::studly('hello world', '-'));
  27. }
  28. }