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
This commit is contained in:
@@ -101,4 +101,55 @@ class {{CONTROLLER_NAME}}ControllerTest extends TestCase
|
||||
// Assert
|
||||
$this->assertResponseOk(); // Renders form view with errors
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method with non-existent ID (404 Not Found)
|
||||
*/
|
||||
public function testViewNotFound(): void
|
||||
{
|
||||
// Act
|
||||
$this->get('/{{ROUTE_PATH}}/view/99999');
|
||||
|
||||
// Assert
|
||||
$this->assertResponseError();
|
||||
$this->assertResponseCode(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit method POST with valid data
|
||||
*/
|
||||
public function testEditSuccess(): void
|
||||
{
|
||||
// Arrange
|
||||
$this->enableCsrfToken();
|
||||
$this->enableSecurityToken();
|
||||
|
||||
$data = [
|
||||
'name' => 'Updated Item',
|
||||
];
|
||||
|
||||
// Act
|
||||
$this->post('/{{ROUTE_PATH}}/edit/1', $data);
|
||||
|
||||
// Assert
|
||||
$this->assertResponseSuccess();
|
||||
$this->assertRedirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete method POST/DELETE
|
||||
*/
|
||||
public function testDeleteSuccess(): void
|
||||
{
|
||||
// Arrange
|
||||
$this->enableCsrfToken();
|
||||
$this->enableSecurityToken();
|
||||
|
||||
// Act
|
||||
$this->delete('/{{ROUTE_PATH}}/delete/1');
|
||||
|
||||
// Assert
|
||||
$this->assertResponseSuccess();
|
||||
$this->assertRedirect(['action' => 'index']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +68,7 @@ class {{ENTITY_NAME}}Test extends TestCase
|
||||
]);
|
||||
|
||||
// Act & Assert
|
||||
if ($this->{{VARIABLE_NAME}}->has('full_name')) {
|
||||
$this->assertSame('John Doe', $this->{{VARIABLE_NAME}}->full_name);
|
||||
} else {
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
$fullName = $this->{{VARIABLE_NAME}}->full_name ?? ($this->{{VARIABLE_NAME}}->first_name . ' ' . $this->{{VARIABLE_NAME}}->last_name);
|
||||
$this->assertSame('John Doe', $fullName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +121,8 @@ class {{TABLE_NAME}}TableTest extends TestCase
|
||||
]);
|
||||
$result = $this->{{VARIABLE_NAME}}->save($entity2);
|
||||
|
||||
// Assert - Rule should fail if unique rule exists
|
||||
if (!empty($entity2->getErrors())) {
|
||||
$this->assertFalse($result);
|
||||
} else {
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
// Assert - Rule should fail when duplicate unique field is saved
|
||||
$this->assertFalse($result);
|
||||
$this->assertNotEmpty($entity2->getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user