|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Phpsa\LaravelApiController\Tests; |
| 4 | + |
| 5 | +use Illuminate\Http\Request; |
| 6 | +use Orchestra\Testbench\TestCase; |
| 7 | +use Phpsa\LaravelApiController\Helpers; |
| 8 | +use Phpsa\LaravelApiController\UriParser; |
| 9 | +use Phpsa\LaravelApiController\ServiceProvider; |
| 10 | +use Phpsa\LaravelApiController\Facades\LaravelApiController; |
| 11 | + |
| 12 | +class LaravelApiHelpersTest extends TestCase |
| 13 | +{ |
| 14 | + protected function getPackageProviders($app) |
| 15 | + { |
| 16 | + return [ServiceProvider::class]; |
| 17 | + } |
| 18 | + |
| 19 | + protected function getPackageAliases($app) |
| 20 | + { |
| 21 | + return [ |
| 22 | + 'laravel-api-controller' => LaravelApiController::class, |
| 23 | + ]; |
| 24 | + } |
| 25 | + |
| 26 | + public function testSnakeCasing() |
| 27 | + { |
| 28 | + $array = [ |
| 29 | + 'test_one' => 'test_one', |
| 30 | + 'testTwo' => 'test_two' |
| 31 | + ]; |
| 32 | + |
| 33 | + $transposed = Helpers::snakeCaseArrayKeys($array); |
| 34 | + |
| 35 | + $this->assertSame(array_keys($transposed), array_values($array)); |
| 36 | + } |
| 37 | + |
| 38 | + public function testCamelCasing() |
| 39 | + { |
| 40 | + $array = [ |
| 41 | + 'test_one' => 'testOne', |
| 42 | + 'testTwo' => 'testTwo' |
| 43 | + ]; |
| 44 | + |
| 45 | + $transposed = Helpers::camelCaseArrayKeys($array); |
| 46 | + |
| 47 | + $this->assertSame(array_keys($transposed), array_values($array)); |
| 48 | + } |
| 49 | + |
| 50 | + public function testArrayExcludes() |
| 51 | + { |
| 52 | + $data1 = []; |
| 53 | + $data2 = []; |
| 54 | + $this->markTestSkipped('Still to build'); |
| 55 | + } |
| 56 | + |
| 57 | + |
| 58 | + /** |
| 59 | + * camelCaseArrayKeys |
| 60 | +snakeCaseArrayKeys |
| 61 | + public static function snake(string $value): string |
| 62 | +filterFieldsFromRequest |
| 63 | +excludeArrayValues |
| 64 | + */ |
| 65 | +} |
0 commit comments