Skip to content

Commit 7a210c6

Browse files
committed
Add test
1 parent 744e0e6 commit 7a210c6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Dto/StimulusControllersDto.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\WebpackEncoreBundle\Dto;
1313

14+
use Twig\Markup;
15+
1416
final class StimulusControllersDto extends AbstractStimulusDto
1517
{
1618
private $controllers = [];
@@ -59,7 +61,7 @@ public function __toString(): string
5961
}
6062

6163
return rtrim(
62-
'data-controller="'.implode(' ', $this->controllers).'"'.
64+
'data-controller="'.implode(' ', $this->controllers).'" '.
6365
implode(' ', array_map(function (string $attribute, string $value): string {
6466
return $attribute.'="'.$this->escapeAsHtmlAttr($value).'"';
6567
}, array_keys($this->values), $this->values)).' '.

tests/Dto/StimulusControllersDtoTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,20 @@ public function testToArrayNoEscapingAttributeValues(): void
5151
$attributesArray
5252
);
5353
}
54+
55+
public function testAddOutlet(): void
56+
{
57+
$this->stimulusControllersDto->addController('foo', ['bar' => '"'], ['baz' => '"']);
58+
$this->stimulusControllersDto->addOutlet('outlet-name', '"');
59+
$attributesArray = $this->stimulusControllersDto->toArray();
60+
self::assertSame(
61+
[
62+
'data-controller' => 'foo',
63+
'data-foo-bar-value' => '"',
64+
'data-foo-baz-class' => '"',
65+
'data-foo-outlet-name-outlet' => '"',
66+
],
67+
$attributesArray
68+
);
69+
}
5470
}

0 commit comments

Comments
 (0)