HelperTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace League\CLImate\Tests;
  3. use League\CLImate\Util\Helper;
  4. class HelperTest extends TestBase
  5. {
  6. /** @test */
  7. public function it_can_convert_a_string_to_an_array()
  8. {
  9. $result = Helper::toArray('string');
  10. $this->assertSame(['string'], $result);
  11. }
  12. /** @test */
  13. public function it_will_leave_an_array_alone_when_trying_to_convert()
  14. {
  15. $result = Helper::toArray(['string']);
  16. $this->assertSame(['string'], $result);
  17. }
  18. /** @test */
  19. public function it_can_flatten_an_array()
  20. {
  21. $arr = [
  22. [
  23. 'this',
  24. 'that'
  25. ],
  26. [
  27. 'other',
  28. 'thing',
  29. ],
  30. ];
  31. $result = Helper::flatten($arr);
  32. $this->assertSame(['this', 'that', 'other', 'thing'], $result);
  33. }
  34. /** @test */
  35. public function it_can_convert_a_string_to_snake_case()
  36. {
  37. $result = Helper::snakeCase('redYellowBlue');
  38. $this->assertSame('red_yellow_blue', $result);
  39. }
  40. }