Commit Graph

92 Commits

Author SHA1 Message Date
Younes ENNAJI 47eb66e874 fix: update tests for new validation requirements
Update tests that were using invalid values for HopsStamp (0 is now
invalid, must be >= 1) and update expected output format for
mainScript (now uses json_encode which produces double quotes).
2026-03-01 20:13:57 +00:00
Younes ENNAJI 162ea87330 fix: prevent memory leaks and handle errors in FlasherPlugin
- Remove DOMContentLoaded listener after it fires to prevent memory leak
- Clean up timer interval and event listeners when notification is removed
- Add null check in stringToHTML to throw clear error for invalid templates
- Store cleanup function on notification element for proper disposal

Added tests for memory leak prevention and error handling.
2026-03-01 20:10:06 +00:00
Younes ENNAJI 6d314dbc07 fix: add validation to HopsStamp and DelayStamp
HopsStamp:
- Validate hops amount must be >= 1 (positive integer)
- Negative or zero hops don't make logical sense

DelayStamp:
- Validate delay must be >= 0 (non-negative integer)
- Negative delays don't make logical sense

Both now throw InvalidArgumentException for invalid values, making
configuration errors fail fast with clear messages.
2026-03-01 20:07:54 +00:00
Younes ENNAJI ad5c0f56dd fix: validate limit criteria must be positive integer
Previously, negative limits caused array_slice() to return unexpected
results (all except last N elements) and zero returned an empty array
without clear intent.

Now throws InvalidArgumentException for values < 1, making invalid
configurations fail fast with a clear error message.
2026-03-01 20:06:53 +00:00
Younes ENNAJI fd36c2ec0c fix: validate alias attribute in PresenterCompilerPass
Add validation to ensure services tagged with 'flasher.presenter' have
the required 'alias' attribute. Previously, accessing $attributes['alias']
without checking would throw an "Undefined array key" error.

Now throws a clear InvalidArgumentException with a helpful message.
2026-03-01 20:01:12 +00:00
Younes ENNAJI 5202c86107 fix: handle invalid JSON gracefully in FlasherComponent
The json_decode() with JSON_THROW_ON_ERROR throws an exception before
the ?: operator can provide a fallback value. This caused page crashes
when invalid JSON was passed to the Blade component attributes.

Now using a helper method with try-catch to safely decode JSON and
return an empty array on failure, preventing page crashes.
2026-03-01 20:00:16 +00:00
Younes ENNAJI 9e7bb17faa fix: make OctaneListener invokable for Laravel event dispatcher
Laravel's event dispatcher expects listener classes to be invokable
(have __invoke method) when registered as a class name string.

The OctaneListener was using a handle() method which caused the
listener to never be invoked, resulting in notification state leaking
between Octane requests.

Renamed handle() to __invoke() to fix the issue.
2026-03-01 19:59:25 +00:00
Younes ENNAJI 83dc9e49dc fix: handle null public directory gracefully in InstallCommand
The getPublicDir() method can return null, but the code was directly
concatenating it with a string, which could cause unexpected behavior.

Now the command properly checks for null and returns a failure with
a clear error message instead of proceeding with an invalid path.
2026-03-01 19:57:50 +00:00
Younes ENNAJI 1d81de581b fix: escape nonce and mainScript to prevent XSS vulnerabilities
The HtmlPresenter was interpolating user-controlled values directly into
HTML attributes and JavaScript code without proper escaping, creating
XSS vulnerabilities.

Changes:
- Escape nonce with htmlspecialchars() for HTML attribute context
- Escape nonce with json_encode() for JavaScript string context
- Escape mainScript with json_encode() for JavaScript string context

Added tests to verify XSS payloads are properly escaped.
2026-03-01 19:55:49 +00:00
Younes ENNAJI 2ebdbecda6 fix: correct inverted Livewire registration condition
The condition in registerLivewire() was inverted, causing the Livewire
listener to never be registered when Livewire was actually available.

Before: returned early when Livewire class exists AND is NOT bound
After: returns early when Livewire class does NOT exist OR is NOT bound

This fixes Livewire notifications not being displayed in Livewire components.
2026-03-01 19:53:39 +00:00
Younes ENNAJI 851e0a00ed improve Translator test coverage to 100% 2026-02-26 06:13:13 +00:00
Younes ENNAJI d9b0b6998e add tests for FlasherDataCollector 2026-02-26 06:04:11 +00:00
Younes ENNAJI ed992d78f6 add tests for FlasherAssert and Constraint classes 2026-02-25 20:45:32 +00:00
Younes ENNAJI c9a61ba69c add tests for helper functions 2026-02-25 20:29:51 +00:00
Younes ENNAJI f9746f607b add Laravel Facade tests 2026-02-25 20:22:38 +00:00
Younes ENNAJI 18c2233baa add tests for remaining Criteria classes 2026-02-25 20:01:29 +00:00
Younes ENNAJI 08c242b45a fix test to properly suppress expected console error 2026-02-25 19:50:01 +00:00
Younes ENNAJI cd53ceb139 improve test coverage for edge cases 2026-02-25 19:31:21 +00:00
Younes ENNAJI 549c36eeee improve test coverage for PHPUnit and Vitest 2026-02-25 19:16:53 +00:00
Younes ENNAJI d33de77835 add vitest for JS/TS testing with comprehensive test coverage 2026-02-25 15:52:21 +00:00
Younes ENNAJI c5059adac7 fix PHPStan errors in ThemeTemplatesTest 2026-02-25 11:34:09 +00:00
Younes ENNAJI 4145b870dd fix PHPStan errors in SessionBag 2026-02-25 11:34:01 +00:00
Younes ENNAJI f20bdebda0 add bootstrap and tailwindcss theme templates for Laravel 2026-02-25 11:20:29 +00:00
Younes ENNAJI f9807e91e2 add FallbackSession for stateless requests in Laravel 2026-02-25 11:15:34 +00:00
Younes ENNAJI 670e40dc97 fix StampsCriteria comparing values instead of keys 2026-02-25 10:43:44 +00:00
Younes ENNAJI 2b0e736d28 fix multi-field sorting in OrderByCriteria 2026-02-25 10:43:36 +00:00
Younes ENNAJI d65300a0e9 Fix PHPStan errors and test failures, improve PHPDoc documentation ordering 2026-01-10 04:36:16 +01:00
Younes ENNAJI 93ca18a67b add themes to symfony configuration 2025-03-27 21:23:53 +00:00
Younes ENNAJI 08b96bdd39 chore: enhance type safety with detailed PHPDoc annotations and stricter PHPStan validations 2024-10-13 21:39:22 +01:00
Younes ENNAJI 43affdc543 chore: add Symfony Profiler integration for PHPFlasher 2024-10-05 15:34:57 +01:00
Younes ENNAJI 58ca234a37 chore: upgrade dependencies 2024-09-21 18:33:59 +01:00
Younes ENNAJI d59e37812d chore: run php-cs-fixer 2024-09-19 06:42:10 +01:00
Younes ENNAJI b28525d718 chore: add and run phpstan phpunit 2024-05-27 00:34:47 +01:00
Younes ENNAJI 6de67f7fb3 chore: Refactor middleware to use Symfony's base response class
This commit updates the FlasherMiddleware and SessionMiddleware to utilize Symfony's base response class instead of Laravel's. This change ensures broader compatibility and addresses the issue with flash message rendering after page refreshes as identified by the community. Preparing for release in v2.0.2.
2024-05-26 13:20:48 +01:00
Younes ENNAJI f61a7d83ce test: add tests for FlasherMiddleware and SessionMiddleware registration 2024-05-24 13:33:25 +01:00
Younes ENNAJI 39f1f3885e chore: fix phpstan bleeding edge errors 2024-05-13 10:24:42 +01:00
Younes ENNAJI d2f019fb62 chore: update the doc and improve phpstan annotations 2024-05-05 19:44:39 +01:00
Younes ENNAJI 7f19ab0570 chore: follow symfony best practices for bundle names 2024-04-09 14:20:55 +00:00
Younes ENNAJI 1f4ea40a39 chore: v2 full rewrite 2024-04-09 07:57:01 +00:00
Younes ENNAJI 117b4815c7 chore: use php v5.3 syntax 2023-12-16 18:11:36 +01:00
Younes ENNAJI c2a013d1e9 chore: fix unit tests 2023-12-16 18:07:27 +01:00
Younes ENNAJI 39201b888f chore: bump flasher assets to v1.3.2 2023-12-16 17:58:59 +01:00
Khoubza Younes eb0244ae37 fix: loading flasher styles correctly 2023-06-06 11:26:33 +01:00
Khoubza Younes 4d62fa3548 feat: set flasher scripts and styles on top level config 2023-06-06 01:36:57 +01:00
Khoubza Younes 8ca1c6fd8e test: add criteria builder tests 2023-02-05 18:52:19 +01:00
Khoubza Younes 590d39b37f test: fix response envelopes order 2023-02-05 17:41:22 +01:00
Khoubza Younes 781e045155 test: add resource manager tests 2023-02-05 17:22:42 +01:00
Khoubza Younes 2faedb15c9 test: add response manager tests 2023-02-05 17:22:24 +01:00
Khoubza Younes e084ac1102 test: add response class tests 2023-02-05 17:22:00 +01:00
Khoubza Younes fab8a9ecb6 test: test html renderer it retruen only envelopes as json object 2023-02-05 12:41:59 +01:00