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:
25 files changed
+1188
No files matched your search
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\GenerateManifest;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('generate manifest returns response with content', function () {
|
||||
$tool = new GenerateManifest;
|
||||
$request = new Request(['resource_name' => 'test-resource']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('generate manifest includes required fields', function () {
|
||||
$tool = new GenerateManifest;
|
||||
$request = new Request(['resource_name' => 'my-test-resource']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain("fx_version 'cerulean'");
|
||||
expect($content)->toContain("game 'gta5'");
|
||||
expect($content)->toContain("lua54 'yes'");
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\GenerateResourceBoilerplate;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('generate resource boilerplate returns response with content', function () {
|
||||
$tool = new GenerateResourceBoilerplate;
|
||||
$request = new Request(['resource_name' => 'test-resource']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('generate resource boilerplate includes resource name', function () {
|
||||
$tool = new GenerateResourceBoilerplate;
|
||||
$request = new Request(['resource_name' => 'my-boilerplate']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('my-boilerplate') || expect($content)->toContain('boilerplate') || expect($content)->not()->toBeEmpty();
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\Client\GetEventClientReference;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('returns client event reference', function () {
|
||||
$tool = new GetEventClientReference;
|
||||
$request = new Request(['event_name' => 'onResourceStart']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('onResourceStart');
|
||||
});
|
||||
|
||||
it('returns not found for invalid event', function () {
|
||||
$tool = new GetEventClientReference;
|
||||
$request = new Request(['event_name' => 'InvalidEvent']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('not found');
|
||||
});
|
||||
|
||||
it('lists all client events when empty event name', function () {
|
||||
$tool = new GetEventClientReference;
|
||||
$request = new Request(['event_name' => '']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
|
||||
it('handles case insensitive event names', function () {
|
||||
$tool = new GetEventClientReference;
|
||||
$request = new Request(['event_name' => 'onresourcestart']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('onResourceStart');
|
||||
});
|
||||
|
||||
it('contains lua examples', function () {
|
||||
$tool = new GetEventClientReference;
|
||||
$request = new Request(['event_name' => 'onResourceStart']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\Server\GetEventServerReference;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('returns server event reference', function () {
|
||||
$tool = new GetEventServerReference;
|
||||
$request = new Request(['event_name' => 'playerConnecting']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('playerConnecting');
|
||||
});
|
||||
|
||||
it('returns not found for invalid server event', function () {
|
||||
$tool = new GetEventServerReference;
|
||||
$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 GetEventServerReference;
|
||||
$request = new Request(['event_name' => '']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
|
||||
it('handles case insensitive server event names', function () {
|
||||
$tool = new GetEventServerReference;
|
||||
$request = new Request(['event_name' => 'playerdropped']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('playerDropped');
|
||||
});
|
||||
|
||||
it('contains examples for server events', function () {
|
||||
$tool = new GetEventServerReference;
|
||||
$request = new Request(['event_name' => 'playerConnecting']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\Client\GetNativeClientFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('returns client native function info', function () {
|
||||
$tool = new GetNativeClientFunction;
|
||||
$request = new Request(['function_name' => 'PlayerPedId', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('PlayerPedId');
|
||||
});
|
||||
|
||||
it('returns not found for invalid function', function () {
|
||||
$tool = new GetNativeClientFunction;
|
||||
$request = new Request(['function_name' => 'InvalidFunction', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('not found');
|
||||
});
|
||||
|
||||
it('supports javascript examples', function () {
|
||||
$tool = new GetNativeClientFunction;
|
||||
$request = new Request(['function_name' => 'GetEntityCoords', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('js');
|
||||
});
|
||||
|
||||
it('handles case insensitive function names', function () {
|
||||
$tool = new GetNativeClientFunction;
|
||||
$request = new Request(['function_name' => 'playerpedid', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('PlayerPedId');
|
||||
});
|
||||
|
||||
it('lists all client functions when no name provided', function () {
|
||||
$tool = new GetNativeClientFunction;
|
||||
$request = new Request(['function_name' => '', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\Server\GetNativeServerFunction;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('returns server native function info', function () {
|
||||
$tool = new GetNativeServerFunction;
|
||||
$request = new Request(['function_name' => 'TriggerClientEvent', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('TriggerClientEvent');
|
||||
});
|
||||
|
||||
it('returns not found for invalid function', function () {
|
||||
$tool = new GetNativeServerFunction;
|
||||
$request = new Request(['function_name' => 'InvalidServerFunction', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('not found');
|
||||
});
|
||||
|
||||
it('supports javascript examples for server natives', function () {
|
||||
$tool = new GetNativeServerFunction;
|
||||
$request = new Request(['function_name' => 'GetPlayerName', 'language' => 'js']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
|
||||
it('handles case insensitive server function names', function () {
|
||||
$tool = new GetNativeServerFunction;
|
||||
$request = new Request(['function_name' => 'getplayername', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->toContain('GetPlayerName');
|
||||
});
|
||||
|
||||
it('lists all server functions when no name provided', function () {
|
||||
$tool = new GetNativeServerFunction;
|
||||
$request = new Request(['function_name' => '', 'language' => 'lua']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect((string) $response->content())->not()->toBeEmpty();
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use App\Mcp\Tools\FiveM\SearchFiveMDocs;
|
||||
use Laravel\Mcp\Request;
|
||||
|
||||
it('search fivem docs returns response with content', function () {
|
||||
$tool = new SearchFiveMDocs;
|
||||
$request = new Request(['query' => 'networking']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
|
||||
expect($response)->not()->toBeNull();
|
||||
expect($response->content())->not()->toBeNull();
|
||||
});
|
||||
|
||||
it('search fivem docs handles empty results', function () {
|
||||
$tool = new SearchFiveMDocs;
|
||||
$request = new Request(['query' => 'nonexistent_topic_xyz']);
|
||||
|
||||
$response = $tool->handle($request);
|
||||
$content = (string) $response->content();
|
||||
|
||||
expect($content)->toContain('No documentation found');
|
||||
});
|
||||
Reference in new issue
Block a user