Skip to content

Conversation

@rgadon107
Copy link
Owner

@rgadon107 rgadon107 commented May 17, 2020

PR Summary

This PR adds a unit and integration test for the function render_option_page_template() in the extend-give-wp plugin. The callback is the 6th parameter passed to add_submenu_page() within the function add_option_settings_page(). The function under test outputs the plugin's option page template in the WordPress admin at: /wp-admin/options-general.php?page=extend-give-wp.

The relative file path within the plugin to the function under test is:

extend-give-wp/src/admin/option-settings-admin.php.

Issues -- Integration Test

The assertion ( assertEquals() ) within the integration test method fails.

The function under test is invoked from within the function add_option_settings_page() when the admin_menu action event files.

While building the integration test method, I inspected the value of (has_filter( ‘admin_menu’, ‘spiralWebDb\ExtendGiveWP\Admin\add_option_settings_page’). It returns the priority level of the callback registered to the event.

I called do_action( ‘admin_menu’, ‘’ ); within the test method, with the intent of invoking add_option_settings_page(), and then invoking render_option_page_template(). I then ran render_option_page_template() through the output buffer to return the actual view from the buffer. The buffer returned falsey ( empty string ).

At present, the integration test is work-in-progress [WIP].

rgadon107 added 2 commits May 17, 2020 14:51
- The markup layout in the expected HTML view is askew due to how the actual HTML view is processed in the IDE. Test passes.
- do_action ('admin_menu', '' ) has callback 'add_option_settings_page' registered to it. 
- callback 'render_option_page_template' is registered when 'add_submenu_page' is invoked inside 'add_option_settings_page'.
- Output buffer returns falsey (empty string). 
- Test assertion fails. $actual_view returns falsey ( empty string ).
@rgadon107 rgadon107 self-assigned this May 17, 2020
@rgadon107 rgadon107 added [WIP]code review Request CR for work in progress would like to discuss Requesting discussion on one or more items in PR labels May 17, 2020
@rgadon107 rgadon107 requested a review from hellofromtonya May 19, 2020 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[WIP]code review Request CR for work in progress would like to discuss Requesting discussion on one or more items in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants