mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Modules\Segments\Services;
|
|
|
|
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
|
use App\Classes\Modules\Segments\Services\CreatesSegment;
|
|
use App\Models\Segment;
|
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use Tests\TestCase;
|
|
|
|
#[Group('unit')]
|
|
#[Group('segments')]
|
|
#[Group('services')]
|
|
#[Group('ok_to_run')]
|
|
class CreatesSegmentTest extends TestCase
|
|
{
|
|
// use DatabaseTransactions;
|
|
|
|
/**
|
|
* Test it can create a segment.
|
|
*
|
|
* @return void
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
*/
|
|
public function test_it_can_create_a_segment()
|
|
{
|
|
// A R R A N G E
|
|
$name = 'test_it_can_create_a_segment';
|
|
$type = SegmentConstants::STANDARD_SEGMENT;
|
|
$object = new SegmentObject($name, $type);
|
|
$service = new CreatesSegment();
|
|
|
|
// A C T
|
|
$result = $service->execute($object);
|
|
|
|
// A S S E R T
|
|
$this->assertInstanceOf(Segment::class, $result);
|
|
$this->assertEquals($name, $result->name);
|
|
$this->assertEquals($type, $result->type);
|
|
|
|
$this->assertDatabaseHas('segments', [
|
|
'id' => $result->id,
|
|
'name' => $name,
|
|
'type' => $type,
|
|
]);
|
|
}
|
|
}
|