createConstructeur(name: 'Constructeur Alpha'); $this->createConstructeur(name: 'Constructeur Beta'); $session = $this->createMcpClient('ROLE_VIEWER'); $data = $this->callMcpTool($session, 'list_constructeurs'); $this->assertArrayHasKey('_parsed', $data, 'MCP response: '.json_encode($data)); $this->assertGreaterThanOrEqual(2, $data['_parsed']['total']); } public function testGetConstructeur(): void { $constructeur = $this->createConstructeur(name: 'Constructeur Gamma'); $session = $this->createMcpClient('ROLE_VIEWER'); $data = $this->callMcpTool($session, 'get_constructeur', ['constructeurId' => $constructeur->getId()]); $this->assertArrayHasKey('_parsed', $data); $this->assertSame('Constructeur Gamma', $data['_parsed']['name']); } public function testCreateConstructeur(): void { $session = $this->createMcpClient('ROLE_GESTIONNAIRE'); $data = $this->callMcpTool($session, 'create_constructeur', [ 'name' => 'Constructeur Nouveau', 'email' => 'contact@nouveau.com', 'phone' => '+33123456789', ]); $this->assertArrayHasKey('_parsed', $data); $this->assertSame('Constructeur Nouveau', $data['_parsed']['name']); $this->assertNotEmpty($data['_parsed']['id']); } public function testCreateConstructeurRequiresGestionnaire(): void { $session = $this->createMcpClient('ROLE_VIEWER'); $data = $this->callMcpTool($session, 'create_constructeur', ['name' => 'Forbidden']); $this->assertArrayHasKey('error', $data, 'Should fail with VIEWER role'); } public function testUpdateConstructeur(): void { $constructeur = $this->createConstructeur(name: 'Old Name'); $session = $this->createMcpClient('ROLE_GESTIONNAIRE'); $data = $this->callMcpTool($session, 'update_constructeur', [ 'constructeurId' => $constructeur->getId(), 'name' => 'New Name', ]); $this->assertArrayHasKey('_parsed', $data); $this->assertSame('New Name', $data['_parsed']['name']); } public function testDeleteConstructeur(): void { $constructeur = $this->createConstructeur(name: 'To Delete'); $session = $this->createMcpClient('ROLE_GESTIONNAIRE'); $data = $this->callMcpTool($session, 'delete_constructeur', ['constructeurId' => $constructeur->getId()]); $this->assertArrayHasKey('_parsed', $data); $this->assertTrue($data['_parsed']['deleted']); } }