Skip to content

Commit 85d6fef

Browse files
committed
Removed test code. Updated tests.
Removed test code. Updated test to do the action rest_api_init and then check if post and page are registered for preview links actions.
1 parent a8bdb73 commit 85d6fef

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

plugins/faustwp/includes/replacement/callbacks.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -338,27 +338,6 @@ function register_preview_link_hooks_for_all_draft_post_types() {
338338
}
339339
}
340340

341-
add_filter( 'rest_post_dispatch', __NAMESPACE__ . '\\rest_post_dispatch', 10, 3 );
342-
343-
/**
344-
* Adds the preview link to rest responses.
345-
*
346-
* @param WP_HTTP_Response $response The rest response object.
347-
* @param WP_REST_Server $post Post object.
348-
* @param WP_REST_Request $request The request object.
349-
*
350-
* @return WP_REST_Response The rest response object.
351-
*/
352-
function rest_post_dispatch( $response, $post, $request ) {
353-
354-
if ( isset( $post->post_status ) && 'draft' === $post->post_status ) {
355-
$response->data['link'] = get_preview_post_link( $post->ID );
356-
}
357-
358-
return $response;
359-
}
360-
361-
362341
/**
363342
* Adds the preview link to rest responses.
364343
*

plugins/faustwp/tests/integration/ReplacementCallbacksTests.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ public function test_preview_post_link_filter() {
4848
$this->assertSame( 1000, has_action( 'preview_post_link', 'WPE\FaustWP\Replacement\post_preview_link' ) );
4949
}
5050

51-
public function test_preview_rest_prepare_post_filter() {
51+
public function test_rest_api_init_filter() {
52+
$this->assertSame( 10, has_action( 'rest_api_init', 'WPE\FaustWP\Replacement\register_preview_link_hooks_for_all_draft_post_types' ) );
53+
do_action( 'rest_api_init' );
5254
$this->assertSame( 10, has_action( 'rest_prepare_post', 'WPE\FaustWP\Replacement\preview_link_in_rest_response' ) );
53-
}
54-
55-
public function test_preview_rest_prepare_page_filter() {
5655
$this->assertSame( 10, has_action( 'rest_prepare_page', 'WPE\FaustWP\Replacement\preview_link_in_rest_response' ) );
5756
}
5857

0 commit comments

Comments
 (0)