[WIP]PR#22 ( renderFeaturedImageIDField ) #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR adds a unit and integration test for the function
render_featured_image_id_field()in theextend-give-wpplugin. The callback is registered to WordPress from within the plugin functioninitialize_option_settings(). The function renders an HTML view file as part of the Featured Image ID settings field. It returnsvoid.The relative file path within the plugin to the function under test is:
============================================
@hellofromtonya
Issues - Unit
The test method runs 2 test scenarios.
Scenario 1: ‘featured-image-id’ => 0, and ‘expected_view’ => ‘’.
Scenario 2: ‘featured-image-id’ => 144, and ‘expected_view’ => <<<HMTL_VIEW.
The source code gets the option value, assigns it to a variable, and then conditionally checks that the variable is set. If no, then return 0.
I added a guardrail condition to the source code that if the variable is falsey ( 0 ), return early.
In the second test scenario, the actual HTML view file is falsey (returns empty string).
function render_featured_image_id_field() {$options = get_option( 'extend-give-wp', [] );$attachment_id = isset( $options['featured-image-id'] ) ? (int) $options['featured-image-id'] : 0;Inside the unit test, I ran the following test assertion (which I did not commit).
This is a similar issue to PR#11.
Issues - Integration
Same as the unit test above.