71 lines
1.9 KiB
PHP
71 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Helpers\ProjectNamingSchema;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ProjectNamingSchemaTest extends TestCase
|
|
{
|
|
/**
|
|
* Test generating a valid project name with all required fields.
|
|
*/
|
|
public function testGenerateValidProjectName()
|
|
{
|
|
$fields = [
|
|
'project' => 'PRJ001',
|
|
'creator' => 'ORG01',
|
|
'volume' => 'V01',
|
|
'level' => 'L01',
|
|
'documentType' => 'DOC',
|
|
'discipline' => 'ARC',
|
|
'number' => '1',
|
|
];
|
|
|
|
$expected = 'PRJ001-ORG01-V01-L01-DOC-ARC-001';
|
|
$this->assertEquals($expected, ProjectNamingSchema::generate($fields));
|
|
}
|
|
|
|
/**
|
|
* Test generating a project name with optional fields.
|
|
*/
|
|
public function testGenerateProjectNameWithOptionalFields()
|
|
{
|
|
$fields = [
|
|
'project' => 'PRJ001',
|
|
'creator' => 'ORG01',
|
|
'volume' => 'V01',
|
|
'level' => 'L01',
|
|
'documentType' => 'DOC',
|
|
'discipline' => 'ARC',
|
|
'number' => '1',
|
|
'description' => 'Description',
|
|
'status' => 'ST',
|
|
'revision' => '1',
|
|
];
|
|
|
|
$expected = 'PRJ001-ORG01-V01-L01-DOC-ARC-001-Description-ST-0001';
|
|
$this->assertEquals($expected, ProjectNamingSchema::generate($fields));
|
|
}
|
|
|
|
/**
|
|
* Test generating a project name with missing required fields.
|
|
*/
|
|
public function testGenerateProjectNameWithMissingFields()
|
|
{
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
$this->expectExceptionMessage("The field 'project' is required.");
|
|
|
|
$fields = [
|
|
'creator' => 'ORG01',
|
|
'volume' => 'V01',
|
|
'level' => 'L01',
|
|
'documentType' => 'DOC',
|
|
'discipline' => 'ARC',
|
|
'number' => '1',
|
|
];
|
|
|
|
ProjectNamingSchema::generate($fields);
|
|
}
|
|
}
|