Skip to content

Commit 0f3dc27

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

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/Map/src/Bridge/Google/composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"require-dev": {
2424
"symfony/phpunit-bridge": "^6.4|^7.0",
25-
"symfony/ux-icons": "^2.18"
25+
"symfony/ux-icons": "^2.18",
26+
"spatie/phpunit-snapshot-assertions": "^5.1.8"
2627
},
2728
"autoload": {
2829
"psr-4": { "Symfony\\UX\\Map\\Bridge\\Google\\": "src/" },

src/Map/src/Bridge/Leaflet/composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"require-dev": {
2424
"symfony/phpunit-bridge": "^6.4|^7.0",
25-
"symfony/ux-icons": "^2.18"
25+
"symfony/ux-icons": "^2.18",
26+
"spatie/phpunit-snapshot-assertions": "^5.1.8"
2627
},
2728
"autoload": {
2829
"psr-4": { "Symfony\\UX\\Map\\Bridge\\Leaflet\\": "src/" },

src/Map/src/Test/RendererTestCase.php

+4-1
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)