Add code coverage configuration (phpunit.xml source filter), baseline coverage report (21.27% lines), gitignore coverage/ and .phpunit.result.cache; remove deprecated setAccessible() calls

This commit is contained in:
Pontoporeia
2026-05-20 02:03:55 +02:00
parent a047062d87
commit a6e0aa5887
9 changed files with 17 additions and 14 deletions

4
.gitignore vendored
View File

@@ -44,3 +44,7 @@ Thumbs.db
# PHP CS Fixer cache
.php-cs-fixer.cache
# PHPUnit
.phpunit.result.cache
coverage/

File diff suppressed because one or more lines are too long

View File

@@ -29,8 +29,8 @@
- [x] 4.2 Verify all pass under `vendor/bin/phpunit`
- [x] 4.3 Remove `run-tests.php` and old test files
- [x] 4.4 Add `vendor/bin/phpunit` to justfile/Makefile CI target
- [ ] 4.5 Generate baseline coverage report (`--coverage-html coverage/`) — needs Xdebug/PCov
- [ ] 4.6 Commit coverage baseline
- [x] 4.5 Generate baseline coverage report (`--coverage-html coverage/`) — needs Xdebug/PCov
- [x] 4.6 Commit coverage baseline
---

View File

@@ -1,5 +1,15 @@
<?xml version="1.0"?>
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<source>
<include>
<directory suffix=".php">app/src</directory>
</include>
</source>
<coverage>
<report>
<html outputDirectory="coverage"/>
</report>
</coverage>
<testsuites>
<testsuite name="XAMXAM">
<directory>tests/phpunit</directory>

View File

@@ -17,11 +17,9 @@ class TestDatabaseInstance extends Database
{
// Inject PDO directly via reflection, then flag as ready
$ref = new ReflectionProperty(Database::class, 'pdo');
$ref->setAccessible(true);
$ref->setValue($this, $pdo);
$pathRef = new ReflectionProperty(Database::class, 'dbPath');
$pathRef->setAccessible(true);
$pathRef->setValue($this, ':memory:');
}
}

View File

@@ -25,7 +25,6 @@ class DatabaseExtendedTest extends TestCase
// Build conditions with special LIKE characters in query
// Use reflection to call the private method
$ref = new ReflectionMethod(Database::class, 'escapeLikeString');
$ref->setAccessible(true);
$this->assertSame('\\\\', $ref->invoke($this->db, '\\'));
$this->assertSame('\\%', $ref->invoke($this->db, '%'));
@@ -39,7 +38,6 @@ class DatabaseExtendedTest extends TestCase
public function testBuildSearchConditionsEmptyParams(): void
{
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
$ref->setAccessible(true);
[$conditions, $bindings] = $ref->invoke($this->db, []);
@@ -51,7 +49,6 @@ class DatabaseExtendedTest extends TestCase
public function testBuildSearchConditionsWithQuery(): void
{
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
$ref->setAccessible(true);
[$conditions, $bindings] = $ref->invoke($this->db, ['query' => 'test']);
@@ -63,7 +60,6 @@ class DatabaseExtendedTest extends TestCase
public function testBuildSearchConditionsWithYear(): void
{
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
$ref->setAccessible(true);
[$conditions, $bindings] = $ref->invoke($this->db, ['year' => 2024]);
@@ -74,7 +70,6 @@ class DatabaseExtendedTest extends TestCase
public function testBuildSearchConditionsWithAllFilters(): void
{
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
$ref->setAccessible(true);
[$conditions, $bindings] = $ref->invoke($this->db, [
'query' => 'art',

View File

@@ -15,7 +15,6 @@ class StudentEmailTest extends TestCase
private function buildHtml(array $thesis): string
{
$ref = new ReflectionMethod(StudentEmail::class, 'buildHtml');
$ref->setAccessible(true);
return $ref->invoke(null, $thesis);
}

View File

@@ -26,7 +26,6 @@ class ThesisCreateValidationTest extends TestCase
private function validate(array $post, bool $adminMode = false): array
{
$ref = new ReflectionMethod(ThesisCreateController::class, 'validateAndSanitise');
$ref->setAccessible(true);
$db = TestDatabase::getInstance();
$ctrl = new ThesisCreateController($db);

View File

@@ -63,7 +63,6 @@ class ThesisEditValidationTest extends TestCase
private function collectJuryMembers(array $post): array
{
$ref = new ReflectionMethod(ThesisEditController::class, 'collectJuryMembers');
$ref->setAccessible(true);
return $ref->invoke($this->ctrl, $post);
}
@@ -142,7 +141,6 @@ class ThesisEditValidationTest extends TestCase
private function invokeHandleWebsiteUrl(int $thesisId, array $post): void
{
$ref = new ReflectionMethod(ThesisEditController::class, 'handleWebsiteUrl');
$ref->setAccessible(true);
$ref->invoke($this->ctrl, $thesisId, $post);
}