Files
nextcloud-autocurrency/tests/bootstrap.php
Chen Asraf effe1a327d chore: improve CI/CD, testing infrastructure, and development tooling
- Add GitHub Actions workflows for PHPUnit testing (MySQL and
PostgreSQL)
- Add issue templates (bug reports, feature requests) for better issue
management
- Enhance Makefile with Docker test support and improved build targets
- Update lint-staged configuration with better PHP and JSON handling
- Add comprehensive PHPUnit test infrastructure with Docker support
- Update dependencies and add lock files for composer and vendor-bin
tools
- Improve code scaffolding templates (command, component, view
generators)
- Update build configuration (Vite, package.json, pnpm-lock.yaml)
- Refactor Application.php settings initialization
- Update AdminSettings and UserSettings implementations
- Rename test file for consistency (ApiTest → ApiControllerTest)
- Update .gitignore (track composer.lock, ignore stats.html)
2025-11-23 00:52:22 +02:00

39 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
// Detect Nextcloud bootstrap location
// Priority: 1) NEXTCLOUD_ROOT env var, 2) Docker location, 3) Standard location
$nextcloudBootstrap = null;
// Check both $_ENV and getenv() as they can differ depending on PHP configuration
$nextcloudRoot = $_ENV['NEXTCLOUD_ROOT'] ?? getenv('NEXTCLOUD_ROOT');
if (!empty($nextcloudRoot)) {
// Use NEXTCLOUD_ROOT environment variable (set by Makefile for local testing)
$nextcloudBootstrap = $nextcloudRoot . '/tests/bootstrap.php';
} elseif (file_exists(__DIR__ . '/../../../tests/bootstrap.php')) {
// Standard location (Docker/installed in Nextcloud apps directory)
$nextcloudBootstrap = __DIR__ . '/../../../tests/bootstrap.php';
}
if ($nextcloudBootstrap && file_exists($nextcloudBootstrap)) {
// Running with full Nextcloud environment
// Define OC_CONSOLE to bypass installation check during tests
if (!defined('OC_CONSOLE')) {
define('OC_CONSOLE', 1);
}
require_once $nextcloudBootstrap;
require_once __DIR__ . '/../vendor/autoload.php';
\OC_App::loadApp(OCA\AutoCurrency\AppInfo\Application::APP_ID);
OC_Hook::clear();
} else {
// Cannot find Nextcloud bootstrap
echo "\n\033[31mError: Nextcloud bootstrap not found.\033[0m\n";
echo "For local testing, set NEXTCLOUD_ROOT environment variable:\n";
echo " NEXTCLOUD_ROOT=~/Dev/nextcloud-docker-dev/workspace/server make test\n";
echo "\nOr run tests in Docker:\n";
echo " make test-docker\n\n";
exit(1);
}