validator = new ArticleValidator(); $this->type = new ArticleType('Notebook'); $this->ramDef = new AttributeDefinition('RAM', AttributeType::String); $this->cpuDef = new AttributeDefinition('CPU', AttributeType::String); $this->type->addAttributeDefinition($this->ramDef); $this->type->addAttributeDefinition($this->cpuDef); } public function testValidWhenAllAttributesSet(): void { $article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good); $article->setAttributeValue(new AttributeValue($article, $this->ramDef, '16 GB')); $article->setAttributeValue(new AttributeValue($article, $this->cpuDef, 'Intel i7')); $missing = $this->validator->getMissingAttributes($article); $this->assertEmpty($missing); $this->assertTrue($this->validator->isValid($article)); } public function testReturnsMissingAttributeNames(): void { $article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good); $article->setAttributeValue(new AttributeValue($article, $this->ramDef, '16 GB')); // cpuDef not set $missing = $this->validator->getMissingAttributes($article); $this->assertCount(1, $missing); $this->assertContains('CPU', $missing); $this->assertFalse($this->validator->isValid($article)); } public function testAllMissingWhenNoValuesSet(): void { $article = new Article($this->type, 'NB-001', 'INV-001', 1, ArticleCondition::Good); $missing = $this->validator->getMissingAttributes($article); $this->assertCount(2, $missing); } }