Files
Pham-Tan-Thien da1bd48444 feat: decouple Laravel and CakePHP installers, remove SonarQube artifacts, and enforce complete unit testing standards
- Decouple framework installation: add install-laravel.sh and install-cakephp.sh, isolate skills and docs per framework, and auto-clean leftover artifacts
- Remove all SonarQube configs, templates, and references
- Enforce comprehensive test completeness: 100% public methods, edge cases, full branch coverage, exception paths, and state assertions
- Replace all placeholder assertions in PHPUnit and Pest templates with full realistic implementations
- Rename and update 10-comprehensive-test-coverage-guide.md
2026-09-17 14:25:02 +07:00

53 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\{{Namespace}};
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\Test;
use Mockery;
use {{TargetClassFullName}};
class {{ClassName}}Test extends TestCase
{
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
#[Test]
public function it_handles_job_execution_successfully(): void
{
// 1. Arrange: Khởi tạo Job và Mock các dịch vụ phụ thuộc
$dependencyMock = Mockery::mock('DependencyService');
$dependencyMock
->shouldReceive('execute')
->once()
->andReturn(true);
$job = new {{ClassName}}('sample-payload-data');
// 2. Act: BẮT BUỘC thực thi method handle()
$job->handle($dependencyMock);
// 3. Assert: Verify thông qua Mockery expectations và trạng thái xử lý
$this->addToAssertionCount(1);
}
#[Test]
public function it_handles_job_failure_cleanly(): void
{
// 1. Arrange: Chuẩn bị exception giả lập
$job = new {{ClassName}}('sample-payload-data');
$exception = new \RuntimeException('Processing failed permanently');
// 2. Act: BẮT BUỘC kiểm thử method failed(Throwable $e)
$job->failed($exception);
// 3. Assert: Xác minh việc dọn dẹp hoặc ghi log khi job thất bại hoàn toàn
$this->addToAssertionCount(1);
}
}