indieweb / wordpress-micropub

A Micropub Endpoint plugin for WordPress
https://wordpress.org/plugins/micropub
51 stars 12 forks source link

Add more comprehensive tests for post status determination #261

Closed jeremyfelt closed 2 years ago

jeremyfelt commented 2 years ago

This introduces test coverage for what I believe to be the possible combinations for the visibility and post-status properties when Micropub_Endpoint::post_status() is used to set post status.

The tests flagged an issue where if visibility is set to public and there is no post-status property, then null would be returned an an error generated. It seems safe to assume a default post status when visibility is set to public, so I added another commit to help tests pass.

I originally looked into this issue and thought (🤦🏻) the issue was a string/array mix up. After digging further, I see now that this plugin requires an array value for both visibility and post-status even though the spec seems to imply a string. Other portions of the plugin check for a numeric array in addition to the string. This seems like something that could be done here, but I wanted to check before going any further.

dshanske commented 2 years ago

I'm going to review this further. I might turn to a bit more normalization.

dshanske commented 2 years ago

I'm verifying thoughts, but the plugin takes the form-encoded input and converts it to JSON to match the JSON encoded input, which should have no single properties.

dshanske commented 2 years ago

I've committed a function that ensures even if a property in JSON syntax comes in without an array, it is converted so everything is standardized.