mivita/tests/Unit/Dhl/TrackShipmentJobTest.php

35 lines
961 B
PHP

<?php
use Acme\Dhl\Models\DhlShipment;
use App\Jobs\TrackShipmentJob;
use App\Services\DhlTrackingService;
use Mockery\MockInterface;
afterEach(function () {
Mockery::close();
});
it('uses the current DHL tracking service for queued tracking updates', function () {
$shipment = new DhlShipment([
'id' => 123,
'dhl_shipment_no' => '00340434161094000001',
'status' => 'created',
]);
$options = ['auto_retrack' => false];
$job = new TrackShipmentJob($shipment, $options);
/** @var DhlTrackingService&MockInterface $trackingService */
$trackingService = Mockery::mock(DhlTrackingService::class);
$trackingService
->shouldReceive('updateTrackingNow')
->once()
->with($shipment, $options)
->andReturn([
'success' => true,
'tracking_status' => 'transit',
'tracking_completed' => false,
]);
$job->handle($trackingService);
});