Add feature tests for QBCore and FiveM tools

- Implement tests for GetInventoryClientFunction and GetInventoryServerFunction in the COX namespace.
- Create tests for GenerateManifest and GenerateResourceBoilerplate in the FiveM namespace.
- Add tests for event and native function references in the FiveM namespace.
- Introduce tests for QBCore client and server event references, functions, and configurations.
- Implement tests for shared data retrieval in QBCore.
- Ensure all tests validate expected responses and handle edge cases.
This commit is contained in:
Adrian Mejias committed 2026-03-01 15:23:07 -06:00
1 parent b4d3b3582c
commit 29b854fd44
25 files changed
+1188

No files matched your search

@@ -0,0 +1,49 @@
<?php
use App\Mcp\Tools\QBCore\Client\GetQBCoreClientEventReference;
use Laravel\Mcp\Request;
it('returns qbcore client event reference', function () {
$tool = new GetQBCoreClientEventReference;
$request = new Request(['event_name' => 'QBCore:Client:OnPlayerLoad']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('OnPlayerLoad');
});
it('returns not found for invalid client event', function () {
$tool = new GetQBCoreClientEventReference;
$request = new Request(['event_name' => 'InvalidClientEvent']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});
it('lists all client events when empty event name', function () {
$tool = new GetQBCoreClientEventReference;
$request = new Request(['event_name' => '']);
$response = $tool->handle($request);
expect((string) $response->content())->not()->toBeEmpty();
});
it('searches by client event short names', function () {
$tool = new GetQBCoreClientEventReference;
$request = new Request(['event_name' => 'QBCore:Client:OnPlayerLoad']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('OnPlayerLoad');
});
it('includes notification event', function () {
$tool = new GetQBCoreClientEventReference;
$request = new Request(['event_name' => 'QBCore:Notify']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Notify');
});
@@ -0,0 +1,49 @@
<?php
use App\Mcp\Tools\QBCore\Client\GetQBCoreClientFunction;
use Laravel\Mcp\Request;
it('returns qbcore client function info', function () {
$tool = new GetQBCoreClientFunction;
$request = new Request(['function_name' => 'QBCore.Functions.GetPlayerData', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('GetPlayerData');
});
it('returns not found for invalid client function', function () {
$tool = new GetQBCoreClientFunction;
$request = new Request(['function_name' => 'InvalidClientFunction', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});
it('supports javascript examples for client functions', function () {
$tool = new GetQBCoreClientFunction;
$request = new Request(['function_name' => 'QBCore.Commands.Add', 'language' => 'js']);
$response = $tool->handle($request);
expect((string) $response->content())->not()->toBeEmpty();
});
it('handles case insensitive client function names', function () {
$tool = new GetQBCoreClientFunction;
$request = new Request(['function_name' => 'qbcore.functions.getplayerdata', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('GetPlayerData');
});
it('includes command registration function', function () {
$tool = new GetQBCoreClientFunction;
$request = new Request(['function_name' => 'QBCore.Commands.Add', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->not()->toBeEmpty();
});
@@ -0,0 +1,72 @@
<?php
use App\Mcp\Tools\QBCore\GetQBCoreConfig;
use Laravel\Mcp\Request;
test('GetQBCoreConfig returns Player config', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'Player', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Player');
expect((string) $response->content())->toContain('PlayerDefaults');
});
test('GetQBCoreConfig returns Framework config', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'Framework', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Framework');
expect((string) $response->content())->toContain('Version');
});
test('GetQBCoreConfig returns Database config', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'Database', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Database');
expect((string) $response->content())->toContain('Backend');
});
test('GetQBCoreConfig returns Callbacks config', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'Callbacks', 'language' => 'js']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Callbacks');
expect((string) $response->content())->toContain('JavaScript Example');
});
test('GetQBCoreConfig returns Features config', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'Features', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Features');
});
test('GetQBCoreConfig returns RepTypes config', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'RepTypes', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('RepTypes');
expect((string) $response->content())->toContain('selling');
});
test('GetQBCoreConfig returns not found for invalid type', function () {
$tool = new GetQBCoreConfig;
$request = new Request(['config_type' => 'InvalidType', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});
@@ -0,0 +1,66 @@
<?php
use App\Mcp\Tools\QBCore\GetQBCorePlayers;
use Laravel\Mcp\Request;
test('GetQBCorePlayers returns Structure info', function () {
$tool = new GetQBCorePlayers;
$request = new Request(['info_type' => 'Structure', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Structure');
expect((string) $response->content())->toContain('PlayerData');
expect((string) $response->content())->toContain('Functions');
});
test('GetQBCorePlayers returns PlayerData info', function () {
$tool = new GetQBCorePlayers;
$request = new Request(['info_type' => 'PlayerData', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('PlayerData');
expect((string) $response->content())->toContain('citizenid');
expect((string) $response->content())->toContain('charinfo');
});
test('GetQBCorePlayers returns Methods info', function () {
$tool = new GetQBCorePlayers;
$request = new Request(['info_type' => 'Methods', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Methods');
expect((string) $response->content())->toContain('AddItem');
expect((string) $response->content())->toContain('SetJob');
});
test('GetQBCorePlayers returns Events info', function () {
$tool = new GetQBCorePlayers;
$request = new Request(['info_type' => 'Events', 'language' => 'js']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Events');
expect((string) $response->content())->toContain('JavaScript Example');
});
test('GetQBCorePlayers returns Examples info', function () {
$tool = new GetQBCorePlayers;
$request = new Request(['info_type' => 'Examples', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Examples');
expect((string) $response->content())->toContain('HasItem');
});
test('GetQBCorePlayers returns not found for invalid type', function () {
$tool = new GetQBCorePlayers;
$request = new Request(['info_type' => 'InvalidType', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});
@@ -0,0 +1,132 @@
<?php
use App\Mcp\Tools\QBCore\GetQBCoreResourceList;
use Laravel\Mcp\Request;
test('GetQBCoreResourceList returns all resources', function () {
$tool = new GetQBCoreResourceList;
$request = new Request([]);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('QBCore Resources Directory');
expect($content)->toContain('qb-ambulancejob');
expect($content)->toContain('qb-adminmenu');
expect($content)->toContain('qb-policejob');
});
test('GetQBCoreResourceList contains all 58 resources', function () {
$tool = new GetQBCoreResourceList;
$request = new Request([]);
$response = $tool->handle($request);
$content = (string) $response->content();
// Count resource names in the response
$resources = [
'qb-adminmenu', 'qb-ambulancejob', 'qb-apartments', 'qb-banking', 'qb-bankrobbery',
'qb-busjob', 'qb-cityhall', 'qb-clothing', 'qb-crypto', 'qb-diving',
'qb-doorlock', 'qb-drugs', 'qb-fitbit', 'qb-fuel', 'qb-garages',
'qb-garbagejob', 'qb-hotdogjob', 'qb-houserobbery', 'qb-houses', 'qb-hud',
'qb-input', 'qb-interior', 'qb-inventory', 'qb-jewelry', 'qb-lapraces',
'qb-loading', 'qb-management', 'qb-mechanicjob', 'qb-menu', 'qb-minigames',
'qb-multicharacter', 'qb-newsjob', 'qb-pawnshop', 'qb-phone', 'qb-policejob',
'qb-prison', 'qb-radialmenu', 'qb-radio', 'qb-recyclejob', 'qb-scoreboard',
'qb-scrapyard', 'qb-shops', 'qb-smallresources', 'qb-spawn', 'qb-storerobbery',
'qb-streetraces', 'qb-taxijob', 'qb-towjob', 'qb-target', 'qb-truckerjob',
'qb-truckrobbery', 'qb-vehiclekeys', 'qb-vehiclesales', 'qb-vehicleshop', 'qb-vineyard',
'qb-weapons', 'qb-weathersync', 'qb-weed',
];
foreach ($resources as $resource) {
expect($content)->toContain($resource);
}
});
test('GetQBCoreResourceList filters by category - Jobs', function () {
$tool = new GetQBCoreResourceList;
$request = new Request(['category' => 'Jobs']);
$response = $tool->handle($request);
$content = (string) $response->content();
// Should contain job resources
expect($content)->toContain('qb-ambulancejob');
expect($content)->toContain('qb-policejob');
expect($content)->toContain('qb-mechanicjob');
// Should not contain non-job resources
expect($content)->not->toContain('## Admin & Management');
});
test('GetQBCoreResourceList filters by category - Crime & Robberies', function () {
$tool = new GetQBCoreResourceList;
$request = new Request(['category' => 'Crime & Robberies']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('qb-bankrobbery');
expect($content)->toContain('qb-drugs');
expect($content)->toContain('qb-weed');
});
test('GetQBCoreResourceList filters by category - Admin & Management', function () {
$tool = new GetQBCoreResourceList;
$request = new Request(['category' => 'Admin & Management']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('qb-adminmenu');
});
test('GetQBCoreResourceList filters by category - UI & Interface', function () {
$tool = new GetQBCoreResourceList;
$request = new Request(['category' => 'UI & Interface']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('qb-hud');
expect($content)->toContain('qb-menu');
expect($content)->toContain('qb-target');
});
test('GetQBCoreResourceList filters by category - Housing & Interiors', function () {
$tool = new GetQBCoreResourceList;
$request = new Request(['category' => 'Housing & Interiors']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('qb-apartments');
expect($content)->toContain('qb-houses');
expect($content)->toContain('qb-interior');
});
test('GetQBCoreResourceList contains documentation links', function () {
$tool = new GetQBCoreResourceList;
$request = new Request([]);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('https://docs.qbcore.org/qbcore-documentation/qbcore-resources/');
expect($content)->toContain('View Docs');
});
test('GetQBCoreResourceList has grouped categories', function () {
$tool = new GetQBCoreResourceList;
$request = new Request([]);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('### Admin');
expect($content)->toContain('### Jobs');
expect($content)->toContain('### Crime');
expect($content)->toContain('### Housing');
expect($content)->toContain('### Vehicles');
});
@@ -0,0 +1,138 @@
<?php
use App\Mcp\Tools\QBCore\GetQBCoreResourceReference;
use Laravel\Mcp\Request;
test('GetQBCoreResourceReference returns ambulance job details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-ambulancejob']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Ambulance Job');
expect($content)->toContain('Hospital Check-in System');
expect($content)->toContain('/heal');
expect($content)->toContain('ifaks');
});
test('GetQBCoreResourceReference returns admin menu details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-adminmenu']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Admin Menu');
expect($content)->toContain('/admin');
expect($content)->toContain('/blips');
expect($content)->toContain('Player Management');
});
test('GetQBCoreResourceReference returns hud details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-hud']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('HUD');
expect($content)->toContain('Health Display');
});
test('GetQBCoreResourceReference returns inventory details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-inventory']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Inventory');
expect($content)->toContain('Player Systems');
});
test('GetQBCoreResourceReference returns phone details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-phone']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Phone');
expect($content)->toContain('Messaging');
});
test('GetQBCoreResourceReference returns police job details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-policejob']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Police Job');
expect($content)->toContain('Dispatch System');
});
test('GetQBCoreResourceReference includes documentation URL', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-adminmenu']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('https://docs.qbcore.org/qbcore-documentation/qbcore-resources/qb-adminmenu');
});
test('GetQBCoreResourceReference not found returns helpful message', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-nonexistent']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('not found');
expect($content)->toContain('GetQBCoreResourceList');
});
test('GetQBCoreResourceReference handles case variations', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'QBCore-Ambulancejob']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Ambulance Job');
});
test('GetQBCoreResourceReference returns garages details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-garages']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Garages');
expect($content)->toContain('Transportation');
});
test('GetQBCoreResourceReference returns shops details', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-shops']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('Shops');
expect($content)->toContain('Commerce');
});
test('GetQBCoreResourceReference includes categories', function () {
$tool = new GetQBCoreResourceReference;
$request = new Request(['resource_name' => 'qb-target']);
$response = $tool->handle($request);
$content = (string) $response->content();
expect($content)->toContain('UI & Interface');
expect($content)->toContain('Target System');
});
@@ -0,0 +1,49 @@
<?php
use App\Mcp\Tools\QBCore\Server\GetQBCoreServerEventReference;
use Laravel\Mcp\Request;
it('returns qbcore server event reference', function () {
$tool = new GetQBCoreServerEventReference;
$request = new Request(['event_name' => 'QBCore:Server:PlayerLoaded']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('PlayerLoaded');
});
it('returns not found for invalid server event', function () {
$tool = new GetQBCoreServerEventReference;
$request = new Request(['event_name' => 'InvalidServerEvent']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});
it('lists all server events when empty event name', function () {
$tool = new GetQBCoreServerEventReference;
$request = new Request(['event_name' => '']);
$response = $tool->handle($request);
expect((string) $response->content())->not()->toBeEmpty();
});
it('searches by server event short names', function () {
$tool = new GetQBCoreServerEventReference;
$request = new Request(['event_name' => 'QBCore:Server:PlayerLoaded']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('PlayerLoaded');
});
it('contains examples for server events', function () {
$tool = new GetQBCoreServerEventReference;
$request = new Request(['event_name' => 'QBCore:Server:playerDropped']);
$response = $tool->handle($request);
expect((string) $response->content())->not()->toBeEmpty();
});
@@ -0,0 +1,49 @@
<?php
use App\Mcp\Tools\QBCore\Server\GetQBCoreServerFunction;
use Laravel\Mcp\Request;
it('returns qbcore server function info', function () {
$tool = new GetQBCoreServerFunction;
$request = new Request(['function_name' => 'QBCore.Functions.GetPlayer', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('GetPlayer');
});
it('returns not found for invalid server function', function () {
$tool = new GetQBCoreServerFunction;
$request = new Request(['function_name' => 'InvalidQBFunction', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});
it('supports javascript examples for server functions', function () {
$tool = new GetQBCoreServerFunction;
$request = new Request(['function_name' => 'AddMoney', 'language' => 'js']);
$response = $tool->handle($request);
expect((string) $response->content())->not()->toBeEmpty();
});
it('handles case insensitive server function names', function () {
$tool = new GetQBCoreServerFunction;
$request = new Request(['function_name' => 'addmoney', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('AddMoney');
});
it('includes player data structure', function () {
$tool = new GetQBCoreServerFunction;
$request = new Request(['function_name' => 'GetMoney', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('GetMoney');
});
@@ -0,0 +1,85 @@
<?php
use App\Mcp\Tools\QBCore\GetQBCoreSharedData;
use Laravel\Mcp\Request;
test('GetQBCoreSharedData returns Items data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'Items', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Items');
expect((string) $response->content())->toContain('label');
expect((string) $response->content())->toContain('weight');
});
test('GetQBCoreSharedData returns Jobs data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'Jobs', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Jobs');
expect((string) $response->content())->toContain('grades');
expect((string) $response->content())->toContain('Lua Example');
});
test('GetQBCoreSharedData returns Gangs data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'Gangs', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Gangs');
});
test('GetQBCoreSharedData returns Vehicles data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'Vehicles', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Vehicles');
expect((string) $response->content())->toContain('model');
expect((string) $response->content())->toContain('price');
});
test('GetQBCoreSharedData returns Weapons data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'Weapons', 'language' => 'js']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Weapons');
expect((string) $response->content())->toContain('JavaScript Example');
});
test('GetQBCoreSharedData returns StarterItems data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'StarterItems', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('StarterItems');
});
test('GetQBCoreSharedData returns Utilities data', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'Utilities', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('Utilities');
expect((string) $response->content())->toContain('RandomStr');
expect((string) $response->content())->toContain('Trim');
});
test('GetQBCoreSharedData returns not found for invalid type', function () {
$tool = new GetQBCoreSharedData;
$request = new Request(['data_type' => 'InvalidType', 'language' => 'lua']);
$response = $tool->handle($request);
expect((string) $response->content())->toContain('not found');
});