feat(mcp) : add business tools — search, history, comments, custom fields, documents, model types
- search_inventory: global search across all 6 entity types - get_entity_history + get_activity_log: audit trail access - 4 comment tools: list, create, resolve, unresolved count - 3 custom field tools: list values, upsert, delete - 2 document tools: list, delete (upload via REST only) - 6 model type tools: list, get, create, update, delete, sync - 69 MCP tests pass total Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
63
tests/Mcp/Tool/SearchInventoryToolTest.php
Normal file
63
tests/Mcp/Tool/SearchInventoryToolTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Mcp\Tool;
|
||||
|
||||
use App\Tests\AbstractApiTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class SearchInventoryToolTest extends AbstractApiTestCase
|
||||
{
|
||||
public function testSearchFindsAcrossEntities(): void
|
||||
{
|
||||
$this->createMachine(name: 'Alpha Machine');
|
||||
$this->createPiece(name: 'Alpha Piece');
|
||||
$this->createSite(name: 'Alpha Site');
|
||||
|
||||
$session = $this->createMcpClient('ROLE_VIEWER');
|
||||
|
||||
$data = $this->callMcpTool($session, 'search_inventory', ['query' => 'Alpha']);
|
||||
|
||||
$this->assertArrayHasKey('_parsed', $data);
|
||||
$results = $data['_parsed'];
|
||||
$this->assertIsArray($results);
|
||||
|
||||
$types = array_unique(array_column($results, 'type'));
|
||||
$this->assertContains('machine', $types);
|
||||
$this->assertContains('piece', $types);
|
||||
$this->assertContains('site', $types);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$this->assertArrayHasKey('type', $result);
|
||||
$this->assertArrayHasKey('id', $result);
|
||||
$this->assertArrayHasKey('name', $result);
|
||||
$this->assertArrayHasKey('reference', $result);
|
||||
$this->assertStringContainsStringIgnoringCase('Alpha', $result['name']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSearchFiltersByType(): void
|
||||
{
|
||||
$this->createMachine(name: 'Beta Machine');
|
||||
$this->createPiece(name: 'Beta Piece');
|
||||
$this->createSite(name: 'Beta Site');
|
||||
|
||||
$session = $this->createMcpClient('ROLE_VIEWER');
|
||||
|
||||
$data = $this->callMcpTool($session, 'search_inventory', [
|
||||
'query' => 'Beta',
|
||||
'types' => 'machine',
|
||||
]);
|
||||
|
||||
$this->assertArrayHasKey('_parsed', $data);
|
||||
$results = $data['_parsed'];
|
||||
$this->assertIsArray($results);
|
||||
$this->assertNotEmpty($results);
|
||||
|
||||
$types = array_unique(array_column($results, 'type'));
|
||||
$this->assertSame(['machine'], $types);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user