REST API: Improve test coverage of single user endpoint for public data.

Add test coverage for requests of a single user resource for authors of post types registered as:

- public = true, show_in_rest = true: success without auth.
- public = true, show_in_rest = false: fail without auth.
- public = false, show_in_rest = true: success without auth.
- public = false, show_in_rest = false: fail without auth.

See #38878.
Fixes #39546.


git-svn-id: https://develop.svn.wordpress.org/trunk@39913 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
James Nylen
2017-01-16 16:21:00 +00:00
parent 14e5a08f5c
commit 79589f4195
5 changed files with 133 additions and 90 deletions

View File

@@ -184,8 +184,10 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
* it has a chance to do so.
*/
protected function reset_post_types() {
foreach ( get_post_types() as $pt ) {
_unregister_post_type( $pt );
foreach ( get_post_types( array(), 'objects' ) as $pt ) {
if ( empty( $pt->tests_no_auto_unregister ) ) {
_unregister_post_type( $pt->name );
}
}
create_initial_post_types();
}