ZIYANGSONG2003 / AI-Enhanced-WordPress-Development-Toolkit

COMP3500
3 stars 8 forks source link

B2.5 Unit Tests for User Shortcode Storage Plugin #186

Closed ZIYANGSONG2003 closed 1 month ago

ZIYANGSONG2003 commented 1 month ago

Description: This issue involves writing and implementing unit tests for the User Shortcode Storage Plugin. This plugin allows users to create custom shortcodes through a form, which are stored in a database and dynamically registered in WordPress.

The tests will verify the following functionalities:

The plugin’s ability to create the necessary database table during activation. The correct handling of user input through a shortcode submission form, ensuring proper data storage and sanitization. Dynamically registering shortcodes stored in the database and rendering them in WordPress content. Security tests to ensure user inputs are sanitized and escaped, preventing XSS and SQL injection vulnerabilities. Proper display and functionality of the shortcode form. Acceptance Criteria: Database Table Creation:

The wp_user_shortcodes table is created successfully upon plugin activation. Shortcode Submission:

Users can submit new shortcodes via the form, and they are stored correctly in the database. Shortcode names and content are properly sanitized and secured before storage. Dynamic Shortcode Registration:

Shortcodes stored in the database are dynamically registered using add_shortcode(). The shortcodes render correctly when used in posts or pages. Security Tests:

All user inputs are sanitized using sanitize_text_field() and wp_kses_post() to prevent any harmful scripts or content. Tests ensure the plugin is secure from SQL injection and XSS vulnerabilities. Shortcode Form Display:

The shortcode submission form is displayed correctly on the front end with all input fields and a submit button. Successful Output Rendering:

Once a shortcode is successfully stored, it can be used dynamically in WordPress content without errors or issues.