Commit Graph
6 Commits
Author SHA1 Message Date
Adam Daley 96659a195c Refactor cookie management and clean up legacy (#3308)
* Remove manual unsetting of `BOXADMR` cookie

* Rename locale cookie `BBLANG` to `fb_locale`

* Rename session name to `fb_sid`

* Tidy comments in `config-sample.php`

* Remove legacy `bb-ipn.php` rewrite rule

* Remove legacy BB params and file migration check

* Remove header comments from `robots.txt`

* Update SQL dump header database name

* Use `FB_*` DB constants and add DB port
2026-03-10 08:42:11 +00:00
Adam Daley c68048a8ea Make clearCache accept path and update tests-legacy (#3232)
Make `clearCache` accept path and update tests
2026-02-07 02:31:41 +00:00
Belle Aerni 0a156f4161 Fix CS automation (#3209)
* Restore needed gitignore

* Ran the fixes since they are far behind

* Fix for rector causing a problem. Re-ran.

* Update ServiceTest.php
2026-01-26 11:18:35 -08:00
Adam DaleyandCopilot a0b3158b30 PHPUnit test-legacy refactor and cleanup (#3144)
* PHPUnit test-legacy cleanup

Refactor and cleanup the legacy PHPUnit tests.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-13 17:32:09 +00:00
03c26e5972 Introduce RequiredParams attribute (#2965)
* Introduce RequiredParams attribute

* Use the new RequiredParams attribute instead

* Make sure we are always passing an array

* Fixed tests

* Fixed tests

* Fixed tests

* Fix validation attribute test failures

Added back manual parameter validation to API methods that use
RequiredParams attributes. The attribute validation only works when
methods are called through Api_Handler, but tests call methods directly.

Changes:
- Added checkRequiredParamsForArray calls to methods with RequiredParams
- Updated tests to include validators in DI containers
- Fixed HTTPS URL expectation in Invoice test
- Ensured all 1673 tests pass

This maintains both attribute-based validation (for Handler calls) and
inline validation (for direct calls and tests).

* Fix RequiredParams attribute validation in tests

- Made Api_Handler::validateRequiredParams() public to enable testing
- Added validateRequiredParams() helper method to BBTestCase for test validation
- Updated all failing tests to call validation before API methods
- Added RequiredParams attribute to Servicedomain update() method
- Fixed test expectation message to match actual error message
- All 1673 tests now pass successfully

This completes the RequiredParams attribute implementation by ensuring
tests properly validate required parameters through the attribute system
rather than relying on manual validation calls.

* Remove duplicate manual validation from API methods

Removed checkRequiredParamsForArray calls that were duplicating the
RequiredParams attribute validation. These manual calls are no longer
needed since the Api_Handler now processes the attributes automatically.

Files updated:
- Client/Api/Admin.php: Removed duplicate 'id' validation in update()
- Currency/Api/Admin.php: Removed duplicate 'code' validation in delete()
- Profile/Api/Admin.php: Removed duplicate password field validation in change_password()
- Staff/Api/Guest.php: Removed duplicate email/password validation in login()
- Support/Api/Admin.php: Removed duplicate 'id' validation in kb_category_* methods

All methods now rely solely on the RequiredParams attribute for validation.

* Introduce RequiredParams attribute

* Use the new RequiredParams attribute instead

* Make sure we are always passing an array

* Fixed tests

* Fixed tests

* Fixed tests

* Fix validation attribute test failures

Added back manual parameter validation to API methods that use
RequiredParams attributes. The attribute validation only works when
methods are called through Api_Handler, but tests call methods directly.

Changes:
- Added checkRequiredParamsForArray calls to methods with RequiredParams
- Updated tests to include validators in DI containers
- Fixed HTTPS URL expectation in Invoice test
- Ensured all 1673 tests pass

This maintains both attribute-based validation (for Handler calls) and
inline validation (for direct calls and tests).

* Fix RequiredParams attribute validation in tests

- Made Api_Handler::validateRequiredParams() public to enable testing
- Added validateRequiredParams() helper method to BBTestCase for test validation
- Updated all failing tests to call validation before API methods
- Added RequiredParams attribute to Servicedomain update() method
- Fixed test expectation message to match actual error message
- All 1673 tests now pass successfully

This completes the RequiredParams attribute implementation by ensuring
tests properly validate required parameters through the attribute system
rather than relying on manual validation calls.

* Remove duplicate manual validation from API methods

Removed checkRequiredParamsForArray calls that were duplicating the
RequiredParams attribute validation. These manual calls are no longer
needed since the Api_Handler now processes the attributes automatically.

Files updated:
- Client/Api/Admin.php: Removed duplicate 'id' validation in update()
- Currency/Api/Admin.php: Removed duplicate 'code' validation in delete()
- Profile/Api/Admin.php: Removed duplicate password field validation in change_password()
- Staff/Api/Guest.php: Removed duplicate email/password validation in login()
- Support/Api/Admin.php: Removed duplicate 'id' validation in kb_category_* methods

All methods now rely solely on the RequiredParams attribute for validation.

* Fix RequiredParams validation in tests

- Updated 10 tests to call validateRequiredParams() before API methods
- Fixed error message expectation in Client::update test
- Changed Staff login mock expectations from atLeastOnce to never
  (validation throws before validateAndSanitizeEmail is reached)
- Added missing validator to DI containers in Currency and Support tests
- Fixed http to https in Invoice callback URL test

All RequiredParams validation tests now properly test the attribute system.

* Fix kbHitView mock return type errors

The kbHitView method has a void return type, so mocks should not
specify a return value. Removed willReturn() calls from all kbHitView
mock setups.

Reduced errors from 70 to 64.

* Add location/ directory to gitignore

* Fix all void return type mock errors

Removed willReturn(null) from checkRequiredParamsForArray mocks and other
void methods. These methods have void return types and should not specify
return values in mocks.

Result: All 1673 tests now pass with 0 failures and 0 errors!
Only 30 PHPUnit deprecation warnings remain (not errors).

* chore: stabilize legacy tests after merge from main

- Fix PHPUnit 11 attribute compatibility issues (DataProvider, Group).
- Fix DI container issues in legacy tests by ensuring 'validator' and 'tools' are always available.
- Resolve 'IncompatibleReturnValueException' in mocks due to updated method return types (void, bool, int).
- Fix broken class/namespace references in mocks using 'getMockBuilder' and 'createMock'.
- Restore missing 'deleteLoginHistory' method in Staff Service.
- Remove obsolete Branding module legacy tests.

* chore: fully resolve legacy test failures and restore passing state

- Fixed 'testUninstall' in Extension module by allowing Filesystem injection.
- Restored missing 'deleteLoginHistory' in Staff Service.
- Updated all mocks for 'checkRequiredParamsForArray' to be optional (any()) as it's now handled by attributes.
- Corrected numerous assertions from assertIsArray/assertIsInt to assertTrue for methods whose return type changed to bool.
- Fixed relative class references and namespaces in several legacy tests.

* chore: eliminate all PHPUnit deprecations and resolve final test failures

- Replaced deprecated 'new ServiceTest()' manual instantiation in data providers with string identifiers.
- Updated 'onConsecutiveCalls' usage to use the newer 'willReturn' syntax for multiple values.
- Fixed numerous 'TypeError' and dynamic expectation call issues introduced during refactoring.
- Improved 'Email Service' by moving salt retrieval from static Config to DI container for better testability.
- Resolved all remaining legacy test failures and deprecations.

* Remove unused asset file

Deleted the file at location/Of/Assets/file as it is no longer needed.

* Restore Branding module with service, icon, and manifest

Introduces a new Branding module including the service class, SVG icon, and manifest file. This module allows voluntary display of FOSSBilling references and includes basic module permissions and uninstall functionality.

* Update .gitignore and add .gitkeep for cache directory

Modified .gitignore to properly ignore cache files while allowing the .gitkeep file to be tracked. Added src/data/cache/.gitkeep to ensure the cache directory is present in the repository.

* These were removed in #3026 and seem to be accidentally reintroduced.

* No need to use it here

* Also removed with #3026.

* Also removed with #3026.

* Update dependencies in composer.lock

Bump nette/utils from v4.1.0 to v4.1.1 and react/child-process from v0.6.6 to v0.6.7 in composer.lock to include latest bug fixes and improvements.

* Update service test mocks and improve test setup

Refactored Extension ServiceTest to properly mock getExtensionPath and filesystem exists, ensuring temp directories are created and cleaned up within the test. Updated Invoice ServiceTest to include 'toApiArray' in the list of mocked methods for relevant tests.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2025-12-24 01:54:13 +00:00
Belle Aerni ccc97a3ec9 Initial implementation of CI against a live FOSSBilling Install (#2067)
* Rename tests to tests-legacy

* Groundwork for live tests

* Somewhat working tests on a live instance

* Hmmmmmm

* Fix

* Fixed the other bug

* Added a handful of various tests

* Typos, all these are admin endpoints

* Bypass this check for testing envs

* Disable it for now

* Mini cleanup

* Cleanup from debugging, ran PHP-CS-Fixer
2024-01-14 22:51:32 -08:00