mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-27 08:24:06 +00:00
Update: laravel 8 to 12, php 7.3 to php 8.3, Jenkinsfile, Unit/Feature testing, vapor, docker
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Models\Segment;
|
||||
use App\Models\SegmentConstant;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\TestCase;
|
||||
|
||||
#[Group('unit')]
|
||||
#[Group('segments')]
|
||||
#[Group('services')]
|
||||
#[Group('ok_to_run')]
|
||||
class CreatesConstantTest extends TestCase
|
||||
{
|
||||
// use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Test it can create a segment constant.
|
||||
*
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function test_it_can_create_a_segment_constant()
|
||||
{
|
||||
// A R R A N G E
|
||||
$segment = new Segment();
|
||||
$segment->name = 'test_it_can_create_a_segment_constant_SEG';
|
||||
$segment->save();
|
||||
|
||||
$detail = ['key' => 'value'];
|
||||
$object = new ConstantObject('test_it_can_create_a_segment_constant_CON', 'test_it_can_create_a_segment_constant_REF', $detail);
|
||||
$service = new CreatesConstant();
|
||||
|
||||
// A C T
|
||||
$result = $service->execute($segment, $object);
|
||||
|
||||
// A S S E R T
|
||||
$this->assertInstanceOf(SegmentConstant::class, $result);
|
||||
$this->assertEquals('test_it_can_create_a_segment_constant_CON', $result->name);
|
||||
$this->assertEquals('test_it_can_create_a_segment_constant_REF', $result->reference);
|
||||
$this->assertEquals((object) $detail, $result->detail);
|
||||
$this->assertEquals($segment->id, $result->segment_id);
|
||||
|
||||
$this->assertDatabaseHas('segment_constants', [
|
||||
'id' => $result->id,
|
||||
'name' => 'test_it_can_create_a_segment_constant_CON',
|
||||
'reference' => 'test_it_can_create_a_segment_constant_REF',
|
||||
'segment_id' => $segment->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user