da1bd48444
- 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
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use {{TargetClassFullName}};
|
|
|
|
beforeEach(function () {
|
|
$this->dependencyMock = Mockery::mock('DependencyInterface');
|
|
$this->service = new {{ClassName}}($this->dependencyMock);
|
|
});
|
|
|
|
describe('{{ClassName}}', function () {
|
|
it('executes successfully with valid input', function () {
|
|
// Arrange
|
|
$input = 'sample_input';
|
|
$expectedResult = 'success_result';
|
|
|
|
$this->dependencyMock
|
|
->shouldReceive('execute')
|
|
->once()
|
|
->with($input)
|
|
->andReturn($expectedResult);
|
|
|
|
// Act
|
|
$result = $this->service->process($input);
|
|
|
|
// Assert
|
|
expect($result)->toBe($expectedResult);
|
|
});
|
|
|
|
it('handles edge case input properly', function () {
|
|
// Arrange
|
|
$this->dependencyMock
|
|
->shouldReceive('execute')
|
|
->once()
|
|
->with('')
|
|
->andReturn('default_output');
|
|
|
|
// Act & Assert
|
|
expect($this->service->process(''))->toBe('default_output');
|
|
});
|
|
|
|
it('throws exception when dependency throws error', function () {
|
|
$this->dependencyMock
|
|
->shouldReceive('execute')
|
|
->once()
|
|
->andThrow(new \RuntimeException('Execution failed'));
|
|
|
|
expect(fn () => $this->service->process('error_trigger'))
|
|
->toThrow(\RuntimeException::class, 'Execution failed');
|
|
});
|
|
});
|