mivita/tests/Unit/Dhl/OrderDhlShippingButtonTest.php
Kevin 42ef4dd1c6 DHL-Versand: Sendungs-Info-Button in Bestelllisten & Absenderadresse
Neuer schlanker DHL-Info-Button (getDhlShippingButton) in den Order- und
Shop-Sales-Datatables, oeffnet ein Read-only-Modal (modal_dhl_shipping_info)
mit den Tracking-Daten; dhlShipments wird dafuer eager geladen.
Absenderadresse in config/dhl.php aktualisiert, plus kleinere Fixes in
DhlShipmentController/Service/DataHelper und CreateReturnLabelJob.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 13:37:13 +00:00

43 lines
1.2 KiB
PHP

<?php
use Acme\Dhl\Models\DhlShipment;
use App\Http\Controllers\Controller;
use App\Models\ShoppingOrder;
use Illuminate\Support\Facades\Route;
beforeEach(function () {
Route::post('modal/load', fn () => '')->name('modal_load');
app('router')->getRoutes()->refreshNameLookups();
});
function dhlShippingButtonProbe(): Controller
{
return new class extends Controller
{
public function render(ShoppingOrder $order): string
{
return $this->getDhlShippingButton($order);
}
};
}
it('renders no shipping button when the order has no DHL shipment', function () {
$order = new ShoppingOrder;
$order->id = 5;
$order->setRelation('dhlShipments', collect());
expect(dhlShippingButtonProbe()->render($order))->toBe('');
});
it('renders the shipping-fast button when the order has a DHL shipment', function () {
$order = new ShoppingOrder;
$order->id = 42;
$order->setRelation('dhlShipments', collect([new DhlShipment]));
$html = dhlShippingButtonProbe()->render($order);
expect($html)
->toContain('fa-shipping-fast')
->toContain('data-action="user-order-dhl-info"')
->toContain('data-id="42"');
});