7425b263d5
- 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
56 lines
1.2 KiB
PHP
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);
|
|
}
|
|
}
|