mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-23 14:34:04 +00:00
47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Original controller logic file:
|
|
* app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.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 UpdateConstantPostcodeLogicTest extends SegmentsControllerLogicTestCase
|
|
{
|
|
public function test_it_can_add_a_postcode_and_remove_it_from_the_opposite_constant()
|
|
{
|
|
// A R R A N G E
|
|
$segment = $this->createSegment('update_constant_postcode_logic');
|
|
$this->createConstant($segment, SegmentConstants::CENTER_POSTCODE, ['10000']);
|
|
$this->createConstant($segment, SegmentConstants::OUTSTATION_POSTCODE, ['20000', '30000']);
|
|
$payload = [
|
|
'reference' => SegmentConstants::CENTER_POSTCODE,
|
|
'postcode' => '33000',
|
|
];
|
|
|
|
// A C T
|
|
$response = $this->actingAsAdmin()
|
|
->putJson("/api/v1/segment/{$segment->id}/constant/update/postcode", $payload);
|
|
|
|
// A S S E R T
|
|
$response->assertStatus(200);
|
|
$response->assertJsonPath('payload.data.reference', SegmentConstants::CENTER_POSTCODE);
|
|
$response->assertJsonPath('payload.data.value.0', '10000');
|
|
$response->assertJsonPath('payload.data.value.1', '33000');
|
|
|
|
$this->assertDatabaseHas('segment_constants', [
|
|
'segment_id' => $segment->id,
|
|
'reference' => SegmentConstants::CENTER_POSTCODE,
|
|
]);
|
|
|
|
$this->assertSame(['20000', '30000'], $segment->constants()->where('reference', SegmentConstants::OUTSTATION_POSTCODE)->first()->value);
|
|
}
|
|
}
|