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,75 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\TestCase\Form;
|
||||
|
||||
use App\Form\{{FORM_NAME}}Form;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* App\Form\{{FORM_NAME}}Form Test Case
|
||||
*/
|
||||
class {{FORM_NAME}}FormTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \App\Form\{{FORM_NAME}}Form
|
||||
*/
|
||||
protected {{FORM_NAME}}Form ${{VARIABLE_NAME}};
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->{{VARIABLE_NAME}} = new {{FORM_NAME}}Form();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->{{VARIABLE_NAME}});
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validationDefault with valid data
|
||||
*/
|
||||
public function testValidationSuccess(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = [
|
||||
'email' => 'user@example.com',
|
||||
'message' => 'Hello World',
|
||||
];
|
||||
|
||||
// Act
|
||||
$isValid = $this->{{VARIABLE_NAME}}->validate($data);
|
||||
|
||||
// Assert
|
||||
$this->assertTrue($isValid);
|
||||
$this->assertEmpty($this->{{VARIABLE_NAME}}->getErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test execute method
|
||||
*/
|
||||
public function testExecuteSuccess(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = [
|
||||
'email' => 'user@example.com',
|
||||
'message' => 'Hello World',
|
||||
];
|
||||
|
||||
// Act
|
||||
$result = $this->{{VARIABLE_NAME}}->execute($data);
|
||||
|
||||
// Assert
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user