Skip to content

Commit cc467a7

Browse files
FrankiFixxsamdarkvjik
authored
Fix #223: Make $content optional in Button factories (#238)
Co-authored-by: Alexander Makarov <sam@rmcreative.ru> Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
1 parent 2006c3e commit cc467a7

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 3.9.1 under development
44

55
- Bug #232: Render `loading` attribute before `src` (@samdark)
6+
- Enh #223: Make `$content` parameter optional in `Button` factories (@FrankiFixx)
67

78
## 3.9.0 November 29, 2024
89

src/Tag/Button.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ final class Button extends NormalTag
1414
{
1515
use TagContentTrait;
1616

17-
public static function button(string $content): self
17+
public static function button(string $content = ''): self
1818
{
1919
$button = self::tag()->content($content);
2020
$button->attributes['type'] = 'button';
2121
return $button;
2222
}
2323

24-
public static function submit(string $content): self
24+
public static function submit(string $content = ''): self
2525
{
2626
$button = self::tag()->content($content);
2727
$button->attributes['type'] = 'submit';
2828
return $button;
2929
}
3030

31-
public static function reset(string $content): self
31+
public static function reset(string $content = ''): self
3232
{
3333
$button = self::tag()->content($content);
3434
$button->attributes['type'] = 'reset';

tests/Tag/ButtonTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ public function testButton(): void
2828
);
2929
}
3030

31+
public function testButtonWithoutContent(): void
32+
{
33+
$this->assertSame(
34+
'<button type="button"></button>',
35+
(string)Button::button()
36+
);
37+
}
38+
39+
public function testSubmitWithoutContent(): void
40+
{
41+
$this->assertSame(
42+
'<button type="submit"></button>',
43+
(string)Button::submit()
44+
);
45+
}
46+
47+
public function testResetWithoutContent(): void
48+
{
49+
$this->assertSame(
50+
'<button type="reset"></button>',
51+
(string)Button::reset()
52+
);
53+
}
54+
3155
public function testSubmit(): void
3256
{
3357
$this->assertSame(

0 commit comments

Comments
 (0)