Skip to content

Commit e71456e

Browse files
committed
Add test
1 parent 76fa730 commit e71456e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/Dto/StimulusOutletsDtoTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony WebpackEncoreBundle package.
5+
* (c) Fabien Potencier <[email protected]>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
namespace Symfony\WebpackEncoreBundle\Tests\Dto;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use Symfony\WebpackEncoreBundle\Dto\StimulusOutletsDto;
14+
use Twig\Environment;
15+
use Twig\Loader\ArrayLoader;
16+
17+
class StimulusOutletsDtoTest extends TestCase
18+
{
19+
/**
20+
* @var StimulusOutletsDto
21+
*/
22+
private $stimulusOutletsDto;
23+
24+
protected function setUp(): void
25+
{
26+
$this->stimulusOutletsDto = new StimulusOutletsDto(new Environment(new ArrayLoader()));
27+
}
28+
29+
public function testToStringEscapingAttributeValues(): void
30+
{
31+
$this->stimulusOutletsDto->addOutlet('foo', 'bar', '"');
32+
$attributesHtml = (string) $this->stimulusOutletsDto;
33+
self::assertSame('data-foo-bar-outlet="&quot;"', $attributesHtml);
34+
}
35+
36+
public function testToArrayNoEscapingAttributeValues(): void
37+
{
38+
$this->stimulusOutletsDto->addOutlet('foo', 'bar', '"');
39+
$attributesArray = $this->stimulusOutletsDto->toArray();
40+
self::assertSame(['data-foo-bar-outlet' => '"'], $attributesArray);
41+
}
42+
}

0 commit comments

Comments
 (0)