Commit Graph
37 Commits
Author SHA1 Message Date
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
e85b1eeff9 Update SpamChecker to be able to use Cloudflare Turnstile and hCaptcha (#3004)
* Do not include local dev database, which is used for debugging

* Revert of ceddc35aa7

* Add turnstile to config and a selector of providers

* Add turnstile's logic

* add turnstile variables to the API

* add turnstile to the macro and html_client

* Add hCaptcha

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/html_admin/mod_spamchecker_settings.html.twig

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

* Fix bugs

* Fix space consistency in Guest.php

* Apply suggestion from @Copilot

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

* Fix macros

* Add link to hcaptcha's website

* Add and fix unit tests for the Spamchecker

* Fix cspell

* Reverse the "recaptcha_private/publickey" to "captcha_recaptcha_private/publickey"

* Apply suggestion from @Copilot

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

* Apply suggestion from @Copilot

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

* Update cspell.json with new terms and ignore paths

* Update src/modules/Spamchecker/html_client/mod_spamchecker_recaptcha.html.twig

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

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update src/modules/Spamchecker/Service.php

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

* Fix array formatting in GuestTest

* Update tests-legacy/modules/Spamchecker/Api/GuestTest.php

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

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/html_admin/mod_spamchecker_settings.html.twig

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

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/Service.php

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

* Update src/modules/Spamchecker/Service.php

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

* Apply suggestion from @Copilot

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

* Rewrite toggleProviderSettings in vanilla JS

* Remove useless comment

* Update src/modules/Spamchecker/html_admin/mod_spamchecker_settings.html.twig

Co-authored-by: Adam Daley <admdly@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
2025-11-06 17:50:14 +00:00
Belle Aerni c486b262d9 Small developer experience improvements (#2971)
* ddev enhancements

Introduced a new script that runs when the ddev container starts.
This script will automatically update the dependencies if they fall behind the lockfile and will rebuild NPM when needed too

* Fixes and improvements for DX

* Cleaner, better

* Changes based on copilot review

* Remove an old comment I somehow missed

* use npm ci instead
2025-10-14 11:06:33 -07:00
Adam Daley 86964e8eb2 Switch Wysiwyg module build from Webpack to esbuild (#2948) 2025-10-06 11:57:02 +01:00
FOSSBilling BotandBelle Aerni 48f47e723c Apply PHP Code Styling & Quality Changes (#2938)
Update .gitignore

Co-authored-by: Belle Aerni <belleaerni@gmail.com>
2025-10-02 16:41:18 -07: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
Belle Aerni 32d011225b Rector & PHP-CS-Fixer Improvements (#2047)
* Added the rector cache to the action

* Enabled PHP-CS fixer for the tests & library folder

* Use the PHP-CS-Fixer Cache

* Fix the tests

* Ensure the Sentry placeholder isn't messed up from CS changes

* Typo..
2024-01-08 00:10:00 +00:00
Adam Daleyandrenovate[bot] 2a14679d2e Move Docker file and add automated Docker builds (#1916)
* Rework reusable workflows to use composite actions (#1918)

* Update FOSSBilling/.workflows digest to 5c7b960

* Update dependency apexcharts to v3.44.2

* Update CKEditor to v39.3.0 (minor) (#1931)

Update CKEditor to v39.3.0

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency core-js to v3.34.0 (#1932)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency cypress to v13.6.1

* Update dependency flag-icons to v7.0.3

* Update dependency phpunit/phpunit to v10.5.2

* Bump lcharette/webpack-encore-twig to v1.2 (#1933)

Bump lcharette/webpack-encore-twig

Bump lcharette/webpack-encore-twig to ^1.2 and remove symfony/webpack-encore-bundle override as now fixed upstream.

* Move Dockerfile from Docker repo

* Add Docker preview build and push to CI

* Add workflow to build and tag Docker builds on release

* Update workflow to build and tag Docker builds on release

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-07 17:29:45 +00:00
Belle Aerni 50043e6211 Run Rector against our tests (#1761)
* Update rector config to include tests

* Run Rector against the tests

* Delete test-results

* Update .gitignore

* Correctly set the PHP min to 8.1, split the configs

* Corrected PHPDoc

* Deleted tests we can't really get to pass

PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so).

No way to disable the exception as far as we can tell
2023-11-11 18:41:09 +00:00
RonandBelle Aerni 75fb9cbdcf Developer Workflow Supporting Code (#1692)
* #1583 initial workflow update using debug reference in config for install dir bypass

* #1583 add missed files

* #1583 improve config generation

* #1583 clean up docblock (issue feedback)

* fix https detection, corrected pull from upstream

* #1583 improve docker build config

* #1583 remove docker configs from repo, they have been moved to dev workflow documentation

* Two very minor changes

* Other minor changes

---------

Co-authored-by: Belle Aerni <belleaerni@gmail.com>
2023-10-05 09:47:57 +02:00
Yağızhan 100256d43c Moved Cypress to /tests. (#1621) 2023-09-19 22:31:28 +03:00
fefbcd21b0 Apply PHP Code Styling & Quality Changes (#1498)
* Apply PHP Code Styling & Quality Changes

* Delete these

* Update .gitignore

* Fixes for PHPStan

* Ignore spelling in the gitnore

* Allow null for that type

Honestly doing so makes ZERO sense, but it matches the current behavior.

---------

Co-authored-by: FOSSBilling Bot <fossbilling-bot>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
2023-07-30 08:57:44 -07:00
Adam Daley b08fc53d72 Update rewrite rules, improve error handling, and some related cleanup (#1075)
* Rename htaccess to be applied automatically

Rename the htaccess file, improve handling when .htaccess is missing, and remove from .gitignore so that rules are automatically applied on supported web servers.

* Clean up .gitignore file

* Update .htaccess to improve security

Update .htaccess file to improve general security, handle missing mod_rewrite, and to simplify the required rules.

* Improve HTTP and generic error handling

Improve handling of HTTP errors, and make the error handling code more generic to permit catching more errors.

* Remove outdated example web server config files

Remove the outdated and unmaintained example web server configuration files in favour of FOSSBilling/config-generator.

* Remove support for non-search engine friendly URLs

Remove support for non-search engine friendly URLs as these are depreciated.

* Revert "Remove support for non-search engine friendly URLs"

This reverts commit 724b1eb274.

* Update config migration backup handling
2023-04-06 21:59:25 +02:00
Jaap Marcus 33f08b0c8e Fix Client name look up
Use CONCAT_WS instead CONCAT add white space infront of Firstname
2022-12-14 23:25:06 +01:00
Belle Aerni a68c1d7261 Fix checks 2022-12-08 17:06:32 -08:00
Belle Aerni ee676ca33a Update file references 2022-11-28 17:22:50 +03:00
Benjamin Aerni 42d197568e Apply PHP CS Fixer 2022-11-02 12:00:10 -06:00
Yağızhan Burak Yakar c135a1efcd Merge remote-tracking branch 'origin/main' into rename-templates 2022-05-20 10:45:55 +03:00
Yağızhan Burak Yakar ff197210d8 Follow-up 2022-05-18 20:23:15 +03:00
Yağızhan Burak Yakar 1b7069dd19 Minor changes and some rebranding 2022-05-18 18:36:22 +03:00
andpavlenko 07aafb19fa Rewrite admin theme with Tabler.io 2022-05-17 14:38:08 +00:00
andpavlenko 3380a10178 Task #1276 - Rename templates to native Twig extension 2022-04-21 13:49:37 +00:00
andpavlenko f4c4f6bac7 Mirgate to PSR12 and other small fixes 2022-04-01 09:32:55 +00:00
evrifaessa 88e9f4114e Update .gitignore 2020-12-16 13:08:12 +03:00
Fordnox 1fe90f837e Merge branch 'master' into travis-stages 2020-11-01 18:52:48 +02:00
Fordnox 6642636fd2 Remove puphpet 2020-11-01 03:36:29 +02:00
Fordnox 093068eb61 Docker build and makefile 2020-11-01 02:00:49 +02:00
Timothy Webb Sr dabfbc750b Composer updates. 2020-09-09 05:50:38 +00:00
Mr. Timothy Glenn Webb Sr 6a92ed7fbe Directory structure cleanup. 2020-09-05 04:17:30 +00:00
Timothy Webb Sr 6d78dfbc65 Composer updates 2020-09-04 14:44:41 +00:00
Timothy Webb 595ee0280a Error log commit. 2020-08-31 20:10:02 -04:00
Timothy Webb eb97f0fa8b Added to .gitignore bb-data/log/* 2020-08-31 16:33:34 -04:00
samapraku 9904f0f520 ignore .history folder 2020-03-24 15:18:39 +01:00
Vaidas Lungis 6e8df56c0b add grunt-spritesmith grunt task 2015-05-28 17:48:31 +03:00
Vaidas Lungis 4260e2b62c install nodejs for npm support
ignore node_modules folder
2015-05-28 15:41:53 +03:00
Vaidas Lungis 5fa592ca3f update gitignore for vagrant 2014-12-11 12:43:31 +02:00
fordnox 5af4cc20d9 Initial release 2014-11-03 09:00:47 +02:00