mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-23 14:34:04 +00:00
46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Original controller logic file:
|
|
* app/Classes/Modules/Segments/ControllersLogic/FetchBasePriceLogic.php
|
|
*/
|
|
|
|
namespace Tests\Feature\Segments\ControllersLogic;
|
|
|
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
|
|
#[Group('feature')]
|
|
#[Group('segments')]
|
|
#[Group('controllers_logic')]
|
|
#[Group('ok_to_run')]
|
|
class FetchBasePriceLogicTest extends SegmentsControllerLogicTestCase
|
|
{
|
|
public function test_it_can_fetch_base_price_for_a_date_range_via_controller_logic()
|
|
{
|
|
// A R R A N G E
|
|
$segment = $this->createSegment('fetch_base_price_logic');
|
|
$this->createConstant($segment, SegmentConstants::BASE_PRICE, [
|
|
'2026-03-01' => '10.00',
|
|
'2026-03-02' => '11.00',
|
|
'2026-03-05' => '14.00',
|
|
]);
|
|
|
|
// A C T
|
|
$response = $this->actingAsAdmin()
|
|
->getJson("/api/v1/segment/{$segment->id}/constant/base-price/show?dateFrom=2026-03-01&dateTo=2026-03-03");
|
|
|
|
// A S S E R T
|
|
$response->assertStatus(200);
|
|
$response->assertJsonPath('payload.data.reference', SegmentConstants::BASE_PRICE);
|
|
|
|
$value = $response->json('payload.data.value');
|
|
if (is_string($value)) {
|
|
$value = json_decode($value, true);
|
|
}
|
|
|
|
$this->assertSame('10.00', $value['2026-03-01'] ?? null);
|
|
$this->assertSame('11.00', $value['2026-03-02'] ?? null);
|
|
$this->assertArrayNotHasKey('2026-03-05', $value);
|
|
}
|
|
}
|