wp-api-meta-endpoints icon indicating copy to clipboard operation
wp-api-meta-endpoints copied to clipboard

Unit Tests: Post Meta - Invalid Meta ID should be set to a non-numeric value instead of -1

Open kjbenk opened this issue 9 years ago • 0 comments

Currently in the Post Meta unit test class the invalid meta id check will change the value of the meta_id to -1 which does not perform the action I think you want it to.

When you pass a value of -1 for the meta_id to the get_metadata_by_mid()* function it will then covert it to 1 from the function absint()**.

An example of this is here: https://github.com/WP-API/wp-api-meta-endpoints/blob/master/tests/test-rest-meta-posts-controller.php#L938.

I think we should instead use a string for the invalid meta_id since it will throw and error no matter what at this line https://github.com/WordPress/WordPress/blob/571e14f897e92c6d330e89d4560f02fa7a958509/wp-includes/meta.php#L570.

References:

** https://github.com/WordPress/WordPress/blob/571e14f897e92c6d330e89d4560f02fa7a958509/wp-includes/meta.php#L556-L595 *** https://github.com/WordPress/WordPress/blob/master/wp-includes/functions.php#L3604-L3614

kjbenk avatar Feb 23 '16 22:02 kjbenk