Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/Feature/BoostServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
$provider->register();
$provider->boot(app('router'));

expect(app()->bound(Laravel\Roster\Roster::class))->toBeTrue();
expect(config('logging.channels.browser'))->not->toBeNull();
expect(app()->bound(Laravel\Roster\Roster::class))->toBeTrue()
->and(config('logging.channels.browser'))->not->toBeNull();
});
});

Expand Down
18 changes: 9 additions & 9 deletions tests/Feature/Mcp/ToolExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
expect(false)->toBeTrue("Tool execution failed with error: {$errorText}");
}

expect($result->isError)->toBeFalse();
expect($result->content)->toBeArray();
expect($result->isError)->toBeFalse()
->and($result->content)->toBeArray();

// The content should contain the app name (which should be "Laravel" in testbench)
$textContent = $result->content[0]->text ?? '';
Expand All @@ -64,15 +64,15 @@
$result1 = $executor->execute(Tinker::class, ['code' => 'return getmypid();']);
$result2 = $executor->execute(Tinker::class, ['code' => 'return getmypid();']);

expect($result1->isError)->toBeFalse();
expect($result2->isError)->toBeFalse();
expect($result1->isError)->toBeFalse()
->and($result2->isError)->toBeFalse();

$pid1 = json_decode($result1->content[0]->text, true)['result'];
$pid2 = json_decode($result2->content[0]->text, true)['result'];

expect($pid1)->toBeInt()->not->toBe(getmypid());
expect($pid2)->toBeInt()->not->toBe(getmypid());
expect($pid1)->not()->toBe($pid2);
expect($pid1)->toBeInt()->not->toBe(getmypid())
->and($pid2)->toBeInt()->not->toBe(getmypid())
->and($pid1)->not()->toBe($pid2);
});

test('subprocess sees modified autoloaded code changes', function () {
Expand Down Expand Up @@ -110,8 +110,8 @@
$result2 = $executor->execute(GetConfig::class, ['key' => 'app.name']);
$response2 = json_decode($result2->content[0]->text, true);

expect($result2->isError)->toBeFalse();
expect($response2['value'])->toBe('MODIFIED_BY_TEST'); // Using updated code, not cached
expect($result2->isError)->toBeFalse()
->and($response2['value'])->toBe('MODIFIED_BY_TEST'); // Using updated code, not cached
} finally {
$cleanup();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Mcp/ToolRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
});

test('can check if tool is allowed', function () {
expect(ToolRegistry::isToolAllowed(ApplicationInfo::class))->toBeTrue();
expect(ToolRegistry::isToolAllowed('NonExistentTool'))->toBeFalse();
expect(ToolRegistry::isToolAllowed(ApplicationInfo::class))->toBeTrue()
->and(ToolRegistry::isToolAllowed('NonExistentTool'))->toBeFalse();
});

test('can get tool names', function () {
Expand Down
44 changes: 22 additions & 22 deletions tests/Feature/Mcp/Tools/ApplicationInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@
expect($data['isError'])->toBeFalse();

$content = json_decode($data['content'][0]['text'], true);
expect($content['php_version'])->toBe(PHP_VERSION);
expect($content['laravel_version'])->toBe(app()->version());
expect($content['database_engine'])->toBe(config('database.default'));
expect($content['packages'])->toHaveCount(2);
expect($content['packages'][0]['roster_name'])->toBe('LARAVEL');
expect($content['packages'][0]['package_name'])->toBe('laravel/framework');
expect($content['packages'][0]['version'])->toBe('11.0.0');
expect($content['packages'][1]['roster_name'])->toBe('PEST');
expect($content['packages'][1]['package_name'])->toBe('pestphp/pest');
expect($content['packages'][1]['version'])->toBe('2.0.0');
expect($content['models'])->toBeArray();
expect($content['models'])->toHaveCount(2);
expect($content['models'])->toContain('App\\Models\\User');
expect($content['models'])->toContain('App\\Models\\Post');
expect($content['php_version'])->toBe(PHP_VERSION)
->and($content['laravel_version'])->toBe(app()->version())
->and($content['database_engine'])->toBe(config('database.default'))
->and($content['packages'])->toHaveCount(2)
->and($content['packages'][0]['roster_name'])->toBe('LARAVEL')
->and($content['packages'][0]['package_name'])->toBe('laravel/framework')
->and($content['packages'][0]['version'])->toBe('11.0.0')
->and($content['packages'][1]['roster_name'])->toBe('PEST')
->and($content['packages'][1]['package_name'])->toBe('pestphp/pest')
->and($content['packages'][1]['version'])->toBe('2.0.0')
->and($content['models'])->toBeArray()
->and($content['models'])->toHaveCount(2)
->and($content['models'])->toContain('App\\Models\\User')
->and($content['models'])->toContain('App\\Models\\Post');
});

test('it returns application info with no packages', function () {
Expand All @@ -60,17 +60,17 @@
$tool = new ApplicationInfo($roster, $guidelineAssist);
$result = $tool->handle([]);

expect($result)->toBeInstanceOf(ToolResult::class);
expect($result)->toBeInstanceOf(ToolResult::class);
expect($result)->toBeInstanceOf(ToolResult::class)
->and($result)->toBeInstanceOf(ToolResult::class);

$data = $result->toArray();
expect($data['isError'])->toBeFalse();

$content = json_decode($data['content'][0]['text'], true);
expect($content['php_version'])->toBe(PHP_VERSION);
expect($content['laravel_version'])->toBe(app()->version());
expect($content['database_engine'])->toBe(config('database.default'));
expect($content['packages'])->toHaveCount(0);
expect($content['models'])->toBeArray();
expect($content['models'])->toHaveCount(0);
expect($content['php_version'])->toBe(PHP_VERSION)
->and($content['laravel_version'])->toBe(app()->version())
->and($content['database_engine'])->toBe(config('database.default'))
->and($content['packages'])->toHaveCount(0)
->and($content['models'])->toBeArray()
->and($content['models'])->toHaveCount(0);
});
51 changes: 26 additions & 25 deletions tests/Feature/Mcp/Tools/BrowserLogsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
expect($result)->toBeInstanceOf(ToolResult::class);

$data = $result->toArray();
expect($data['isError'])->toBeFalse();
expect($data['content'][0]['type'])->toBe('text');
expect($data['isError'])->toBeFalse()
->and($data['content'][0]['type'])->toBe('text');

$text = $data['content'][0]['text'];
expect($text)->toContain('browser.WARNING: Warning message');
expect($text)->toContain('browser.ERROR: JavaScript error occurred');
expect($text)->not->toContain('browser.DEBUG: console log message');
expect($text)->toContain('browser.WARNING: Warning message')
->and($text)->toContain('browser.ERROR: JavaScript error occurred')
->and($text)->not->toContain('browser.DEBUG: console log message');
});

test('it returns error when entries argument is invalid', function () {
Expand All @@ -56,16 +56,16 @@
expect($result)->toBeInstanceOf(ToolResult::class);

$data = $result->toArray();
expect($data['isError'])->toBeTrue();
expect($data['content'][0]['text'])->toBe('The "entries" argument must be greater than 0.');
expect($data['isError'])->toBeTrue()
->and($data['content'][0]['text'])->toBe('The "entries" argument must be greater than 0.');

// Test with negative
$result = $tool->handle(['entries' => -5]);
expect($result)->toBeInstanceOf(ToolResult::class);

$data = $result->toArray();
expect($data['isError'])->toBeTrue();
expect($data['content'][0]['text'])->toBe('The "entries" argument must be greater than 0.');
expect($data['isError'])->toBeTrue()
->and($data['content'][0]['text'])->toBe('The "entries" argument must be greater than 0.');
});

test('it returns error when log file does not exist', function () {
Expand All @@ -75,8 +75,8 @@
expect($result)->toBeInstanceOf(ToolResult::class);

$data = $result->toArray();
expect($data['isError'])->toBeTrue();
expect($data['content'][0]['text'])->toBe('No log file found, probably means no logs yet.');
expect($data['isError'])->toBeTrue()
->and($data['content'][0]['text'])->toBe('No log file found, probably means no logs yet.');
});

test('it returns error when log file is empty', function () {
Expand All @@ -91,8 +91,8 @@
expect($result)->toBeInstanceOf(ToolResult::class);

$data = $result->toArray();
expect($data['isError'])->toBeFalse();
expect($data['content'][0]['text'])->toBe('Unable to retrieve log entries, or no logs');
expect($data['isError'])->toBeFalse()
->and($data['content'][0]['text'])->toBe('Unable to retrieve log entries, or no logs');
});

test('@boostJs blade directive renders browser logger script', function () {
Expand All @@ -106,11 +106,11 @@

// Test that the script contains expected content
$script = BrowserLogger::getScript();
expect($script)->toContain('browser-logger-active');
expect($script)->toContain('/_boost/browser-logs');
expect($script)->toContain('console.log');
expect($script)->toContain('console.error');
expect($script)->toContain('window.onerror');
expect($script)->toContain('browser-logger-active')
->and($script)->toContain('/_boost/browser-logs')
->and($script)->toContain('console.log')
->and($script)->toContain('console.error')
->and($script)->toContain('window.onerror');
});

test('browser logs endpoint processes logs correctly', function () {
Expand Down Expand Up @@ -215,9 +215,10 @@
});

$content = $result->getContent();
expect($content)->toContain('browser-logger-active');
expect($content)->toContain('</head>');
expect(substr_count($content, 'browser-logger-active'))->toBe(1); // Should not inject twice
expect($content)->toContain('browser-logger-active')
->and($content)->toContain('</head>')
->and(substr_count($content, 'browser-logger-active'))->toBe(1);
// Should not inject twice
});

test('InjectBoost middleware does not inject into non-HTML responses', function () {
Expand All @@ -233,8 +234,8 @@
});

$content = $result->getContent();
expect($content)->toBe($json);
expect($content)->not->toContain('browser-logger-active');
expect($content)->toBe($json)
->and($content)->not->toContain('browser-logger-active');
});

test('InjectBoost middleware does not inject script twice', function () {
Expand Down Expand Up @@ -284,6 +285,6 @@
});

$content = $result->getContent();
expect($content)->toContain('browser-logger-active');
expect($content)->toMatch('/<script[^>]*browser-logger-active[^>]*>.*<\/script>\s*<\/body>/s');
expect($content)->toContain('browser-logger-active')
->and($content)->toMatch('/<script[^>]*browser-logger-active[^>]*>.*<\/script>\s*<\/body>/s');
});
14 changes: 7 additions & 7 deletions tests/Feature/Mcp/Tools/DatabaseConnectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
expect($data['isError'])->toBe(false);

$content = json_decode($data['content'][0]['text'], true);
expect($content['default_connection'])->toBe('mysql');
expect($content['connections'])->toHaveCount(3);
expect($content['connections'])->toContain('mysql');
expect($content['connections'])->toContain('pgsql');
expect($content['connections'])->toContain('sqlite');
expect($content['default_connection'])->toBe('mysql')
->and($content['connections'])->toHaveCount(3)
->and($content['connections'])->toContain('mysql')
->and($content['connections'])->toContain('pgsql')
->and($content['connections'])->toContain('sqlite');
});

test('it returns empty connections when none configured', function () {
Expand All @@ -41,6 +41,6 @@
expect($data['isError'])->toBe(false);

$content = json_decode($data['content'][0]['text'], true);
expect($content['default_connection'])->toBe('mysql');
expect($content['connections'])->toHaveCount(0);
expect($content['default_connection'])->toBe('mysql')
->and($content['connections'])->toHaveCount(0);
});
49 changes: 23 additions & 26 deletions tests/Feature/Mcp/Tools/DatabaseSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,27 @@

$schemaArray = json_decode($responseArray['content'][0]['text'], true);

expect($schemaArray)->toHaveKey('engine');
expect($schemaArray['engine'])->toBe('sqlite');

expect($schemaArray)->toHaveKey('tables');
expect($schemaArray['tables'])->toHaveKey('examples');
expect($schemaArray)->toHaveKey('engine')
->and($schemaArray['engine'])->toBe('sqlite')
->and($schemaArray)->toHaveKey('tables')
->and($schemaArray['tables'])->toHaveKey('examples');

$exampleTable = $schemaArray['tables']['examples'];
expect($exampleTable)->toHaveKey('columns');
expect($exampleTable['columns'])->toHaveKey('id');
expect($exampleTable['columns'])->toHaveKey('name');

expect($exampleTable['columns']['id']['type'])->toBe('integer');
expect($exampleTable['columns']['name']['type'])->toBe('varchar');

expect($exampleTable)->toHaveKey('indexes');
expect($exampleTable)->toHaveKey('foreign_keys');
expect($exampleTable)->toHaveKey('triggers');
expect($exampleTable)->toHaveKey('check_constraints');

expect($schemaArray)->toHaveKey('global');
expect($schemaArray['global'])->toHaveKey('views');
expect($schemaArray['global'])->toHaveKey('stored_procedures');
expect($schemaArray['global'])->toHaveKey('functions');
expect($schemaArray['global'])->toHaveKey('sequences');
expect($exampleTable)->toHaveKey('columns')
->and($exampleTable['columns'])->toHaveKey('id')
->and($exampleTable['columns'])->toHaveKey('name')
->and($exampleTable['columns']['id']['type'])->toBe('integer')
->and($exampleTable['columns']['name']['type'])->toBe('varchar')
->and($exampleTable)->toHaveKey('indexes')
->and($exampleTable)->toHaveKey('foreign_keys')
->and($exampleTable)->toHaveKey('triggers')
->and($exampleTable)->toHaveKey('check_constraints')
->and($schemaArray)->toHaveKey('global')
->and($schemaArray['global'])->toHaveKey('views')
->and($schemaArray['global'])->toHaveKey('stored_procedures')
->and($schemaArray['global'])->toHaveKey('functions')
->and($schemaArray['global'])->toHaveKey('sequences');

});

test('it filters tables by name', function () {
Expand All @@ -84,14 +81,14 @@
$responseArray = $response->toArray();
$schemaArray = json_decode($responseArray['content'][0]['text'], true);

expect($schemaArray['tables'])->toHaveKey('examples');
expect($schemaArray['tables'])->not->toHaveKey('users');
expect($schemaArray['tables'])->toHaveKey('examples')
->and($schemaArray['tables'])->not->toHaveKey('users');

// Test filtering for 'user'
$response = $tool->handle(['filter' => 'user']);
$responseArray = $response->toArray();
$schemaArray = json_decode($responseArray['content'][0]['text'], true);

expect($schemaArray['tables'])->toHaveKey('users');
expect($schemaArray['tables'])->not->toHaveKey('examples');
expect($schemaArray['tables'])->toHaveKey('users')
->and($schemaArray['tables'])->not->toHaveKey('examples');
});
20 changes: 10 additions & 10 deletions tests/Feature/Mcp/Tools/GetAbsoluteUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

expect($result)->toBeInstanceOf(ToolResult::class);
$data = $result->toArray();
expect($data['isError'])->toBe(false);
expect($data['content'][0]['text'])->toBe('http://localhost');
expect($data['isError'])->toBe(false)
->and($data['content'][0]['text'])->toBe('http://localhost');
});

test('it returns absolute url for given path', function () {
Expand All @@ -29,8 +29,8 @@

expect($result)->toBeInstanceOf(ToolResult::class);
$data = $result->toArray();
expect($data['isError'])->toBe(false);
expect($data['content'][0]['text'])->toBe('http://localhost/dashboard');
expect($data['isError'])->toBe(false)
->and($data['content'][0]['text'])->toBe('http://localhost/dashboard');
});

test('it returns absolute url for named route', function () {
Expand All @@ -39,8 +39,8 @@

expect($result)->toBeInstanceOf(ToolResult::class);
$data = $result->toArray();
expect($data['isError'])->toBe(false);
expect($data['content'][0]['text'])->toBe('http://localhost/test');
expect($data['isError'])->toBe(false)
->and($data['content'][0]['text'])->toBe('http://localhost/test');
});

test('it prioritizes path over route when both are provided', function () {
Expand All @@ -49,8 +49,8 @@

expect($result)->toBeInstanceOf(ToolResult::class);
$data = $result->toArray();
expect($data['isError'])->toBe(false);
expect($data['content'][0]['text'])->toBe('http://localhost/dashboard');
expect($data['isError'])->toBe(false)
->and($data['content'][0]['text'])->toBe('http://localhost/dashboard');
});

test('it handles empty path', function () {
Expand All @@ -59,6 +59,6 @@

expect($result)->toBeInstanceOf(ToolResult::class);
$data = $result->toArray();
expect($data['isError'])->toBe(false);
expect($data['content'][0]['text'])->toBe('http://localhost');
expect($data['isError'])->toBe(false)
->and($data['content'][0]['text'])->toBe('http://localhost');
});
Loading