feat: add comprehensive unit testing support for CakePHP
- Add 4 CakePHP Claude Code skills: cakephp-unit-test, cakephp-test-setup, cakephp-test-review, cakephp-mock-helper - Add 11 CakePHP PHPUnit component templates (Table, Entity, Controller, Service, Command, Component, Middleware, Mailer, Form, Behavior, Helper) - Add CakePHP configs (phpunit.xml.dist, app_local.test.php for SQLite in-memory) - Add comprehensive CakePHP documentation and component guides - Update test-runner.sh and installer to auto-detect Laravel and CakePHP - Add CakePHP CI/CD templates for GitHub Actions and GitLab CI - Update system prompt, verification checklist, and README with dedicated guides
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\TestCase\Middleware;
|
||||
|
||||
use App\Middleware\{{MIDDLEWARE_NAME}}Middleware;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Http\ServerRequest;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use TestApp\Http\TestRequestHandler;
|
||||
|
||||
/**
|
||||
* App\Middleware\{{MIDDLEWARE_NAME}}Middleware Test Case
|
||||
*/
|
||||
class {{MIDDLEWARE_NAME}}MiddlewareTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test process method
|
||||
*/
|
||||
public function testProcess(): void
|
||||
{
|
||||
// Arrange
|
||||
$middleware = new {{MIDDLEWARE_NAME}}Middleware();
|
||||
$request = new ServerRequest(['url' => '/test-path']);
|
||||
|
||||
$handler = new class implements \Psr\Http\Server\RequestHandlerInterface {
|
||||
public function handle(\Psr\Http\Message\ServerRequestInterface $request): \Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
$response = $middleware->process($request, $handler);
|
||||
|
||||
// Assert
|
||||
$this->assertInstanceOf(\Psr\Http\Message\ResponseInterface::class, $response);
|
||||
$this->assertSame(200, $response->getStatusCode());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user