mirror of
https://github.com/symfony/ux-map.git
synced 2026-03-23 23:42:07 +01:00
Apply fabbot rules
This commit is contained in:
@@ -56,7 +56,7 @@ Renderer
|
||||
.. tip::
|
||||
|
||||
Read the `Symfony UX Map Leaflet bridge docs`_ and the
|
||||
`Symfony UX Map Google Maps brige docs`_ to learn about the configuration
|
||||
`Symfony UX Map Google Maps bridge docs`_ to learn about the configuration
|
||||
options available for each renderer.
|
||||
|
||||
Create a map
|
||||
@@ -564,7 +564,7 @@ Then, you can use this controller in your template:
|
||||
.. tip::
|
||||
|
||||
Read the `Symfony UX Map Leaflet bridge docs`_ and the
|
||||
`Symfony UX Map Google Maps brige docs`_ to learn about the exact code
|
||||
`Symfony UX Map Google Maps bridge docs`_ to learn about the exact code
|
||||
needed to customize the markers.
|
||||
|
||||
Advanced: Low-level options
|
||||
@@ -852,7 +852,7 @@ https://symfony.com/doc/current/contributing/code/bc.html
|
||||
.. _`the Symfony UX initiative`: https://ux.symfony.com/
|
||||
.. _`Google Maps`: https://github.com/symfony/ux-google-map
|
||||
.. _`Leaflet`: https://github.com/symfony/ux-leaflet-map
|
||||
.. _`Symfony UX Map Google Maps brige docs`: https://github.com/symfony/ux/blob/2.x/src/Map/src/Bridge/Google/README.md
|
||||
.. _`Symfony UX Map Google Maps bridge docs`: https://github.com/symfony/ux/blob/2.x/src/Map/src/Bridge/Google/README.md
|
||||
.. _`Symfony UX Map Leaflet bridge docs`: https://github.com/symfony/ux/blob/2.x/src/Map/src/Bridge/Leaflet/README.md
|
||||
.. _`Twig Component`: https://symfony.com/bundles/ux-twig-component/current/index.html
|
||||
.. _`Live Actions`: https://symfony.com/bundles/ux-live-component/current/index.html#actions
|
||||
|
||||
@@ -21,7 +21,7 @@ use Symfony\UX\Map\Point;
|
||||
|
||||
class DistanceCalculatorTest extends TestCase
|
||||
{
|
||||
public function testCalculateDistanceUseCalculator(): void
|
||||
public function testCalculateDistanceUseCalculator()
|
||||
{
|
||||
$calculator = new class implements DistanceCalculatorInterface {
|
||||
public function calculateDistance(Point $point1, Point $point2): float
|
||||
@@ -41,7 +41,7 @@ class DistanceCalculatorTest extends TestCase
|
||||
*
|
||||
* @dataProvider distanceAccuracyProvider
|
||||
*/
|
||||
public function testAccuracyAgainstVincenty(Point $point1, Point $point2, float $tolerance): void
|
||||
public function testAccuracyAgainstVincenty(Point $point1, Point $point2, float $tolerance)
|
||||
{
|
||||
$vincenty = new VincentyDistanceCalculator();
|
||||
$referenceDistance = $vincenty->calculateDistance($point1, $point2);
|
||||
|
||||
@@ -33,7 +33,7 @@ class DistanceUnitTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideConvertedUnits
|
||||
*/
|
||||
public function testConversionFactorFrom(DistanceUnit $unit, DistanceUnit $otherUnit, float $expected): void
|
||||
public function testConversionFactorFrom(DistanceUnit $unit, DistanceUnit $otherUnit, float $expected)
|
||||
{
|
||||
$this->assertEqualsWithDelta($expected, $unit->getConversionFactorFrom($otherUnit), 0.001);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class IconTest extends TestCase
|
||||
*
|
||||
* @param class-string<Icon> $expectedInstance
|
||||
*/
|
||||
public function testIconConstruction(Icon $icon, string $expectedInstance, array $expectedToArray): void
|
||||
public function testIconConstruction(Icon $icon, string $expectedInstance, array $expectedToArray)
|
||||
{
|
||||
self::assertInstanceOf($expectedInstance, $icon);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class IconTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideIcons
|
||||
*/
|
||||
public function testToArray(Icon $icon, string $expectedInstance, array $expectedToArray): void
|
||||
public function testToArray(Icon $icon, string $expectedInstance, array $expectedToArray)
|
||||
{
|
||||
self::assertSame($expectedToArray, $icon->toArray());
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class IconTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideIcons
|
||||
*/
|
||||
public function testFromArray(Icon $icon, string $expectedInstance, array $expectedToArray): void
|
||||
public function testFromArray(Icon $icon, string $expectedInstance, array $expectedToArray)
|
||||
{
|
||||
self::assertEquals($icon, Icon::fromArray($expectedToArray));
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class IconTest extends TestCase
|
||||
/**
|
||||
* @dataProvider dataProviderForTestSvgIconCustomizationMethodsCanNotBeCalled
|
||||
*/
|
||||
public function testSvgIconCustomizationMethodsCanNotBeCalled(string $method, mixed ...$args): void
|
||||
public function testSvgIconCustomizationMethodsCanNotBeCalled(string $method, mixed ...$args)
|
||||
{
|
||||
$this->expectException(\LogicException::class);
|
||||
if (\in_array($method, ['width', 'height'], true)) {
|
||||
|
||||
@@ -17,7 +17,7 @@ use Symfony\UX\Map\Point;
|
||||
|
||||
class InfoWindowTest extends TestCase
|
||||
{
|
||||
public function testToArray(): void
|
||||
public function testToArray()
|
||||
{
|
||||
$infoWindow = new InfoWindow(
|
||||
headerContent: 'Paris',
|
||||
|
||||
@@ -30,7 +30,7 @@ class MapFactoryTest extends TestCase
|
||||
DummyOptions::unregisterFromNormalizer();
|
||||
}
|
||||
|
||||
public function testFromArray(): void
|
||||
public function testFromArray()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$map = Map::fromArray($array);
|
||||
@@ -62,7 +62,7 @@ class MapFactoryTest extends TestCase
|
||||
$this->assertSame($array['polylines'][0]['infoWindow']['content'], $polylines[0]['infoWindow']['content']);
|
||||
}
|
||||
|
||||
public function testToArrayFromArray(): void
|
||||
public function testToArrayFromArray()
|
||||
{
|
||||
$map = (new Map())
|
||||
->center(new Point(48.8566, 2.3522))
|
||||
@@ -95,7 +95,7 @@ class MapFactoryTest extends TestCase
|
||||
$this->assertEquals($map->toArray(), $newMap->toArray());
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidCenter(): void
|
||||
public function testFromArrayWithInvalidCenter()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['center'] = 'invalid';
|
||||
@@ -104,7 +104,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidZoom(): void
|
||||
public function testFromArrayWithInvalidZoom()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['zoom'] = 'invalid';
|
||||
@@ -113,7 +113,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidMarkers(): void
|
||||
public function testFromArrayWithInvalidMarkers()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['markers'] = 'invalid';
|
||||
@@ -123,7 +123,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidMarker(): void
|
||||
public function testFromArrayWithInvalidMarker()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['markers'] = [
|
||||
@@ -137,7 +137,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidPolygons(): void
|
||||
public function testFromArrayWithInvalidPolygons()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['polygons'] = 'invalid';
|
||||
@@ -147,7 +147,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidPolygon(): void
|
||||
public function testFromArrayWithInvalidPolygon()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['polygons'] = [
|
||||
@@ -161,7 +161,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidPolylines(): void
|
||||
public function testFromArrayWithInvalidPolylines()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['polylines'] = 'invalid';
|
||||
@@ -171,7 +171,7 @@ class MapFactoryTest extends TestCase
|
||||
Map::fromArray($array);
|
||||
}
|
||||
|
||||
public function testFromArrayWithInvalidPolyline(): void
|
||||
public function testFromArrayWithInvalidPolyline()
|
||||
{
|
||||
$array = self::createMapArray();
|
||||
$array['polylines'] = [
|
||||
|
||||
@@ -24,7 +24,7 @@ final class MapOptionsNormalizerTest extends TestCase
|
||||
DummyOptions::unregisterFromNormalizer();
|
||||
}
|
||||
|
||||
public function testDenormalizingWhenProviderKeyIsMissing(): void
|
||||
public function testDenormalizingWhenProviderKeyIsMissing()
|
||||
{
|
||||
$this->expectException(UnableToDenormalizeOptionsException::class);
|
||||
$this->expectExceptionMessage(' the provider key "@provider" is missing in the normalized options.');
|
||||
@@ -32,7 +32,7 @@ final class MapOptionsNormalizerTest extends TestCase
|
||||
MapOptionsNormalizer::denormalize([]);
|
||||
}
|
||||
|
||||
public function testDenormalizingWhenProviderIsNotSupported(): void
|
||||
public function testDenormalizingWhenProviderIsNotSupported()
|
||||
{
|
||||
$this->expectException(UnableToDenormalizeOptionsException::class);
|
||||
$this->expectExceptionMessage(' the provider "foo" is not supported. Supported providers are "google", "leaflet".');
|
||||
@@ -40,7 +40,7 @@ final class MapOptionsNormalizerTest extends TestCase
|
||||
MapOptionsNormalizer::denormalize(['@provider' => 'foo']);
|
||||
}
|
||||
|
||||
public function testDenormalizingAndNormalizing(): void
|
||||
public function testDenormalizingAndNormalizing()
|
||||
{
|
||||
DummyOptions::registerToNormalizer();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MapTest extends TestCase
|
||||
DummyOptions::unregisterFromNormalizer();
|
||||
}
|
||||
|
||||
public function testCenterValidation(): void
|
||||
public function testCenterValidation()
|
||||
{
|
||||
self::expectException(InvalidArgumentException::class);
|
||||
self::expectExceptionMessage('The map "center" must be explicitly set when not enabling "fitBoundsToMarkers" feature.');
|
||||
@@ -43,7 +43,7 @@ class MapTest extends TestCase
|
||||
$map->toArray();
|
||||
}
|
||||
|
||||
public function testZoomValidation(): void
|
||||
public function testZoomValidation()
|
||||
{
|
||||
self::expectException(InvalidArgumentException::class);
|
||||
self::expectExceptionMessage('The map "zoom" must be explicitly set when not enabling "fitBoundsToMarkers" feature.');
|
||||
@@ -54,7 +54,7 @@ class MapTest extends TestCase
|
||||
$map->toArray();
|
||||
}
|
||||
|
||||
public function testZoomAndCenterCanBeOmittedIfFitBoundsToMarkers(): void
|
||||
public function testZoomAndCenterCanBeOmittedIfFitBoundsToMarkers()
|
||||
{
|
||||
$map = new Map(
|
||||
fitBoundsToMarkers: true
|
||||
@@ -78,7 +78,7 @@ class MapTest extends TestCase
|
||||
], $array);
|
||||
}
|
||||
|
||||
public function testWithMinimumConfiguration(): void
|
||||
public function testWithMinimumConfiguration()
|
||||
{
|
||||
$map = new Map();
|
||||
$map
|
||||
@@ -103,7 +103,7 @@ class MapTest extends TestCase
|
||||
], $array);
|
||||
}
|
||||
|
||||
public function testWithMaximumConfiguration(): void
|
||||
public function testWithMaximumConfiguration()
|
||||
{
|
||||
$map = new Map();
|
||||
$map
|
||||
@@ -432,7 +432,7 @@ class MapTest extends TestCase
|
||||
* [null, 5, 2, "The \"zoom\" must be less than or equal to \"maxZoom\"."]
|
||||
* [2.1, null, 2.0, "The \"minZoom\" must be less than or equal to \"maxZoom\"."]
|
||||
*/
|
||||
public function testZoomsValidation(?float $minZoom, ?float $zoom, ?float $maxZoom, string $expectedExceptionMessage): void
|
||||
public function testZoomsValidation(?float $minZoom, ?float $zoom, ?float $maxZoom, string $expectedExceptionMessage)
|
||||
{
|
||||
self::expectException(InvalidArgumentException::class);
|
||||
self::expectExceptionMessage($expectedExceptionMessage);
|
||||
|
||||
@@ -19,7 +19,7 @@ use Symfony\UX\Map\Point;
|
||||
|
||||
class MarkerTest extends TestCase
|
||||
{
|
||||
public function testToArray(): void
|
||||
public function testToArray()
|
||||
{
|
||||
$marker = new Marker(
|
||||
position: new Point(48.8566, 2.3522),
|
||||
|
||||
@@ -28,7 +28,7 @@ class PointTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideInvalidPoint
|
||||
*/
|
||||
public function testInvalidPoint(float $latitude, float $longitude, string $expectedExceptionMessage): void
|
||||
public function testInvalidPoint(float $latitude, float $longitude, string $expectedExceptionMessage)
|
||||
{
|
||||
self::expectException(InvalidArgumentException::class);
|
||||
self::expectExceptionMessage($expectedExceptionMessage);
|
||||
@@ -36,21 +36,21 @@ class PointTest extends TestCase
|
||||
new Point($latitude, $longitude);
|
||||
}
|
||||
|
||||
public function testGetLatitude(): void
|
||||
public function testGetLatitude()
|
||||
{
|
||||
$point = new Point(48.8566, 2.3533);
|
||||
|
||||
self::assertSame(48.8566, $point->getLatitude());
|
||||
}
|
||||
|
||||
public function testGetLongitude(): void
|
||||
public function testGetLongitude()
|
||||
{
|
||||
$point = new Point(48.8566, 2.3533);
|
||||
|
||||
self::assertSame(2.3533, $point->getLongitude());
|
||||
}
|
||||
|
||||
public function testToArray(): void
|
||||
public function testToArray()
|
||||
{
|
||||
$point = new Point(48.8566, 2.3533);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ final class NullRendererTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideTestRenderMap
|
||||
*/
|
||||
public function testRenderMap(string $expectedExceptionMessage, RendererInterface $renderer): void
|
||||
public function testRenderMap(string $expectedExceptionMessage, RendererInterface $renderer)
|
||||
{
|
||||
self::expectException(LogicException::class);
|
||||
self::expectExceptionMessage($expectedExceptionMessage);
|
||||
|
||||
@@ -19,7 +19,7 @@ use Symfony\UX\Map\Renderer\RendererInterface;
|
||||
|
||||
final class RendererTest extends TestCase
|
||||
{
|
||||
public function testUnsupportedSchemeException(): void
|
||||
public function testUnsupportedSchemeException()
|
||||
{
|
||||
self::expectException(UnsupportedSchemeException::class);
|
||||
self::expectExceptionMessage('The renderer "scheme" is not supported.');
|
||||
@@ -28,7 +28,7 @@ final class RendererTest extends TestCase
|
||||
$renderer->fromString('scheme://default');
|
||||
}
|
||||
|
||||
public function testSupportedFactory(): void
|
||||
public function testSupportedFactory()
|
||||
{
|
||||
$renderer = new Renderer([
|
||||
'one' => $oneFactory = self::createMock(RendererFactoryInterface::class),
|
||||
|
||||
@@ -21,7 +21,7 @@ use Symfony\UX\Map\Renderer\Renderers;
|
||||
|
||||
class RenderersTest extends TestCase
|
||||
{
|
||||
public function testConstructWithoutRenderers(): void
|
||||
public function testConstructWithoutRenderers()
|
||||
{
|
||||
self::expectException(LogicException::class);
|
||||
self::expectExceptionMessage('"Symfony\UX\Map\Renderer\Renderers" must have at least one renderer configured.');
|
||||
@@ -29,7 +29,7 @@ class RenderersTest extends TestCase
|
||||
new Renderers([]);
|
||||
}
|
||||
|
||||
public function testRenderMapWithDefaultRenderer(): void
|
||||
public function testRenderMapWithDefaultRenderer()
|
||||
{
|
||||
$defaultRenderer = $this->createMock(RendererInterface::class);
|
||||
$defaultRenderer->expects(self::once())->method('renderMap')->willReturn('<div data-controller="@symfony/ux-default-map"></div>');
|
||||
@@ -39,7 +39,7 @@ class RenderersTest extends TestCase
|
||||
self::assertSame('<div data-controller="@symfony/ux-default-map"></div>', $renderers->renderMap(new Map()));
|
||||
}
|
||||
|
||||
public function testRenderMapWithCustomRenderer(): void
|
||||
public function testRenderMapWithCustomRenderer()
|
||||
{
|
||||
$defaultRenderer = $this->createMock(RendererInterface::class);
|
||||
$defaultRenderer->expects(self::never())->method('renderMap');
|
||||
@@ -54,7 +54,7 @@ class RenderersTest extends TestCase
|
||||
self::assertSame('<div data-controller="@symfony/ux-custom-map"></div>', $renderers->renderMap($map));
|
||||
}
|
||||
|
||||
public function testRenderMapWithUnknownRenderer(): void
|
||||
public function testRenderMapWithUnknownRenderer()
|
||||
{
|
||||
self::expectException(LogicException::class);
|
||||
self::expectExceptionMessage('The "unknown" renderer does not exist (available renderers: "default").');
|
||||
|
||||
@@ -24,7 +24,7 @@ class MapComponentTest extends KernelTestCase
|
||||
return TwigComponentKernel::class;
|
||||
}
|
||||
|
||||
public function testRenderMapComponent(): void
|
||||
public function testRenderMapComponent()
|
||||
{
|
||||
$map = (new Map())
|
||||
->center(new Point(latitude: 5, longitude: 10))
|
||||
|
||||
@@ -30,7 +30,7 @@ class MapExtensionTest extends KernelTestCase
|
||||
return TwigAppKernel::class;
|
||||
}
|
||||
|
||||
public function testExtensionIsRegistered(): void
|
||||
public function testExtensionIsRegistered()
|
||||
{
|
||||
/** @var Environment $twig */
|
||||
$twig = self::getContainer()->get('twig');
|
||||
@@ -39,7 +39,7 @@ class MapExtensionTest extends KernelTestCase
|
||||
$this->assertInstanceOf(MapExtension::class, $twig->getExtension(MapExtension::class));
|
||||
}
|
||||
|
||||
public function testRuntimeIsRegistered(): void
|
||||
public function testRuntimeIsRegistered()
|
||||
{
|
||||
/** @var Environment $twig */
|
||||
$twig = self::getContainer()->get('twig');
|
||||
@@ -47,7 +47,7 @@ class MapExtensionTest extends KernelTestCase
|
||||
$this->assertInstanceOf(MapRuntime::class, $twig->getRuntime(MapRuntime::class));
|
||||
}
|
||||
|
||||
public function testMapFunctionWithArray(): void
|
||||
public function testMapFunctionWithArray()
|
||||
{
|
||||
$map = (new Map())
|
||||
->center(new Point(latitude: 5, longitude: 10))
|
||||
|
||||
@@ -25,7 +25,7 @@ final class TwigTest extends KernelTestCase
|
||||
return TwigAppKernel::class;
|
||||
}
|
||||
|
||||
public function testRenderMap(): void
|
||||
public function testRenderMap()
|
||||
{
|
||||
$map = new Map();
|
||||
$attributes = ['data-foo' => 'bar'];
|
||||
|
||||
@@ -35,7 +35,7 @@ class UXMapBundleTest extends TestCase
|
||||
*
|
||||
* @param class-string<Kernel> $kernelClass
|
||||
*/
|
||||
public function testBootKernel(string $kernelClass): void
|
||||
public function testBootKernel(string $kernelClass)
|
||||
{
|
||||
$kernel = new $kernelClass('test', true);
|
||||
$kernel->boot();
|
||||
@@ -48,7 +48,7 @@ class UXMapBundleTest extends TestCase
|
||||
*
|
||||
* @param class-string<Kernel> $kernelClass
|
||||
*/
|
||||
public function testNullRendererAsDefault(string $kernelClass): void
|
||||
public function testNullRendererAsDefault(string $kernelClass)
|
||||
{
|
||||
$expectedRenderer = new NullRenderer(['symfony/ux-google-map', 'symfony/ux-leaflet-map']);
|
||||
|
||||
|
||||
@@ -15,31 +15,31 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoordinateUtilsTest extends TestCase
|
||||
{
|
||||
public function testDecimalToDMSConvertsCorrectly(): void
|
||||
public function testDecimalToDMSConvertsCorrectly()
|
||||
{
|
||||
$result = CoordinateUtils::decimalToDMS(48.8588443);
|
||||
$this->assertSame([48, 51, 31.83948], $result);
|
||||
}
|
||||
|
||||
public function testDecimalToDMSHandlesNegativeValues(): void
|
||||
public function testDecimalToDMSHandlesNegativeValues()
|
||||
{
|
||||
$result = CoordinateUtils::decimalToDMS(-48.8588443);
|
||||
$this->assertSame([-48, 51, 31.83948], $result);
|
||||
}
|
||||
|
||||
public function testDMSToDecimalConvertsCorrectly(): void
|
||||
public function testDMSToDecimalConvertsCorrectly()
|
||||
{
|
||||
$result = CoordinateUtils::DMSToDecimal(48, 51, 31.8388);
|
||||
$this->assertSame(48.858844, $result);
|
||||
}
|
||||
|
||||
public function testDMSToDecimalHandlesNegativeValues(): void
|
||||
public function testDMSToDecimalHandlesNegativeValues()
|
||||
{
|
||||
$result = CoordinateUtils::DMSToDecimal(-48, 51, 31.8388);
|
||||
$this->assertSame(-48.858844, $result);
|
||||
}
|
||||
|
||||
public function testDMSToDecimalHandlesZeroValues(): void
|
||||
public function testDMSToDecimalHandlesZeroValues()
|
||||
{
|
||||
$result = CoordinateUtils::DMSToDecimal(0, 0, 0.0);
|
||||
$this->assertSame(0.0, $result);
|
||||
|
||||
Reference in New Issue
Block a user