PHPUnit config (phpunit.dist.xml, bin/phpunit, bootstrap.php), PHP CS Fixer config, .editorconfig. Separate .env.dev/.env.test templates. Ollama tunnel setup script. Architecture and plan docs. Updated application-layer unit tests to match current service signatures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.1 KiB
PHP
70 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Domain\Article;
|
|
|
|
use App\Domain\Article\Article;
|
|
use App\Domain\Article\ArticleCondition;
|
|
use App\Domain\Article\ArticleStatus;
|
|
use App\Domain\Article\ArticleType;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ArticleTest extends TestCase
|
|
{
|
|
private ArticleType $type;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->type = new ArticleType('Notebook');
|
|
}
|
|
|
|
public function testNewArticleHasIngestingStatus(): void
|
|
{
|
|
$article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good);
|
|
|
|
$this->assertSame(ArticleStatus::Ingesting, $article->getStatus());
|
|
$this->assertSame(1, $article->getStock());
|
|
}
|
|
|
|
public function testValidStatusTransition(): void
|
|
{
|
|
$article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good);
|
|
$article->transitionTo(ArticleStatus::Draft);
|
|
|
|
$this->assertSame(ArticleStatus::Draft, $article->getStatus());
|
|
}
|
|
|
|
public function testInvalidStatusTransitionThrows(): void
|
|
{
|
|
$article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good);
|
|
|
|
$this->expectException(\DomainException::class);
|
|
$article->transitionTo(ArticleStatus::Sold);
|
|
}
|
|
|
|
public function testDecrementStock(): void
|
|
{
|
|
$article = new Article($this->type, 'NB-001', 'INV-001', 3, ArticleCondition::Good);
|
|
$article->decrementStock();
|
|
|
|
$this->assertSame(2, $article->getStock());
|
|
$this->assertFalse($article->isOutOfStock());
|
|
}
|
|
|
|
public function testDecrementToZeroMarksOutOfStock(): void
|
|
{
|
|
$article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good);
|
|
$article->decrementStock();
|
|
|
|
$this->assertTrue($article->isOutOfStock());
|
|
}
|
|
|
|
public function testDecrementBelowZeroThrows(): void
|
|
{
|
|
$article = new Article($this->type, 'NB-001', 'INV-001', 0, ArticleCondition::Good);
|
|
|
|
$this->expectException(\DomainException::class);
|
|
$article->decrementStock();
|
|
}
|
|
}
|