Files
openidea/fixtures/php-app/tests/Shipping/ShipmentTest.php
T
lleviathe f50d3099ce test(smoke): smoke-test PHP on a php-app fixture (#2189)
PHP had no regression coverage. Adds a php-app fixture (Composer + Pest) with language, run and debug smoke cases, and a php entry in the Language smoke workflow: PHP 8.5 with Xdebug via setup-php, Intelephense pinned like the other servers. Other languages' selectors are unchanged.

Co-authored-by: lleviathe <95321986+lleviathe@users.noreply.github.com>
2026-11-10 12:10:51 +08:00

37 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Shipping\Dimensions;
use App\Shipping\ParcelStatus;
use App\Shipping\Route;
use App\Shipping\Shipment;
use Tests\TestSupport\ParcelFactory;
it('finds the heaviest parcel by billable weight', function (): void {
$bulky = ParcelFactory::make(weightGrams: 900, dimensions: new Dimensions(40, 30, 20));
$dense = ParcelFactory::make(weightGrams: 3000, dimensions: new Dimensions(10, 10, 10));
$shipment = new Shipment('FL-0412', Route::Air)->add($dense)->add($bulky);
expect($shipment->heaviest())->toBe($bulky);
});
it('departs once every parcel has confirmed contents', function (): void {
$confirmed = ParcelFactory::make()
->moveTo(ParcelStatus::Received)
->moveTo(ParcelStatus::AwaitingContents)
->moveTo(ParcelStatus::ContentsConfirmed);
$shipment = new Shipment('FL-0412', Route::Air)->add($confirmed);
expect($shipment->isReadyForDeparture())->toBeTrue()
->and($shipment->add(ParcelFactory::make())->isReadyForDeparture())->toBeFalse();
});
it('keeps its parcel list read-only from outside', function (): void {
$shipment = new Shipment('FL-0412', Route::Air);
expect(fn () => $shipment->parcels = [])->toThrow(Error::class);
});