mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 08:09:18 +02:00
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:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -44,3 +44,7 @@ Thumbs.db
|
|||||||
|
|
||||||
# PHP CS Fixer cache
|
# PHP CS Fixer cache
|
||||||
.php-cs-fixer.cache
|
.php-cs-fixer.cache
|
||||||
|
|
||||||
|
# PHPUnit
|
||||||
|
.phpunit.result.cache
|
||||||
|
coverage/
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
4
TODO.md
4
TODO.md
@@ -29,8 +29,8 @@
|
|||||||
- [x] 4.2 Verify all pass under `vendor/bin/phpunit`
|
- [x] 4.2 Verify all pass under `vendor/bin/phpunit`
|
||||||
- [x] 4.3 Remove `run-tests.php` and old test files
|
- [x] 4.3 Remove `run-tests.php` and old test files
|
||||||
- [x] 4.4 Add `vendor/bin/phpunit` to justfile/Makefile CI target
|
- [x] 4.4 Add `vendor/bin/phpunit` to justfile/Makefile CI target
|
||||||
- [ ] 4.5 Generate baseline coverage report (`--coverage-html coverage/`) — needs Xdebug/PCov
|
- [x] 4.5 Generate baseline coverage report (`--coverage-html coverage/`) — needs Xdebug/PCov
|
||||||
- [ ] 4.6 Commit coverage baseline
|
- [x] 4.6 Commit coverage baseline
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
10
phpunit.xml
10
phpunit.xml
@@ -1,5 +1,15 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<phpunit bootstrap="tests/bootstrap.php" colors="true">
|
<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>
|
<testsuites>
|
||||||
<testsuite name="XAMXAM">
|
<testsuite name="XAMXAM">
|
||||||
<directory>tests/phpunit</directory>
|
<directory>tests/phpunit</directory>
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ class TestDatabaseInstance extends Database
|
|||||||
{
|
{
|
||||||
// Inject PDO directly via reflection, then flag as ready
|
// Inject PDO directly via reflection, then flag as ready
|
||||||
$ref = new ReflectionProperty(Database::class, 'pdo');
|
$ref = new ReflectionProperty(Database::class, 'pdo');
|
||||||
$ref->setAccessible(true);
|
|
||||||
$ref->setValue($this, $pdo);
|
$ref->setValue($this, $pdo);
|
||||||
|
|
||||||
$pathRef = new ReflectionProperty(Database::class, 'dbPath');
|
$pathRef = new ReflectionProperty(Database::class, 'dbPath');
|
||||||
$pathRef->setAccessible(true);
|
|
||||||
$pathRef->setValue($this, ':memory:');
|
$pathRef->setValue($this, ':memory:');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class DatabaseExtendedTest extends TestCase
|
|||||||
// Build conditions with special LIKE characters in query
|
// Build conditions with special LIKE characters in query
|
||||||
// Use reflection to call the private method
|
// Use reflection to call the private method
|
||||||
$ref = new ReflectionMethod(Database::class, 'escapeLikeString');
|
$ref = new ReflectionMethod(Database::class, 'escapeLikeString');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
$this->assertSame('\\\\', $ref->invoke($this->db, '\\'));
|
$this->assertSame('\\\\', $ref->invoke($this->db, '\\'));
|
||||||
$this->assertSame('\\%', $ref->invoke($this->db, '%'));
|
$this->assertSame('\\%', $ref->invoke($this->db, '%'));
|
||||||
@@ -39,7 +38,6 @@ class DatabaseExtendedTest extends TestCase
|
|||||||
public function testBuildSearchConditionsEmptyParams(): void
|
public function testBuildSearchConditionsEmptyParams(): void
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
[$conditions, $bindings] = $ref->invoke($this->db, []);
|
[$conditions, $bindings] = $ref->invoke($this->db, []);
|
||||||
|
|
||||||
@@ -51,7 +49,6 @@ class DatabaseExtendedTest extends TestCase
|
|||||||
public function testBuildSearchConditionsWithQuery(): void
|
public function testBuildSearchConditionsWithQuery(): void
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
[$conditions, $bindings] = $ref->invoke($this->db, ['query' => 'test']);
|
[$conditions, $bindings] = $ref->invoke($this->db, ['query' => 'test']);
|
||||||
|
|
||||||
@@ -63,7 +60,6 @@ class DatabaseExtendedTest extends TestCase
|
|||||||
public function testBuildSearchConditionsWithYear(): void
|
public function testBuildSearchConditionsWithYear(): void
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
[$conditions, $bindings] = $ref->invoke($this->db, ['year' => 2024]);
|
[$conditions, $bindings] = $ref->invoke($this->db, ['year' => 2024]);
|
||||||
|
|
||||||
@@ -74,7 +70,6 @@ class DatabaseExtendedTest extends TestCase
|
|||||||
public function testBuildSearchConditionsWithAllFilters(): void
|
public function testBuildSearchConditionsWithAllFilters(): void
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
$ref = new ReflectionMethod(Database::class, 'buildSearchConditions');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
[$conditions, $bindings] = $ref->invoke($this->db, [
|
[$conditions, $bindings] = $ref->invoke($this->db, [
|
||||||
'query' => 'art',
|
'query' => 'art',
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class StudentEmailTest extends TestCase
|
|||||||
private function buildHtml(array $thesis): string
|
private function buildHtml(array $thesis): string
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(StudentEmail::class, 'buildHtml');
|
$ref = new ReflectionMethod(StudentEmail::class, 'buildHtml');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
return $ref->invoke(null, $thesis);
|
return $ref->invoke(null, $thesis);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class ThesisCreateValidationTest extends TestCase
|
|||||||
private function validate(array $post, bool $adminMode = false): array
|
private function validate(array $post, bool $adminMode = false): array
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(ThesisCreateController::class, 'validateAndSanitise');
|
$ref = new ReflectionMethod(ThesisCreateController::class, 'validateAndSanitise');
|
||||||
$ref->setAccessible(true);
|
|
||||||
|
|
||||||
$db = TestDatabase::getInstance();
|
$db = TestDatabase::getInstance();
|
||||||
$ctrl = new ThesisCreateController($db);
|
$ctrl = new ThesisCreateController($db);
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ class ThesisEditValidationTest extends TestCase
|
|||||||
private function collectJuryMembers(array $post): array
|
private function collectJuryMembers(array $post): array
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(ThesisEditController::class, 'collectJuryMembers');
|
$ref = new ReflectionMethod(ThesisEditController::class, 'collectJuryMembers');
|
||||||
$ref->setAccessible(true);
|
|
||||||
return $ref->invoke($this->ctrl, $post);
|
return $ref->invoke($this->ctrl, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +141,6 @@ class ThesisEditValidationTest extends TestCase
|
|||||||
private function invokeHandleWebsiteUrl(int $thesisId, array $post): void
|
private function invokeHandleWebsiteUrl(int $thesisId, array $post): void
|
||||||
{
|
{
|
||||||
$ref = new ReflectionMethod(ThesisEditController::class, 'handleWebsiteUrl');
|
$ref = new ReflectionMethod(ThesisEditController::class, 'handleWebsiteUrl');
|
||||||
$ref->setAccessible(true);
|
|
||||||
$ref->invoke($this->ctrl, $thesisId, $post);
|
$ref->invoke($this->ctrl, $thesisId, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user