mejoras en la gestión de nombres y códigos de proyectos y documentos según la norma ISO 19650
This commit is contained in:
70
tests/Unit/ProjectNamingSchemaTest.php
Normal file
70
tests/Unit/ProjectNamingSchemaTest.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user