Files
Mitgliederverwaltung/tests/bootstrap.php
T
shahondin1624 ee569250ad
Database Portability Tests / Unit Tests (PlatformHelper) (push) Failing after 40s
Database Portability Tests / Integration (mysql) (push) Has been skipped
Database Portability Tests / Integration (postgres) (push) Has been skipped
Database Portability Tests / Integration (sqlite) (push) Has been skipped
Database Portability Tests / Verify no MySQL-specific SQL (push) Successful in 5s
Fix N+1 query problem in MemberService (Closes #200)
- MemberMapper: 8 new *WithRelations() methods that fetch members with
  addresses, phones, and emails in a single query using LEFT JOINs
- MemberMapper: addJoinClauses() and fetchWithRelations() private helpers
  that handle JOIN duplication (one member × multiple sub-entities)
- MemberService: refactored findAll, findByFamily, findByStatus, search,
  findByBirthdayThisMonth, findWithUnpaidFees, findFiltered, fullTextSearch
  to delegate to joined mapper methods
- MemberService: added arrayToMember() and arrayToAddress() helpers so
  buildMatchContext() works with flat-array results from fullTextSearch
- MemberServiceTest: updated all existing tests to mock new method names
  and return flat-array format with nested sub-entities
- MemberServiceTest: added 10 new tests covering joined methods, backward
  compatibility, and correct shape of returned data
- Moved issue-200 plan from open/ to done/
2026-04-28 21:35:42 +02:00

49 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* Test bootstrap: load Composer autoloader and register stubs for
* internal Nextcloud classes that OCP interfaces reference but that
* are not shipped with the nextcloud/ocp stubs package.
*/
// Stub OC\Hooks\Emitter (referenced by OCP\Files\IRootFolder)
if (!interface_exists('OC\Hooks\Emitter')) {
// @phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
eval('namespace OC\Hooks; interface Emitter {}');
}
// Stub OCA\DAV\CalDAV\CalDavBackend (from the dav app, not in OCP stubs)
if (!class_exists('OCA\DAV\CalDAV\CalDavBackend')) {
eval('namespace OCA\DAV\CalDAV; class CalDavBackend {}');
}
// Try the app's vendor autoload first (full local dev).
// Fall back to Nextcloud's root autoloader which has PSR packages.
$appAutoload = __DIR__ . '/../vendor/autoload.php';
$ncAutoload = '/var/www/html/lib/composer/autoload.php';
if (file_exists($appAutoload)) {
require_once $appAutoload;
} elseif (file_exists($ncAutoload)) {
require_once $ncAutoload;
}
// Register the app's lib directory for PSR-4 autoloading.
// This ensures OCA\Mitgliederverwaltung\* classes are loaded regardless
// of which vendor/autoload.php was used (full local dev vs. container).
spl_autoload_register(function ($class) {
$prefix = 'OCA\\Mitgliederverwaltung\\';
$baseDir = __DIR__ . '/../lib/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relativeClass = substr($class, $len);
$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
if (file_exists($file)) {
require $file;
}
});