16
16
use Symfony \UX \Map \Map ;
17
17
use Symfony \UX \Map \Marker ;
18
18
use Symfony \UX \Map \Point ;
19
+ use Symfony \UX \Map \Polygon ;
19
20
use Symfony \UX \Map \Test \RendererTestCase ;
20
21
use Symfony \UX \StimulusBundle \Helper \StimulusHelper ;
21
22
@@ -28,24 +29,32 @@ public function provideTestRenderMap(): iterable
28
29
->zoom (12 );
29
30
30
31
yield 'simple map ' => [
31
- 'expected_render ' => '<div data-controller="symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":{}}}" data-symfony--ux-leaflet-map--map-markers-value="[]" data-symfony--ux-leaflet-map--map-polygons-value="[]"></div> ' ,
32
+ 'expected_render ' => '<div data-controller="symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":[]},"@provider":"leaflet"}" data-symfony--ux-leaflet-map--map-markers-value="[]" data-symfony--ux-leaflet-map--map-polygons-value="[]"></div> ' ,
32
33
'renderer ' => new LeafletRenderer (new StimulusHelper (null )),
33
34
'map ' => $ map ,
34
35
];
35
36
36
37
yield 'with custom attributes ' => [
37
- 'expected_render ' => '<div data-controller="my-custom-controller symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":{}}}" data-symfony--ux-leaflet-map--map-markers-value="[]" data-symfony--ux-leaflet-map--map-polygons-value="[]" class="map"></div> ' ,
38
+ 'expected_render ' => '<div data-controller="my-custom-controller symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":[]},"@provider":"leaflet"}" data-symfony--ux-leaflet-map--map-markers-value="[]" data-symfony--ux-leaflet-map--map-polygons-value="[]" class="map"></div> ' ,
38
39
'renderer ' => new LeafletRenderer (new StimulusHelper (null )),
39
40
'map ' => $ map ,
40
41
'attributes ' => ['data-controller ' => 'my-custom-controller ' , 'class ' => 'map ' ],
41
42
];
42
43
43
44
yield 'with markers and infoWindows ' => [
44
- 'expected_render ' => '<div data-controller="symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":{}}}" data-symfony--ux-leaflet-map--map-markers-value="[{"position":{"lat":48.8566,"lng":2.3522},"title":"Paris","infoWindow":null,"extra":{}},{"position":{"lat":48.8566,"lng":2.3522},"title":"Lyon","infoWindow":{"headerContent":null,"content":"Lyon","position":null,"opened":false,"autoClose":true,"extra":{}},"extra":{}}]" data-symfony--ux-leaflet-map--map-polygons-value="[]"></div> ' ,
45
+ 'expected_render ' => '<div data-controller="symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":[]},"@provider":"leaflet"}" data-symfony--ux-leaflet-map--map-markers-value="[{"position":{"lat":48.8566,"lng":2.3522},"title":"Paris","infoWindow":null,"extra":[],"@id":"abd45a2c703af97a"},{"position":{"lat":48.8566,"lng":2.3522},"title":"Lyon","infoWindow":{"headerContent":null,"content":"Lyon","position":null,"opened":false,"autoClose":true,"extra":[]},"extra":[],"@id":"219637cbd8e62ea6"}]" data-symfony--ux-leaflet-map--map-polygons-value="[]"></div> ' ,
45
46
'renderer ' => new LeafletRenderer (new StimulusHelper (null )),
46
47
'map ' => (clone $ map )
47
48
->addMarker (new Marker (new Point (48.8566 , 2.3522 ), 'Paris ' ))
48
49
->addMarker (new Marker (new Point (48.8566 , 2.3522 ), 'Lyon ' , infoWindow: new InfoWindow (content: 'Lyon ' ))),
49
50
];
51
+
52
+ yield 'with polygons and infoWindows ' => [
53
+ 'expected_render ' => '<div data-controller="symfony--ux-leaflet-map--map" data-symfony--ux-leaflet-map--map-provider-options-value="{}" data-symfony--ux-leaflet-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-leaflet-map--map-zoom-value="12" data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-leaflet-map--map-options-value="{"tileLayer":{"url":"https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png","attribution":"\u00a9 <a href=\"https:\/\/www.openstreetmap.org\/copyright\">OpenStreetMap<\/a>","options":[]},"@provider":"leaflet"}" data-symfony--ux-leaflet-map--map-markers-value="[]" data-symfony--ux-leaflet-map--map-polygons-value="[{"points":[{"lat":48.8566,"lng":2.3522},{"lat":48.8566,"lng":2.3522},{"lat":48.8566,"lng":2.3522}],"title":null,"infoWindow":null,"extra":[],"@id":"2dc7aa290e8fc88a"},{"points":[{"lat":1.1,"lng":2.2},{"lat":3.3,"lng":4.4},{"lat":5.5,"lng":6.6}],"title":null,"infoWindow":{"headerContent":null,"content":"Polygon","position":null,"opened":false,"autoClose":true,"extra":[]},"extra":[],"@id":"d6cab193e60e5faf"}]"></div> ' ,
54
+ 'renderer ' => new LeafletRenderer (new StimulusHelper (null )),
55
+ 'map ' => (clone $ map )
56
+ ->addPolygon (new Polygon (points: [new Point (48.8566 , 2.3522 ), new Point (48.8566 , 2.3522 ), new Point (48.8566 , 2.3522 )]))
57
+ ->addPolygon (new Polygon (points: [new Point (1.1 , 2.2 ), new Point (3.3 , 4.4 ), new Point (5.5 , 6.6 )], infoWindow: new InfoWindow (content: 'Polygon ' ))),
58
+ ];
50
59
}
51
60
}
0 commit comments