@@ -2289,7 +2289,7 @@ public function testSpatialDistanceInMeterForMultiDimensionGeometry(): void
22892289 }
22902290 }
22912291
2292- public function testSpatialDistanceInMeterError ()
2292+ public function testSpatialDistanceInMeterError (): void
22932293 {
22942294 /** @var Database $database */
22952295 $ database = static ::getDatabase ();
@@ -2316,37 +2316,33 @@ public function testSpatialDistanceInMeterError()
23162316 ]));
23172317 $ this ->assertInstanceOf (Document::class, $ doc );
23182318
2319- // Invalid geometry pairs (all combinations except POINT vs POINT)
2319+ // Invalid geometry pairs
23202320 $ cases = [
2321- // Point compared against wrong types
2322- ['attr ' => 'line ' , 'geom ' => [0.002 , 0.0 ], 'msg ' => 'Point vs LineString ' ],
2323- ['attr ' => 'poly ' , 'geom ' => [0.002 , 0.0 ], 'msg ' => 'Point vs Polygon ' ],
2324-
2325- // LineString compared against wrong types
2326- ['attr ' => 'loc ' , 'geom ' => [[0.0 , 0.0 ], [0.001 , 0.001 ]], 'msg ' => 'LineString vs Point ' ],
2327- ['attr ' => 'poly ' , 'geom ' => [[0.0 , 0.0 ], [0.001 , 0.001 ]], 'msg ' => 'LineString vs Polygon ' ],
2328-
2329- // Polygon compared against wrong types
2330- ['attr ' => 'loc ' , 'geom ' => [[[0.0 , 0.0 ], [0.001 , 0.0 ], [0.001 , 0.001 ], [0.0 , 0.0 ]]], 'msg ' => 'Polygon vs Point ' ],
2331- ['attr ' => 'line ' , 'geom ' => [[[0.0 , 0.0 ], [0.001 , 0.0 ], [0.001 , 0.001 ], [0.0 , 0.0 ]]], 'msg ' => 'Polygon vs LineString ' ],
2332-
2333- // Polygon vs Polygon (still invalid for "meters")
2334- ['attr ' => 'poly ' , 'geom ' => [[[0.002 , -0.001 ], [0.002 , 0.001 ], [0.004 , 0.001 ], [0.002 , -0.001 ]]], 'msg ' => 'Polygon vs Polygon ' ],
2335-
2336- // LineString vs LineString (invalid for "meters")
2337- ['attr ' => 'line ' , 'geom ' => [[0.002 , 0.0 ], [0.003 , 0.0 ]], 'msg ' => 'LineString vs LineString ' ],
2321+ ['attr ' => 'line ' , 'geom ' => [0.002 , 0.0 ], 'expected ' => ['linestring ' , 'point ' ]],
2322+ ['attr ' => 'poly ' , 'geom ' => [0.002 , 0.0 ], 'expected ' => ['polygon ' , 'point ' ]],
2323+ ['attr ' => 'loc ' , 'geom ' => [[0.0 , 0.0 ], [0.001 , 0.001 ]], 'expected ' => ['point ' , 'linestring ' ]],
2324+ ['attr ' => 'poly ' , 'geom ' => [[0.0 , 0.0 ], [0.001 , 0.001 ]], 'expected ' => ['polygon ' , 'linestring ' ]],
2325+ ['attr ' => 'loc ' , 'geom ' => [[[0.0 , 0.0 ], [0.001 , 0.0 ], [0.001 , 0.001 ], [0.0 , 0.0 ]]], 'expected ' => ['point ' , 'polygon ' ]],
2326+ ['attr ' => 'line ' , 'geom ' => [[[0.0 , 0.0 ], [0.001 , 0.0 ], [0.001 , 0.001 ], [0.0 , 0.0 ]]], 'expected ' => ['linestring ' , 'polygon ' ]],
2327+ ['attr ' => 'poly ' , 'geom ' => [[[0.002 , -0.001 ], [0.002 , 0.001 ], [0.004 , 0.001 ], [0.002 , -0.001 ]]], 'expected ' => ['polygon ' , 'polygon ' ]],
2328+ ['attr ' => 'line ' , 'geom ' => [[0.002 , 0.0 ], [0.003 , 0.0 ]], 'expected ' => ['linestring ' , 'linestring ' ]],
23382329 ];
23392330
23402331 foreach ($ cases as $ case ) {
23412332 try {
23422333 $ database ->find ($ collection , [
23432334 Query::distanceLessThan ($ case ['attr ' ], $ case ['geom ' ], 1000 , true )
23442335 ]);
2345- $ this ->fail ('Expected Exception not thrown for ' . $ case ['msg ' ] );
2336+ $ this ->fail ('Expected Exception not thrown for ' . implode ( ' vs ' , $ case ['expected ' ]) );
23462337 } catch (\Exception $ e ) {
2347- $ this ->assertInstanceOf (\Exception::class, $ e , $ case ['msg ' ]);
2338+ $ this ->assertInstanceOf (\Exception::class, $ e );
2339+
2340+ // Validate exception message contains correct type names
2341+ $ msg = strtolower ($ e ->getMessage ());
2342+ var_dump ($ msg );
2343+ $ this ->assertStringContainsString ($ case ['expected ' ][0 ], $ msg , 'Attr type missing in exception ' );
2344+ $ this ->assertStringContainsString ($ case ['expected ' ][1 ], $ msg , 'Geom type missing in exception ' );
23482345 }
23492346 }
23502347 }
2351-
23522348}
0 commit comments