Skip to content

Commit 1922813

Browse files
committed
Fix turning off logging via Laravel config
1 parent 89065c4 commit 1922813

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/Laravel/Configs/ApiSdkConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function getLoggers(): LoggersMapEntity
2323

2424
public function getLogging(): string
2525
{
26-
return $this->config->getRequiredString([self::KeyLogging, self::KeyLoggingType]);
26+
return $this->config->getString([self::KeyLogging, self::KeyLoggingType]) ?? '';
2727
}
2828

2929
public function isTelescopeEnabled(): bool
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)