Protokoll #16966

ID16966
Zeitstempel2025-12-25 20:24:56.569636
Clientroot
IP145.224.72.140
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens5,265 (Input: 2,630, Output: 2,635)
Dauer83 ms
Request-Zeit2025-12-25 20:24:56.569636
Response-Zeit2025-12-25 20:24:56.652683

Request

{
    "event": "PreToolUse",
    "tool_name": "Write",
    "tool_input": {
        "file_path": "\/var\/www\/dev.campus.systemische-tools.de\/tests\/Integration\/Taxonomy\/TaxonomyIntegrationTest.php",
        "content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Integration\\Taxonomy;\n\n\/\/ @responsibility: Integration-Tests für Taxonomie-Mapping Pipeline\n\nuse Domain\\Entity\\ChunkTaxonomyMapping;\nuse Domain\\Entity\\EntityTaxonomyMapping;\nuse Domain\\ValueObject\\Confidence;\nuse Domain\\ValueObject\\MappingSource;\nuse PHPUnit\\Framework\\TestCase;\n\n\/**\n * Integration tests for Taxonomy Mapping Pipeline.\n *\n * Tests cover:\n * - ChunkTaxonomyMapping entity creation and serialization\n * - EntityTaxonomyMapping entity creation and validation\n * - Value objects (Confidence, MappingSource)\n * - Data integrity across mapping lifecycle\n *\/\nclass TaxonomyIntegrationTest extends TestCase\n{\n    \/\/ =========================================================================\n    \/\/ ChunkTaxonomyMapping Tests\n    \/\/ =========================================================================\n\n    public function testChunkTaxonomyMappingCreation(): void\n    {\n        $mapping = new ChunkTaxonomyMapping();\n        $mapping->setChunkId(42);\n        $mapping->setTaxonomyTermId(7);\n        $mapping->setConfidence(Confidence::fromFloat(0.85));\n        $mapping->setSource(MappingSource::AUTO);\n\n        $this->assertNull($mapping->getId());\n        $this->assertSame(42, $mapping->getChunkId());\n        $this->assertSame(7, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.85, $mapping->getConfidence()->value());\n        $this->assertSame('auto', $mapping->getSource()->value);\n        $this->assertInstanceOf(\\DateTimeImmutable::class, $mapping->getCreatedAt());\n    }\n\n    public function testChunkTaxonomyMappingToArray(): void\n    {\n        $mapping = new ChunkTaxonomyMapping();\n        $mapping->setId(1);\n        $mapping->setChunkId(100);\n        $mapping->setTaxonomyTermId(5);\n        $mapping->setConfidence(Confidence::fromFloat(0.9));\n        $mapping->setSource(MappingSource::MANUAL);\n\n        $array = $mapping->toArray();\n\n        $this->assertSame(1, $array['id']);\n        $this->assertSame(100, $array['chunk_id']);\n        $this->assertSame(5, $array['taxonomy_term_id']);\n        $this->assertSame(0.9, $array['confidence']);\n        $this->assertSame('manual', $array['source']);\n        $this->assertArrayHasKey('created_at', $array);\n    }\n\n    public function testChunkTaxonomyMappingFromArray(): void\n    {\n        $data = [\n            'id' => 99,\n            'chunk_id' => 200,\n            'taxonomy_term_id' => 15,\n            'confidence' => 0.75,\n            'source' => 'pipeline',\n            'created_at' => '2025-01-01 12:00:00',\n        ];\n\n        $mapping = ChunkTaxonomyMapping::fromArray($data);\n\n        $this->assertSame(99, $mapping->getId());\n        $this->assertSame(200, $mapping->getChunkId());\n        $this->assertSame(15, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.75, $mapping->getConfidence()->value());\n        $this->assertSame('pipeline', $mapping->getSource()->value);\n    }\n\n    public function testChunkTaxonomyMappingRoundTrip(): void\n    {\n        $original = new ChunkTaxonomyMapping();\n        $original->setId(42);\n        $original->setChunkId(500);\n        $original->setTaxonomyTermId(25);\n        $original->setConfidence(Confidence::high());\n        $original->setSource(MappingSource::IMPORT);\n\n        $array = $original->toArray();\n        $restored = ChunkTaxonomyMapping::fromArray($array);\n\n        $this->assertSame($original->getId(), $restored->getId());\n        $this->assertSame($original->getChunkId(), $restored->getChunkId());\n        $this->assertSame($original->getTaxonomyTermId(), $restored->getTaxonomyTermId());\n        $this->assertSame($original->getConfidence()->value(), $restored->getConfidence()->value());\n        $this->assertSame($original->getSource()->value, $restored->getSource()->value);\n    }\n\n    \/\/ =========================================================================\n    \/\/ EntityTaxonomyMapping Tests\n    \/\/ =========================================================================\n\n    public function testEntityTaxonomyMappingCreation(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setEntityId(10);\n        $mapping->setTaxonomyTermId(3);\n        $mapping->setRelevance(Confidence::fromFloat(0.8));\n\n        $this->assertNull($mapping->getId());\n        $this->assertSame(10, $mapping->getEntityId());\n        $this->assertSame(3, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.8, $mapping->getRelevance()->value());\n        $this->assertFalse($mapping->isValidated());\n    }\n\n    public function testEntityTaxonomyMappingValidation(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setEntityId(5);\n        $mapping->setTaxonomyTermId(2);\n\n        $this->assertFalse($mapping->isValidated());\n\n        $mapping->validate();\n        $this->assertTrue($mapping->isValidated());\n        $this->assertNotNull($mapping->getUpdatedAt());\n\n        $mapping->invalidate();\n        $this->assertFalse($mapping->isValidated());\n    }\n\n    public function testEntityTaxonomyMappingToArray(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setId(50);\n        $mapping->setEntityId(100);\n        $mapping->setTaxonomyTermId(20);\n        $mapping->setRelevance(Confidence::medium());\n        $mapping->validate();\n\n        $array = $mapping->toArray();\n\n        $this->assertSame(50, $array['id']);\n        $this->assertSame(100, $array['entity_id']);\n        $this->assertSame(20, $array['taxonomy_term_id']);\n        $this->assertSame(0.5, $array['relevance']);\n        $this->assertSame(1, $array['validated']);\n    }\n\n    public function testEntityTaxonomyMappingFromArray(): void\n    {\n        $data = [\n            'id' => 77,\n            'entity_id' => 300,\n            'taxonomy_term_id' => 30,\n            'relevance' => 0.65,\n            'validated' => true,\n            'created_at' => '2025-06-15 10:30:00',\n            'updated_at' => '2025-06-15 11:00:00',\n        ];\n\n        $mapping = EntityTaxonomyMapping::fromArray($data);\n\n        $this->assertSame(77, $mapping->getId());\n        $this->assertSame(300, $mapping->getEntityId());\n        $this->assertSame(30, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.65, $mapping->getRelevance()->value());\n        $this->assertTrue($mapping->isValidated());\n        $this->assertNotNull($mapping->getUpdatedAt());\n    }\n\n    \/\/ =========================================================================\n    \/\/ Confidence Value Object Tests\n    \/\/ =========================================================================\n\n    public function testConfidenceFromFloat(): void\n    {\n        $confidence = Confidence::fromFloat(0.75);\n        $this->assertSame(0.75, $confidence->value());\n    }\n\n    public function testConfidenceFactoryMethods(): void\n    {\n        $this->assertSame(0.9, Confidence::high()->value());\n        $this->assertSame(0.5, Confidence::medium()->value());\n        $this->assertSame(0.3, Confidence::low()->value());\n    }\n\n    public function testConfidenceBoundaries(): void\n    {\n        $zero = Confidence::fromFloat(0.0);\n        $one = Confidence::fromFloat(1.0);\n\n        $this->assertSame(0.0, $zero->value());\n        $this->assertSame(1.0, $one->value());\n    }\n\n    public function testConfidenceInvalidValueTooLow(): void\n    {\n        $this->expectException(\\InvalidArgumentException::class);\n        Confidence::fromFloat(-0.1);\n    }\n\n    public function testConfidenceInvalidValueTooHigh(): void\n    {\n        $this->expectException(\\InvalidArgumentException::class);\n        Confidence::fromFloat(1.1);\n    }\n\n    \/\/ =========================================================================\n    \/\/ MappingSource Value Object Tests\n    \/\/ =========================================================================\n\n    public function testMappingSourceValues(): void\n    {\n        $this->assertSame('auto', MappingSource::AUTO->value);\n        $this->assertSame('manual', MappingSource::MANUAL->value);\n        $this->assertSame('pipeline', MappingSource::PIPELINE->value);\n        $this->assertSame('import', MappingSource::IMPORT->value);\n    }\n\n    public function testMappingSourceFrom(): void\n    {\n        $auto = MappingSource::from('auto');\n        $manual = MappingSource::from('manual');\n\n        $this->assertSame(MappingSource::AUTO, $auto);\n        $this->assertSame(MappingSource::MANUAL, $manual);\n    }\n\n    public function testMappingSourceTryFrom(): void\n    {\n        $valid = MappingSource::tryFrom('pipeline');\n        $invalid = MappingSource::tryFrom('invalid_source');\n\n        $this->assertSame(MappingSource::PIPELINE, $valid);\n        $this->assertNull($invalid);\n    }\n\n    \/\/ =========================================================================\n    \/\/ Data Integrity Tests\n    \/\/ =========================================================================\n\n    public function testChunkMappingUpdatedAtOnConfidenceChange(): void\n    {\n        $mapping = new ChunkTaxonomyMapping();\n        $mapping->setChunkId(1);\n        $mapping->setTaxonomyTermId(1);\n        $mapping->setConfidence(Confidence::low());\n\n        $initialUpdatedAt = $mapping->getUpdatedAt();\n\n        usleep(1000);\n        $mapping->setConfidence(Confidence::high());\n\n        $this->assertNotNull($mapping->getUpdatedAt());\n        if ($initialUpdatedAt !== null) {\n            $this->assertNotEquals(\n                $initialUpdatedAt->format('U.u'),\n                $mapping->getUpdatedAt()->format('U.u')\n            );\n        }\n    }\n\n    public function testEntityMappingUpdatedAtOnValidation(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setEntityId(1);\n        $mapping->setTaxonomyTermId(1);\n\n        $this->assertNull($mapping->getUpdatedAt());\n\n        $mapping->validate();\n\n        $this->assertNotNull($mapping->getUpdatedAt());\n    }\n\n    public function testMultipleMappingsIndependence(): void\n    {\n        $mapping1 = new Ch... [TRUNCATED-bc6e5d98b893c0d3]"
    }
}

Response

{
    "tool_response": {
        "type": "create",
        "filePath": "\/var\/www\/dev.campus.systemische-tools.de\/tests\/Integration\/Taxonomy\/TaxonomyIntegrationTest.php",
        "content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Integration\\Taxonomy;\n\n\/\/ @responsibility: Integration-Tests für Taxonomie-Mapping Pipeline\n\nuse Domain\\Entity\\ChunkTaxonomyMapping;\nuse Domain\\Entity\\EntityTaxonomyMapping;\nuse Domain\\ValueObject\\Confidence;\nuse Domain\\ValueObject\\MappingSource;\nuse PHPUnit\\Framework\\TestCase;\n\n\/**\n * Integration tests for Taxonomy Mapping Pipeline.\n *\n * Tests cover:\n * - ChunkTaxonomyMapping entity creation and serialization\n * - EntityTaxonomyMapping entity creation and validation\n * - Value objects (Confidence, MappingSource)\n * - Data integrity across mapping lifecycle\n *\/\nclass TaxonomyIntegrationTest extends TestCase\n{\n    \/\/ =========================================================================\n    \/\/ ChunkTaxonomyMapping Tests\n    \/\/ =========================================================================\n\n    public function testChunkTaxonomyMappingCreation(): void\n    {\n        $mapping = new ChunkTaxonomyMapping();\n        $mapping->setChunkId(42);\n        $mapping->setTaxonomyTermId(7);\n        $mapping->setConfidence(Confidence::fromFloat(0.85));\n        $mapping->setSource(MappingSource::AUTO);\n\n        $this->assertNull($mapping->getId());\n        $this->assertSame(42, $mapping->getChunkId());\n        $this->assertSame(7, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.85, $mapping->getConfidence()->value());\n        $this->assertSame('auto', $mapping->getSource()->value);\n        $this->assertInstanceOf(\\DateTimeImmutable::class, $mapping->getCreatedAt());\n    }\n\n    public function testChunkTaxonomyMappingToArray(): void\n    {\n        $mapping = new ChunkTaxonomyMapping();\n        $mapping->setId(1);\n        $mapping->setChunkId(100);\n        $mapping->setTaxonomyTermId(5);\n        $mapping->setConfidence(Confidence::fromFloat(0.9));\n        $mapping->setSource(MappingSource::MANUAL);\n\n        $array = $mapping->toArray();\n\n        $this->assertSame(1, $array['id']);\n        $this->assertSame(100, $array['chunk_id']);\n        $this->assertSame(5, $array['taxonomy_term_id']);\n        $this->assertSame(0.9, $array['confidence']);\n        $this->assertSame('manual', $array['source']);\n        $this->assertArrayHasKey('created_at', $array);\n    }\n\n    public function testChunkTaxonomyMappingFromArray(): void\n    {\n        $data = [\n            'id' => 99,\n            'chunk_id' => 200,\n            'taxonomy_term_id' => 15,\n            'confidence' => 0.75,\n            'source' => 'pipeline',\n            'created_at' => '2025-01-01 12:00:00',\n        ];\n\n        $mapping = ChunkTaxonomyMapping::fromArray($data);\n\n        $this->assertSame(99, $mapping->getId());\n        $this->assertSame(200, $mapping->getChunkId());\n        $this->assertSame(15, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.75, $mapping->getConfidence()->value());\n        $this->assertSame('pipeline', $mapping->getSource()->value);\n    }\n\n    public function testChunkTaxonomyMappingRoundTrip(): void\n    {\n        $original = new ChunkTaxonomyMapping();\n        $original->setId(42);\n        $original->setChunkId(500);\n        $original->setTaxonomyTermId(25);\n        $original->setConfidence(Confidence::high());\n        $original->setSource(MappingSource::IMPORT);\n\n        $array = $original->toArray();\n        $restored = ChunkTaxonomyMapping::fromArray($array);\n\n        $this->assertSame($original->getId(), $restored->getId());\n        $this->assertSame($original->getChunkId(), $restored->getChunkId());\n        $this->assertSame($original->getTaxonomyTermId(), $restored->getTaxonomyTermId());\n        $this->assertSame($original->getConfidence()->value(), $restored->getConfidence()->value());\n        $this->assertSame($original->getSource()->value, $restored->getSource()->value);\n    }\n\n    \/\/ =========================================================================\n    \/\/ EntityTaxonomyMapping Tests\n    \/\/ =========================================================================\n\n    public function testEntityTaxonomyMappingCreation(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setEntityId(10);\n        $mapping->setTaxonomyTermId(3);\n        $mapping->setRelevance(Confidence::fromFloat(0.8));\n\n        $this->assertNull($mapping->getId());\n        $this->assertSame(10, $mapping->getEntityId());\n        $this->assertSame(3, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.8, $mapping->getRelevance()->value());\n        $this->assertFalse($mapping->isValidated());\n    }\n\n    public function testEntityTaxonomyMappingValidation(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setEntityId(5);\n        $mapping->setTaxonomyTermId(2);\n\n        $this->assertFalse($mapping->isValidated());\n\n        $mapping->validate();\n        $this->assertTrue($mapping->isValidated());\n        $this->assertNotNull($mapping->getUpdatedAt());\n\n        $mapping->invalidate();\n        $this->assertFalse($mapping->isValidated());\n    }\n\n    public function testEntityTaxonomyMappingToArray(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setId(50);\n        $mapping->setEntityId(100);\n        $mapping->setTaxonomyTermId(20);\n        $mapping->setRelevance(Confidence::medium());\n        $mapping->validate();\n\n        $array = $mapping->toArray();\n\n        $this->assertSame(50, $array['id']);\n        $this->assertSame(100, $array['entity_id']);\n        $this->assertSame(20, $array['taxonomy_term_id']);\n        $this->assertSame(0.5, $array['relevance']);\n        $this->assertSame(1, $array['validated']);\n    }\n\n    public function testEntityTaxonomyMappingFromArray(): void\n    {\n        $data = [\n            'id' => 77,\n            'entity_id' => 300,\n            'taxonomy_term_id' => 30,\n            'relevance' => 0.65,\n            'validated' => true,\n            'created_at' => '2025-06-15 10:30:00',\n            'updated_at' => '2025-06-15 11:00:00',\n        ];\n\n        $mapping = EntityTaxonomyMapping::fromArray($data);\n\n        $this->assertSame(77, $mapping->getId());\n        $this->assertSame(300, $mapping->getEntityId());\n        $this->assertSame(30, $mapping->getTaxonomyTermId());\n        $this->assertSame(0.65, $mapping->getRelevance()->value());\n        $this->assertTrue($mapping->isValidated());\n        $this->assertNotNull($mapping->getUpdatedAt());\n    }\n\n    \/\/ =========================================================================\n    \/\/ Confidence Value Object Tests\n    \/\/ =========================================================================\n\n    public function testConfidenceFromFloat(): void\n    {\n        $confidence = Confidence::fromFloat(0.75);\n        $this->assertSame(0.75, $confidence->value());\n    }\n\n    public function testConfidenceFactoryMethods(): void\n    {\n        $this->assertSame(0.9, Confidence::high()->value());\n        $this->assertSame(0.5, Confidence::medium()->value());\n        $this->assertSame(0.3, Confidence::low()->value());\n    }\n\n    public function testConfidenceBoundaries(): void\n    {\n        $zero = Confidence::fromFloat(0.0);\n        $one = Confidence::fromFloat(1.0);\n\n        $this->assertSame(0.0, $zero->value());\n        $this->assertSame(1.0, $one->value());\n    }\n\n    public function testConfidenceInvalidValueTooLow(): void\n    {\n        $this->expectException(\\InvalidArgumentException::class);\n        Confidence::fromFloat(-0.1);\n    }\n\n    public function testConfidenceInvalidValueTooHigh(): void\n    {\n        $this->expectException(\\InvalidArgumentException::class);\n        Confidence::fromFloat(1.1);\n    }\n\n    \/\/ =========================================================================\n    \/\/ MappingSource Value Object Tests\n    \/\/ =========================================================================\n\n    public function testMappingSourceValues(): void\n    {\n        $this->assertSame('auto', MappingSource::AUTO->value);\n        $this->assertSame('manual', MappingSource::MANUAL->value);\n        $this->assertSame('pipeline', MappingSource::PIPELINE->value);\n        $this->assertSame('import', MappingSource::IMPORT->value);\n    }\n\n    public function testMappingSourceFrom(): void\n    {\n        $auto = MappingSource::from('auto');\n        $manual = MappingSource::from('manual');\n\n        $this->assertSame(MappingSource::AUTO, $auto);\n        $this->assertSame(MappingSource::MANUAL, $manual);\n    }\n\n    public function testMappingSourceTryFrom(): void\n    {\n        $valid = MappingSource::tryFrom('pipeline');\n        $invalid = MappingSource::tryFrom('invalid_source');\n\n        $this->assertSame(MappingSource::PIPELINE, $valid);\n        $this->assertNull($invalid);\n    }\n\n    \/\/ =========================================================================\n    \/\/ Data Integrity Tests\n    \/\/ =========================================================================\n\n    public function testChunkMappingUpdatedAtOnConfidenceChange(): void\n    {\n        $mapping = new ChunkTaxonomyMapping();\n        $mapping->setChunkId(1);\n        $mapping->setTaxonomyTermId(1);\n        $mapping->setConfidence(Confidence::low());\n\n        $initialUpdatedAt = $mapping->getUpdatedAt();\n\n        usleep(1000);\n        $mapping->setConfidence(Confidence::high());\n\n        $this->assertNotNull($mapping->getUpdatedAt());\n        if ($initialUpdatedAt !== null) {\n            $this->assertNotEquals(\n                $initialUpdatedAt->format('U.u'),\n                $mapping->getUpdatedAt()->format('U.u')\n            );\n        }\n    }\n\n    public function testEntityMappingUpdatedAtOnValidation(): void\n    {\n        $mapping = new EntityTaxonomyMapping();\n        $mapping->setEntityId(1);\n        $mapping->setTaxonomyTermId(1);\n\n        $this->assertNull($mapping->getUpdatedAt());\n\n        $mapping->validate();\n\n        $this->assertNotNull($mapping->getUpdatedAt());\n    }\n\n    public function testMultipleMappingsIndependence(): void\n    {\n        $mapping1 = new Ch... [TRUNCATED-bc6e5d98b893c0d3]",
        "structuredPatch": [],
        "originalFile": null
    }
}
← Vorheriger Zur Liste Nächster →