HelperTest.php 1.1 KB

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