|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace WrkFlow\ApiSdkBuilderTests\Laravel\Configs; |
| 6 | + |
| 7 | +use Closure; |
| 8 | +use Illuminate\Config\Repository; |
| 9 | +use WrkFlow\ApiSdkBuilder\Laravel\Configs\ApiSdkConfig; |
| 10 | +use WrkFlow\ApiSdkBuilderTests\Laravel\TestCase; |
| 11 | +use Wrkflow\GetValue\GetValueFactory; |
| 12 | + |
| 13 | +class ApiSdkConfigLoggingTest extends TestCase |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @return array<string|int, array{0: Closure(static):void}> |
| 17 | + */ |
| 18 | + public function data(): array |
| 19 | + { |
| 20 | + return [ |
| 21 | + 'non empty string' => [ |
| 22 | + static fn (self $self) => $self->assertConfig(set: 'info', expected: 'info'), |
| 23 | + ], |
| 24 | + 'empty string' => [ |
| 25 | + static fn (self $self) => $self->assertConfig(set: '', expected: ''), |
| 26 | + ], |
| 27 | + 'null' => [ |
| 28 | + static fn (self $self) => $self->assertConfig(set: null, expected: ''), |
| 29 | + ], |
| 30 | + ]; |
| 31 | + } |
| 32 | + |
| 33 | + |
| 34 | + /** |
| 35 | + * @param Closure(static):void $assert |
| 36 | + * |
| 37 | + * @dataProvider data |
| 38 | + */ |
| 39 | + public function test(Closure $assert): void |
| 40 | + { |
| 41 | + $assert($this); |
| 42 | + } |
| 43 | + |
| 44 | + private function assertConfig(?string $set, string $expected): void |
| 45 | + { |
| 46 | + $config = new ApiSdkConfig( |
| 47 | + config: new Repository([ |
| 48 | + 'api_sdk' => [ |
| 49 | + ApiSdkConfig::KeyLogging => [ |
| 50 | + ApiSdkConfig::KeyLoggingType => $set, |
| 51 | + ], |
| 52 | + ], |
| 53 | + ]), |
| 54 | + getValueFactory: new GetValueFactory() |
| 55 | + ); |
| 56 | + $this->assertEquals($config->getLogging(), $expected); |
| 57 | + } |
| 58 | +} |
0 commit comments