Closed mrabbani closed 2 months ago
[!IMPORTANT]
Review skipped
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yaml
file in this repository. To trigger a single review, invoke the@coderabbitai review
command.You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
The updates encompass enhancements mainly in test infrastructure and refinement of the registration process. Key additions include TDD documentation, efficient test data creation through factories, and refactored nonce validation logic. These changes aim to streamline testing and ensure robust, maintainable code, including crucial adjustments for integration with the Blocksy theme.
Files | Change Summary |
---|---|
composer.json |
Updated PSR-4 autoload mappings and added scripts for running PHPUnit tests. |
docs/tdd/factories.md , docs/tdd/readme.md |
Added documentation on test data factories and TDD workflow. |
includes/Registration.php |
Refactored nonce validation logic by adding a centralized validate_nonce method and updated related methods. |
phpunit.xml |
Updated file paths in PHPUnit configuration. |
tests/php/DokanTestCase.php |
Introduced abstract class DokanTestCase with methods for creating fixtures and asserting database states. |
tests/php/CommissionTest.php , .../CustomFactoriesTest.php |
Updated namespaces, class names, and formatting for tests. Added CustomFactoriesTest class with methods for creating various test entities. |
tests/php/Factories/*.php |
Added new factories (e.g., ProductFactory , OrderFactory , CouponFactory , etc.) to facilitate creation and manipulation of test data objects. |
tests/php/Helpers/*.php |
Introduced new helper classes (e.g., WC_Helper_Coupon , WC_Helper_Customer , WC_Helper_Order ) for managing WooCommerce entities in tests. |
sequenceDiagram
participant User
participant BlocksyTheme
participant DokanRegistration
User->>BlocksyTheme: Register using modal
BlocksyTheme->>DokanRegistration: Initiate vendor registration
DokanRegistration->>DokanRegistration: validate_nonce
DokanRegistration->>DokanRegistration: set_new_vendor_names
DokanRegistration->DokanRegistration: save_vendor_info
DokanRegistration->>BlocksyTheme: Registration success response
BlocksyTheme->>User: Vendor registered
Objective | Addressed | Explanation |
---|---|---|
Add hook dokan_register_nonce_check to set_new_vendor_names and save_vendor_info (#2279) |
✅ |
Amidst the code and tests, lines did appear,
A rabbit worked hard, with focus so clear. 🐇
Factories sprouted, to ease the dev’s plight,
Ensuring code's sturdy, in day or in night.
Dokan now stronger, with nonce safe and sound,
Bugs bounced away, in tests they were found.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All Submissions:
Changes proposed in this Pull Request:
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
Changelog entry
Enable to bypass the nonce verification
Verify nonce through method call which enable third-party developers to override the nonce check if necessary.
Bypass nonce:
add_filter( 'dokan_register_nonce_check', '__return_false' )
;Before Changes
Describe the issue before changes with screenshots(s).
After Changes
Describe the issue after changes with screenshot(s).
Feature Video (optional)
Link of detailed video if this PR is for a feature.
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
Documentation
docs/tdd/readme.md
.docs/tdd/factories.md
for efficient test data creation using factory classes.Refactor
New Features
DokanTestCase
for fixture creation and database assertions.Tests