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
67 lines
1.3 KiB
PHP
67 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Test\TestCase\Service;
|
|
|
|
use App\Service\{{SERVICE_NAME}}Service;
|
|
use Cake\TestSuite\TestCase;
|
|
|
|
/**
|
|
* App\Service\{{SERVICE_NAME}}Service Test Case
|
|
*/
|
|
class {{SERVICE_NAME}}ServiceTest extends TestCase
|
|
{
|
|
/**
|
|
* Test subject
|
|
*
|
|
* @var \App\Service\{{SERVICE_NAME}}Service
|
|
*/
|
|
protected {{SERVICE_NAME}}Service ${{VARIABLE_NAME}};
|
|
|
|
/**
|
|
* setUp method
|
|
*/
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
// Arrange dependencies
|
|
$this->{{VARIABLE_NAME}} = new {{SERVICE_NAME}}Service();
|
|
}
|
|
|
|
/**
|
|
* tearDown method
|
|
*/
|
|
protected function tearDown(): void
|
|
{
|
|
unset($this->{{VARIABLE_NAME}});
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* Test execution success (Happy Path)
|
|
*/
|
|
public function testExecuteSuccess(): void
|
|
{
|
|
// Arrange
|
|
$input = 'sample_input';
|
|
|
|
// Act
|
|
$result = $this->{{VARIABLE_NAME}}->execute($input);
|
|
|
|
// Assert
|
|
$this->assertNotNull($result);
|
|
}
|
|
|
|
/**
|
|
* Test execution with invalid input (Exception Path)
|
|
*/
|
|
public function testExecuteThrowsExceptionOnInvalidInput(): void
|
|
{
|
|
// Assert
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
// Act
|
|
$this->{{VARIABLE_NAME}}->execute('');
|
|
}
|
|
}
|