Skip to content

Commit ac41d8b

Browse files
authored
Merge pull request #14 from codeigniter4/nulls
Helper Nulls
2 parents af1c44b + f83e842 commit ac41d8b

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/Helpers/setting_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function setting(?string $key = null, $value = null)
1717
}
1818

1919
// Getting the value?
20-
if ($value === null) {
20+
if (count(func_get_args()) === 1) {
2121
return $setting->get($key);
2222
}
2323

tests/HelperTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ public function testThrowsExceptionWithInvalidField()
3333
setting('Foobar');
3434
}
3535

36+
public function testSetsNull()
37+
{
38+
setting('Foo.bam', null);
39+
40+
$this->seeInDatabase($this->table, [
41+
'class' => 'Foo',
42+
'key' => 'bam',
43+
'value' => null,
44+
'type' => 'NULL',
45+
]);
46+
47+
$this->assertNull(setting('Foo.bam'));
48+
}
49+
3650
public function testReturnsValueDotArray()
3751
{
3852
$this->hasInDatabase($this->table, [

0 commit comments

Comments
 (0)