Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fold the hidden post type test into the exposure helper
  • Loading branch information
jorgefilipecosta committed Oct 2, 2026
commit 09d114920255a4c828036637c902e4c8e9a54aa0
Original file line number Diff line number Diff line change
Expand Up @@ -590,36 +590,6 @@ public function test_post_type_without_rest_is_exposed_by_opt_in(): void {
$this->assertSame( 'rest_cannot_read_type', $response->as_error()->get_error_code(), 'REST should not serve the post type.' );
}

/**
* A hidden post type and a missing one cannot be told apart.
*
* @since x.x.x
*/
public function test_hidden_and_missing_post_types_are_denied_alike(): void {
$this->register_test_post_type(
'wpai_hidden',
array(
'public' => true,
'show_in_rest' => true,
)
);
$this->login_as( 'administrator' );
$this->register_ability();

$hidden = array( 'slug' => 'wpai_hidden' );
$missing = array( 'slug' => 'wpai_missing' );

$post_types = new Post_Types();
$this->assertFalse( $post_types->check_permission( $hidden ), 'A hidden post type should be denied.' );
$this->assertFalse( $post_types->check_permission( $missing ), 'A missing post type should be denied.' );
$this->assertEquals( $post_types->execute_post_types_query( $missing ), $post_types->execute_post_types_query( $hidden ), 'A direct call should report a hidden post type like a missing one.' );

$hidden_result = $this->query_post_types( $hidden );
$missing_result = $this->query_post_types( $missing );
$this->assertAbilityError( $hidden_result, 'ability_invalid_input', 'A hidden post type should fail validation.' );
$this->assertEquals( $missing_result, $hidden_result, 'A hidden post type should fail validation like a missing one.' );
}

/**
* A post type hidden after the ability registered is denied like one unregistered since.
*
Expand Down Expand Up @@ -879,6 +849,7 @@ private function assert_post_type_is_not_exposed( string $post_type ): void {
$this->assertNotContains( $post_type, $slugs, "The {$post_type} post type should not be listed in the edit context." );

$this->assertAbilityError( $this->query_post_types( array( 'slug' => $post_type ) ), 'ability_invalid_input', "The {$post_type} post type should fail validation." );
$this->assertFalse( ( new Post_Types() )->check_permission( array( 'slug' => $post_type ) ), "The permission callback should deny the {$post_type} post type." );

$result = ( new Post_Types() )->execute_post_types_query( array( 'slug' => $post_type ) );
$this->assertAbilityError( $result, 'post_types_type_invalid', "A direct call should report the {$post_type} post type as invalid." );
Expand Down
Loading