Skip to content

Commit 571b05b

Browse files
committed
test: add test for set_checkbox()
1 parent 84c28a9 commit 571b05b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/system/Helpers/FormHelperTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,29 @@ public function testSetCheckboxWithValueZero(): void
867867
$this->assertSame(' checked="checked"', set_checkbox('foo', '0', true));
868868
}
869869

870+
/**
871+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/7814
872+
*/
873+
public function testSetCheckboxWithUnchecked(): void
874+
{
875+
$_SESSION = [
876+
'_ci_old_input' => [
877+
'post' => [
878+
],
879+
],
880+
];
881+
882+
$this->assertSame(
883+
'',
884+
set_checkbox('fruit', 'apple', true)
885+
);
886+
887+
$this->assertSame(
888+
'',
889+
set_checkbox('fruit', 'apple')
890+
);
891+
}
892+
870893
/**
871894
* @runInSeparateProcess
872895
* @preserveGlobalState disabled

0 commit comments

Comments
 (0)