mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-02 21:30:16 +09:00
Enhance type safety, authentication checks, and testing framework (#3701)
* Improve type safety, auth checks and PHPStan fixes (#3250) * Improve type safety, auth checks and PHPStan fixes * Remove @phpstan-ignore annotations * Improve type safety, auth checks and PHPStan fixes * Remove @phpstan-ignore annotations * Remove redundant @phpstan-ignore comment * Improve code robustness and reliability (#3248) * Harden code against null/undefined values * Update dependency lockfiles * Sanitize ticket input and use IDs in email list * Restructure tests and add test utilities * Move E2E tests to `Library\E2E` namespace * Update `php-build` action ref in workflows * Switch tests to Pest and add test scaffolding * Refactor E2E tests to Pest-style tests m Skip E2E tests when env not configured * Refactor Unit tests and update test config Add test datasets and refine test helpers * Add DEBUG guard, fix API JSON decode, update tests * Refactor tests: add types and Mockery expectations * Adjust tests, phpstan config, and composer script * Instantiate test APIs locally, remove beforeEach * Refactor runtime checks, types & logging * Apply PHP Code Styling Changes m * Add PHPStan ignores, test renames & small fixes * Enable Pest tests in CI workflow * Remove legacy tests; add new unit tests/config * Avoid undefined index in fingerprint comparison * Ignore properties absent in both fingerprints * Remove public_ticket_create API method * Add Fingerprint unit tests * Remove em dash from fingerprint test name * Switch to Pest; assorted bug fixes & refactors * Prefer getDi() and guard DEBUG define * Refactor tests: DBAL, Antispam rename, helpers * Refactor email tests to use Doctrine entities * Update tests, use DBAL mocks & improve Formbuilder admin * Validate plan_id and update unit tests * Replace error_log with DI logger and update tests * Expect db->store in Invoice Service test * Use DI logger instead of error_log; fix tests * Fix typo in Hook Service test * Fix Staff test spelling fixture * Complete Pest test migration * Fix Product test spelling fixtures * Fix Product test spelling fixtures * Run live tests with Pest and load helpers * Migrate tests to ApiClient; remove legacy APIHelper * Fix Email test spelling * Remove unused PHPUnit bridge * Organize Cypress end-to-end tests * Document Pest test directory root * Remove noisy Pest comments
This commit is contained in:
1 parent
f36ee692d2
commit
dd3dcbfd52
477 files changed
+45173
-56802
No files matched your search
+8
-2
@@ -42,6 +42,7 @@ function checkInstaller(): void
|
||||
}
|
||||
|
||||
// If the config file exists and not install.php, but the install folder does, perform some cleanup.
|
||||
// @phpstan-ignore booleanNot.alwaysTrue (DEBUG is a runtime constant)
|
||||
if ($filesystem->exists(PATH_CONFIG) && $filesystem->exists(Path::normalize('install')) && !DEBUG) {
|
||||
$filesystem->remove('install');
|
||||
}
|
||||
@@ -54,7 +55,7 @@ function checkSSL(): void
|
||||
{
|
||||
global $request;
|
||||
|
||||
if (!empty(Config::getProperty('security.force_https')) && Config::getProperty('security.force_https') && !Environment::isCLI()) {
|
||||
if (Config::getProperty('security.force_https') && !Environment::isCLI()) {
|
||||
if (!$request->isSecure()) {
|
||||
(new RedirectResponse('https://' . $request->getHost() . $request->getRequestUri()))->send();
|
||||
exit;
|
||||
@@ -159,6 +160,7 @@ function exceptionHandler(Exception|Error $e)
|
||||
return false;
|
||||
}
|
||||
|
||||
// @phpstan-ignore booleanAnd.alwaysFalse, booleanAnd.rightAlwaysFalse (DEBUG is a runtime constant)
|
||||
if (defined('DEBUG') && DEBUG && $filesystem->exists(PATH_VENDOR)) {
|
||||
/**
|
||||
* If advanced debugging is enabled, print Whoops instead of our error page.
|
||||
@@ -170,6 +172,7 @@ function exceptionHandler(Exception|Error $e)
|
||||
$prettyPage->addDataTable('FOSSBilling environment', [
|
||||
'PHP Version' => PHP_VERSION,
|
||||
'Error code' => $e->getCode(),
|
||||
// @phpstan-ignore nullCoalesce.expr (INSTANCE_ID is a runtime constant that may not be defined during analysis)
|
||||
'Instance ID' => INSTANCE_ID ?? 'Unknown',
|
||||
]);
|
||||
$whoops->pushHandler($prettyPage);
|
||||
@@ -261,7 +264,9 @@ function init(): void
|
||||
// Set globals and relevant settings based on the config.
|
||||
date_default_timezone_set(Config::getProperty('i18n.timezone', 'UTC'));
|
||||
define('ADMIN_PREFIX', Config::getProperty('admin_area_prefix'));
|
||||
define('DEBUG', (bool) Config::getProperty('debug_and_monitoring.debug', false));
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', (bool) Config::getProperty('debug_and_monitoring.debug', false));
|
||||
}
|
||||
$pathData = Path::normalize(Config::getProperty('path_data'));
|
||||
if (Environment::isTesting()) {
|
||||
$pathData = Path::join(sys_get_temp_dir(), 'fossbilling_test_data');
|
||||
@@ -312,6 +317,7 @@ function postInit(): void
|
||||
ini_set('error_log', Path::join(PATH_LOG, 'php_error.log'));
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// @phpstan-ignore if.alwaysFalse (DEBUG is a runtime constant that may be true during debugging)
|
||||
if (DEBUG) {
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
|
||||
Reference in new issue
Block a user