@@ -304,4 +304,127 @@ public function testCheckAndMoveExpectLossOfEmptyShipIfNotFixed(): void
304304
305305 $ this ->subject ->checkAndMove ($ wrapper , $ flightRoute );
306306 }
307+
308+ public function testCheckAndMoveExpectNoAlertCheckIfDestroyedOnEntrance (): void
309+ {
310+ $ ship = $ this ->mock (ShipInterface::class);
311+ $ wrapper = $ this ->mock (ShipWrapperInterface::class);
312+ $ flightRoute = $ this ->mock (FlightRouteInterface::class);
313+ $ map = $ this ->mock (MapInterface::class);
314+ $ conditionCheckResult = $ this ->mock (ConditionCheckResult::class);
315+ $ messageCollection = $ this ->mock (MessageCollectionInterface::class);
316+ $ emptyMessage = $ this ->mock (MessageInterface::class);
317+
318+ $ shipId = 12345 ;
319+
320+ $ ship ->shouldReceive ('getId ' )
321+ ->withNoArgs ()
322+ ->once ()
323+ ->andReturn ($ shipId );
324+ $ ship ->shouldReceive ('getName ' )
325+ ->withNoArgs ()
326+ ->once ()
327+ ->andReturn ("SHIP " );
328+ $ ship ->shouldReceive ('isFleetLeader ' )
329+ ->withNoArgs ()
330+ ->once ()
331+ ->andReturn (false );
332+ $ ship ->shouldReceive ('getTractoredShip ' )
333+ ->withNoArgs ()
334+ ->andReturn (null );
335+ $ ship ->shouldReceive ('isDestroyed ' )
336+ ->withNoArgs ()
337+ ->times (5 )
338+ ->andReturn (false , true , true , true , true );
339+ $ ship ->shouldReceive ('getLocation ' )
340+ ->withNoArgs ()
341+ ->once ()
342+ ->andReturn ($ map );
343+
344+ $ map ->shouldReceive ('getAnomalies ' )
345+ ->withNoArgs ()
346+ ->once ()
347+ ->andReturn (new ArrayCollection ());
348+ $ map ->shouldReceive ('getBuoys ' )
349+ ->withNoArgs ()
350+ ->once ()
351+ ->andReturn (new ArrayCollection ());
352+
353+ $ wrapper ->shouldReceive ('get ' )
354+ ->withNoArgs ()
355+ ->andReturn ($ ship );
356+ $ wrapper ->shouldReceive ('getFleetWrapper ' )
357+ ->withNoArgs ()
358+ ->andReturn (null );
359+ $ wrapper ->shouldReceive ('getTractoredShipWrapper ' )
360+ ->withNoArgs ()
361+ ->once ()
362+ ->andReturn (null );
363+
364+ $ map ->shouldReceive ('getFieldType->getPassable ' )
365+ ->withNoArgs ()
366+ ->once ()
367+ ->andReturn (true );
368+
369+ $ flightRoute ->shouldReceive ('isDestinationArrived ' )
370+ ->withNoArgs ()
371+ ->times (2 )
372+ ->andReturn (false , true );
373+ $ flightRoute ->shouldReceive ('getNextWaypoint ' )
374+ ->withNoArgs ()
375+ ->once ()
376+ ->andReturn ($ map );
377+ $ flightRoute ->shouldReceive ('enterNextWaypoint ' )
378+ ->with (
379+ Mockery::on (fn (ArrayCollection $ coll ) => $ coll ->toArray () === [$ shipId => $ wrapper ]),
380+ $ messageCollection
381+ )
382+ ->once ();
383+ $ flightRoute ->shouldReceive ('getRouteMode ' )
384+ ->withNoArgs ()
385+ ->once ()
386+ ->andReturn (RouteModeEnum::FLIGHT );
387+ $ flightRoute ->shouldReceive ('abortFlight ' )
388+ ->withNoArgs ()
389+ ->once ();
390+
391+ $ conditionCheckResult ->shouldReceive ('isFlightPossible ' )
392+ ->withNoArgs ()
393+ ->once ()
394+ ->andReturn (true );
395+ $ conditionCheckResult ->shouldReceive ('getBlockedIds ' )
396+ ->withNoArgs ()
397+ ->once ()
398+ ->andReturn ([]);
399+ $ conditionCheckResult ->shouldReceive ('getInformations ' )
400+ ->withNoArgs ()
401+ ->once ()
402+ ->andReturn ([]);
403+
404+ $ this ->preFlightConditionsCheck ->shouldReceive ('checkPreconditions ' )
405+ ->with ($ wrapper , [$ shipId => $ wrapper ], $ flightRoute , false )
406+ ->once ()
407+ ->andReturn ($ conditionCheckResult );
408+
409+ $ this ->messageFactory ->shouldReceive ('createMessageCollection ' )
410+ ->withNoArgs ()
411+ ->once ()
412+ ->andReturn ($ messageCollection );
413+ $ messageCollection ->shouldReceive ('add ' )
414+ ->with ($ emptyMessage )
415+ ->once ();
416+ $ messageCollection ->shouldReceive ('addInformation ' )
417+ ->with ('Es wurden alle Schiffe zerstört ' )
418+ ->once ();
419+ $ this ->messageFactory ->shouldReceive ('createMessage ' )
420+ ->with (UserEnum::USER_NOONE , null , [])
421+ ->once ()
422+ ->andReturn ($ emptyMessage );
423+
424+ $ this ->shipMovementInformationAdder ->shouldReceive ('reachedDestinationDestroyed ' )
425+ ->with ($ ship , 'SHIP ' , false , RouteModeEnum::FLIGHT , $ messageCollection )
426+ ->once ();
427+
428+ $ this ->subject ->checkAndMove ($ wrapper , $ flightRoute );
429+ }
307430}
0 commit comments