| @@ 13-61 (lines=49) @@ | ||
| 10 | ||
| 11 | use function spatie\array_keys_camel2snake; |
|
| 12 | ||
| 13 | class ArrayKeysCamel2SnakeTest extends \PHPUnit_Framework_TestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @test |
|
| 17 | */ |
|
| 18 | public function it_return_camel_case(){ |
|
| 19 | $array = [ |
|
| 20 | 'iAmAKey1'=>1, |
|
| 21 | 'iAmAKey2'=>2, |
|
| 22 | 'iAmAKey3'=>3, |
|
| 23 | 'iAmAKey4'=>[ |
|
| 24 | 'iAmAKey41'=>41, |
|
| 25 | 'iAmAKey42'=>42, |
|
| 26 | 'iAmAKey43'=>43, |
|
| 27 | ], |
|
| 28 | 'iAmAKey5'=>[ |
|
| 29 | 'iAmAKey51'=>51, |
|
| 30 | 'iAmAKey52'=>52, |
|
| 31 | 'iAmAKey53'=>53, |
|
| 32 | 'iAmAKey54'=>[ |
|
| 33 | 'iAmAKey541'=>541, |
|
| 34 | 'iAmAKey542'=>542, |
|
| 35 | ], |
|
| 36 | ], |
|
| 37 | ]; |
|
| 38 | ||
| 39 | $arrayReturn = [ |
|
| 40 | 'i_am_a_key1'=>1, |
|
| 41 | 'i_am_a_key2'=>2, |
|
| 42 | 'i_am_a_key3'=>3, |
|
| 43 | 'i_am_a_key4'=>[ |
|
| 44 | 'i_am_a_key41'=>41, |
|
| 45 | 'i_am_a_key42'=>42, |
|
| 46 | 'i_am_a_key43'=>43, |
|
| 47 | ], |
|
| 48 | 'i_am_a_key5'=>[ |
|
| 49 | 'i_am_a_key51'=>51, |
|
| 50 | 'i_am_a_key52'=>52, |
|
| 51 | 'i_am_a_key53'=>53, |
|
| 52 | 'i_am_a_key54'=>[ |
|
| 53 | 'i_am_a_key541'=>541, |
|
| 54 | 'i_am_a_key542'=>542, |
|
| 55 | ], |
|
| 56 | ], |
|
| 57 | ]; |
|
| 58 | ||
| 59 | $this->assertEquals($arrayReturn, array_keys_camel2snake($array)); |
|
| 60 | } |
|
| 61 | } |
|
| @@ 13-62 (lines=50) @@ | ||
| 10 | ||
| 11 | use function spatie\array_keys_snake2camel; |
|
| 12 | ||
| 13 | class ArrayKeysSnake2CamelTest extends \PHPUnit_Framework_TestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @test |
|
| 17 | */ |
|
| 18 | public function it_return_camel_case(){ |
|
| 19 | ||
| 20 | $array = [ |
|
| 21 | 'i_am_a_key1'=>1, |
|
| 22 | 'i_am_a_key2'=>2, |
|
| 23 | 'i_am_a_key3'=>3, |
|
| 24 | 'i_am_a_key4'=>[ |
|
| 25 | 'i_am_a_key41'=>41, |
|
| 26 | 'i_am_a_key42'=>42, |
|
| 27 | 'i_am_a_key43'=>43, |
|
| 28 | ], |
|
| 29 | 'i_am_a_key5'=>[ |
|
| 30 | 'i_am_a_key51'=>51, |
|
| 31 | 'i_am_a_key52'=>52, |
|
| 32 | 'i_am_a_key53'=>53, |
|
| 33 | 'i_am_a_key54'=>[ |
|
| 34 | 'i_am_a_key541'=>541, |
|
| 35 | 'i_am_a_key542'=>542, |
|
| 36 | ], |
|
| 37 | ], |
|
| 38 | ]; |
|
| 39 | ||
| 40 | $arrayReturn = [ |
|
| 41 | 'iAmAKey1'=>1, |
|
| 42 | 'iAmAKey2'=>2, |
|
| 43 | 'iAmAKey3'=>3, |
|
| 44 | 'iAmAKey4'=>[ |
|
| 45 | 'iAmAKey41'=>41, |
|
| 46 | 'iAmAKey42'=>42, |
|
| 47 | 'iAmAKey43'=>43, |
|
| 48 | ], |
|
| 49 | 'iAmAKey5'=>[ |
|
| 50 | 'iAmAKey51'=>51, |
|
| 51 | 'iAmAKey52'=>52, |
|
| 52 | 'iAmAKey53'=>53, |
|
| 53 | 'iAmAKey54'=>[ |
|
| 54 | 'iAmAKey541'=>541, |
|
| 55 | 'iAmAKey542'=>542, |
|
| 56 | ], |
|
| 57 | ], |
|
| 58 | ]; |
|
| 59 | ||
| 60 | $this->assertEquals($arrayReturn, array_keys_snake2camel($array)); |
|
| 61 | } |
|
| 62 | } |
|