Skip to content

Commit 61bc44d

Browse files
committed
[Map] Make renderer tests way easier to maintain
1 parent ab44abf commit 61bc44d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Map/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"symfony/phpunit-bridge": "^6.4|^7.0",
4242
"symfony/twig-bundle": "^6.4|^7.0",
4343
"symfony/ux-twig-component": "^2.18",
44-
"symfony/ux-icons": "^2.18"
44+
"symfony/ux-icons": "^2.18",
45+
"spatie/phpunit-snapshot-assertions": "^5.1.8"
4546
},
4647
"conflict": {
4748
"symfony/ux-twig-component": "<2.21"

src/Map/src/Test/RendererTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\Map\Test;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Spatie\Snapshots\MatchesSnapshots;
1516
use Symfony\UX\Map\Map;
1617
use Symfony\UX\Map\Renderer\RendererInterface;
1718

@@ -20,6 +21,8 @@
2021
*/
2122
abstract class RendererTestCase extends TestCase
2223
{
24+
use MatchesSnapshots;
25+
2326
/**
2427
* @return iterable<array{expected_render: string, renderer: RendererInterface, map: Map, attributes: array<mixed>}>
2528
*/
@@ -30,6 +33,6 @@ abstract public function provideTestRenderMap(): iterable;
3033
*/
3134
public function testRenderMap(string $expectedRender, RendererInterface $renderer, Map $map, array $attributes = []): void
3235
{
33-
self::assertSame($expectedRender, $renderer->renderMap($map, $attributes));
36+
$this->assertMatchesSnapshot($renderer->renderMap($map, $attributes));
3437
}
3538
}

0 commit comments

Comments
 (0)