first commit

This commit is contained in:
julien
2026-03-20 22:13:41 +01:00
commit 41f8b3afb4
323 changed files with 27222 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Tests\Taxonomy;
use Netig\Netslim\Taxonomy\Domain\Entity\Taxon;
use PHPUnit\Framework\TestCase;
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
final class TaxonModelTest extends TestCase
{
public function testConstructAndGettersExposeTaxonData(): void
{
$taxon = new Taxon(4, 'PHP', 'php');
self::assertSame(4, $taxon->getId());
self::assertSame('PHP', $taxon->getName());
self::assertSame('php', $taxon->getSlug());
}
public function testFromArrayHydratesTaxon(): void
{
$taxon = Taxon::fromArray([
'id' => '6',
'name' => 'Tests',
'slug' => 'tests',
]);
self::assertSame(6, $taxon->getId());
self::assertSame('Tests', $taxon->getName());
self::assertSame('tests', $taxon->getSlug());
}
public function testValidationRejectsEmptyName(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Le nom du terme ne peut pas être vide');
new Taxon(1, '', 'slug');
}
public function testValidationRejectsTooLongName(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Le nom du terme ne peut pas dépasser 100 caractères');
new Taxon(1, str_repeat('a', 101), 'slug');
}
}