Files
agent-unit-testing/templates/cakephp/phpunit/ComponentTest.template.php
T
Pham-Tan-Thien 7425b263d5 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
2026-09-14 10:19:40 +07:00

56 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller\Component;
use App\Controller\Component\{{COMPONENT_NAME}}Component;
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Http\ServerRequest;
use Cake\TestSuite\TestCase;
/**
* App\Controller\Component\{{COMPONENT_NAME}}Component Test Case
*/
class {{COMPONENT_NAME}}ComponentTest extends TestCase
{
/**
* Test subject
*
* @var \App\Controller\Component\{{COMPONENT_NAME}}Component
*/
protected {{COMPONENT_NAME}}Component ${{VARIABLE_NAME}};
/**
* setUp method
*/
protected function setUp(): void
{
parent::setUp();
$controller = new Controller(new ServerRequest());
$registry = new ComponentRegistry($controller);
$this->{{VARIABLE_NAME}} = new {{COMPONENT_NAME}}Component($registry);
}
/**
* tearDown method
*/
protected function tearDown(): void
{
unset($this->{{VARIABLE_NAME}});
parent::tearDown();
}
/**
* Test basic method
*/
public function testDoActionSuccess(): void
{
// Act
$result = $this->{{VARIABLE_NAME}}->doAction();
// Assert
$this->assertTrue($result);
}
}