mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -30,7 +30,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
remove_role( 'grammarian' );
|
||||
}
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
wp_set_current_user( self::$editor_id );
|
||||
@@ -42,14 +42,14 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* Helper function: return the timestamp(s) of cron jobs for the specified hook and post.
|
||||
*/
|
||||
function _next_schedule_for_post( $hook, $id ) {
|
||||
private function next_schedule_for_post( $hook, $id ) {
|
||||
return wp_next_scheduled( 'publish_future_post', array( 0 => (int) $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function, unsets current user globally.
|
||||
*/
|
||||
function _unset_current_user() {
|
||||
private function unset_current_user() {
|
||||
global $current_user, $user_ID;
|
||||
|
||||
$current_user = null;
|
||||
@@ -59,7 +59,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test simple valid behavior: insert and get a post.
|
||||
*/
|
||||
function test_vb_insert_get_delete() {
|
||||
public function test_vb_insert_get_delete() {
|
||||
register_post_type( 'cpt', array( 'taxonomies' => array( 'post_tag', 'ctax' ) ) );
|
||||
register_taxonomy( 'ctax', 'cpt' );
|
||||
$post_types = array( 'post', 'cpt' );
|
||||
@@ -120,7 +120,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* Insert a post with a future date, and make sure the status and cron schedule are correct.
|
||||
*/
|
||||
function test_vb_insert_future() {
|
||||
public function test_vb_insert_future() {
|
||||
$future_date = strtotime( '+1 day' );
|
||||
|
||||
$post = array(
|
||||
@@ -148,13 +148,13 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// There should be a publish_future_post hook scheduled on the future date.
|
||||
$this->assertSame( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a post with a future date, and make sure the status and cron schedule are correct.
|
||||
*/
|
||||
function test_vb_insert_future_over_dst() {
|
||||
public function test_vb_insert_future_over_dst() {
|
||||
// Some magic days - one DST one not.
|
||||
$future_date_1 = strtotime( 'June 21st +1 year' );
|
||||
$future_date_2 = strtotime( 'Jan 11th +1 year' );
|
||||
@@ -177,7 +177,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// Check that there's a publish_future_post job scheduled at the right time.
|
||||
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
// Now save it again with a date further in the future.
|
||||
|
||||
@@ -192,7 +192,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// And the correct date on the cron job.
|
||||
$this->assertSame( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_2, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 4710
|
||||
*/
|
||||
function test_vb_insert_future_edit_bug() {
|
||||
public function test_vb_insert_future_edit_bug() {
|
||||
$future_date_1 = strtotime( '+1 day' );
|
||||
$future_date_2 = strtotime( '+2 day' );
|
||||
|
||||
@@ -222,7 +222,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// Check that there's a publish_future_post job scheduled at the right time.
|
||||
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
// Now save it again with a date further in the future.
|
||||
|
||||
@@ -237,13 +237,13 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// And the correct date on the cron job.
|
||||
$this->assertSame( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_2, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a draft post with a future date, and make sure no cron schedule is set.
|
||||
*/
|
||||
function test_vb_insert_future_draft() {
|
||||
public function test_vb_insert_future_draft() {
|
||||
$future_date = strtotime( '+1 day' );
|
||||
|
||||
$post = array(
|
||||
@@ -271,14 +271,14 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// There should be a publish_future_post hook scheduled on the future date.
|
||||
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a future post, then edit and change it to draft, and make sure cron gets it right.
|
||||
*/
|
||||
function test_vb_insert_future_change_to_draft() {
|
||||
public function test_vb_insert_future_change_to_draft() {
|
||||
$future_date_1 = strtotime( '+1 day' );
|
||||
|
||||
$post = array(
|
||||
@@ -299,7 +299,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// Check that there's a publish_future_post job scheduled at the right time.
|
||||
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
// Now save it again with status set to draft.
|
||||
|
||||
@@ -313,13 +313,13 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// And the correct date on the cron job.
|
||||
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a future post, then edit and change the status, and make sure cron gets it right.
|
||||
*/
|
||||
function test_vb_insert_future_change_status() {
|
||||
public function test_vb_insert_future_change_status() {
|
||||
$future_date_1 = strtotime( '+1 day' );
|
||||
|
||||
$statuses = array( 'draft', 'static', 'object', 'attachment', 'inherit', 'pending' );
|
||||
@@ -343,7 +343,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// Check that there's a publish_future_post job scheduled at the right time.
|
||||
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
// Now save it again with status changed.
|
||||
|
||||
@@ -357,14 +357,14 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// And the correct date on the cron job.
|
||||
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a draft post with a future date, and make sure no cron schedule is set.
|
||||
*/
|
||||
function test_vb_insert_future_private() {
|
||||
public function test_vb_insert_future_private() {
|
||||
$future_date = strtotime( '+1 day' );
|
||||
|
||||
$post = array(
|
||||
@@ -392,7 +392,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// There should be a publish_future_post hook scheduled on the future date.
|
||||
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,7 +400,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 17180
|
||||
*/
|
||||
function test_vb_insert_invalid_date() {
|
||||
public function test_vb_insert_invalid_date() {
|
||||
$post = array(
|
||||
'post_author' => self::$editor_id,
|
||||
'post_status' => 'publish',
|
||||
@@ -421,7 +421,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* Insert a future post, then edit and change it to private, and make sure cron gets it right.
|
||||
*/
|
||||
function test_vb_insert_future_change_to_private() {
|
||||
public function test_vb_insert_future_change_to_private() {
|
||||
$future_date_1 = strtotime( '+1 day' );
|
||||
|
||||
$post = array(
|
||||
@@ -442,7 +442,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// Check that there's a publish_future_post job scheduled at the right time.
|
||||
$this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
// Now save it again with status set to draft.
|
||||
|
||||
@@ -456,7 +456,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date'], $out->post_date );
|
||||
|
||||
// And the correct date on the cron job.
|
||||
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,7 +527,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 5364
|
||||
*/
|
||||
function test_delete_future_post_cron() {
|
||||
public function test_delete_future_post_cron() {
|
||||
$future_date = strtotime( '+1 day' );
|
||||
|
||||
$post = array(
|
||||
@@ -543,12 +543,12 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->post_ids[] = $id;
|
||||
|
||||
// Check that there's a publish_future_post job scheduled at the right time.
|
||||
$this->assertSame( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
|
||||
// Now delete the post and make sure the cron entry is removed.
|
||||
wp_delete_post( $id );
|
||||
|
||||
$this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
$this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,7 +558,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 5305
|
||||
*/
|
||||
function test_permalink_without_title() {
|
||||
public function test_permalink_without_title() {
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
|
||||
$post = array(
|
||||
@@ -579,7 +579,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink );
|
||||
}
|
||||
|
||||
function test_wp_publish_post() {
|
||||
public function test_wp_publish_post() {
|
||||
$draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
|
||||
|
||||
$post = get_post( $draft_id );
|
||||
@@ -594,7 +594,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 22944
|
||||
*/
|
||||
function test_wp_insert_post_and_wp_publish_post_with_future_date() {
|
||||
public function test_wp_insert_post_and_wp_publish_post_with_future_date() {
|
||||
$future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 );
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
@@ -617,7 +617,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 48145
|
||||
*/
|
||||
function test_wp_insert_post_should_default_to_publish_if_post_date_is_within_59_seconds_from_current_time() {
|
||||
public function test_wp_insert_post_should_default_to_publish_if_post_date_is_within_59_seconds_from_current_time() {
|
||||
$future_date = gmdate( 'Y-m-d H:i:s', time() + 59 );
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
@@ -633,7 +633,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 22944
|
||||
*/
|
||||
function test_publish_post_with_content_filtering() {
|
||||
public function test_publish_post_with_content_filtering() {
|
||||
kses_remove_filters();
|
||||
|
||||
$post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
|
||||
@@ -658,7 +658,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 22944
|
||||
*/
|
||||
function test_wp_publish_post_and_avoid_content_filtering() {
|
||||
public function test_wp_publish_post_and_avoid_content_filtering() {
|
||||
kses_remove_filters();
|
||||
|
||||
$post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
|
||||
@@ -678,7 +678,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23708
|
||||
*/
|
||||
function test_get_post_ancestors_within_loop() {
|
||||
public function test_get_post_ancestors_within_loop() {
|
||||
global $post;
|
||||
$parent_id = self::factory()->post->create();
|
||||
$post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) );
|
||||
@@ -688,7 +688,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23474
|
||||
*/
|
||||
function test_update_invalid_post_id() {
|
||||
public function test_update_invalid_post_id() {
|
||||
$post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
|
||||
$post = get_post( $post_id, ARRAY_A );
|
||||
|
||||
@@ -702,7 +702,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_parse_post_content_single_page() {
|
||||
public function test_parse_post_content_single_page() {
|
||||
global $multipage, $pages, $numpages;
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
|
||||
$post = get_post( $post_id );
|
||||
@@ -713,7 +713,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( array( 'Page 0' ), $pages );
|
||||
}
|
||||
|
||||
function test_parse_post_content_multi_page() {
|
||||
public function test_parse_post_content_multi_page() {
|
||||
global $multipage, $pages, $numpages;
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
|
||||
$post = get_post( $post_id );
|
||||
@@ -724,7 +724,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
|
||||
}
|
||||
|
||||
function test_parse_post_content_remaining_single_page() {
|
||||
public function test_parse_post_content_remaining_single_page() {
|
||||
global $multipage, $pages, $numpages;
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
|
||||
$post = get_post( $post_id );
|
||||
@@ -735,7 +735,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( array( 'Page 0' ), $pages );
|
||||
}
|
||||
|
||||
function test_parse_post_content_remaining_multi_page() {
|
||||
public function test_parse_post_content_remaining_multi_page() {
|
||||
global $multipage, $pages, $numpages;
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
|
||||
$post = get_post( $post_id );
|
||||
@@ -749,7 +749,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16746
|
||||
*/
|
||||
function test_parse_post_content_starting_with_nextpage() {
|
||||
public function test_parse_post_content_starting_with_nextpage() {
|
||||
global $multipage, $pages, $numpages;
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
|
||||
$post = get_post( $post_id );
|
||||
@@ -763,7 +763,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 16746
|
||||
*/
|
||||
function test_parse_post_content_starting_with_nextpage_multi() {
|
||||
public function test_parse_post_content_starting_with_nextpage_multi() {
|
||||
global $multipage, $pages, $numpages;
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
|
||||
$post = get_post( $post_id );
|
||||
@@ -777,8 +777,8 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 19373
|
||||
*/
|
||||
function test_insert_programmatic_sanitized() {
|
||||
$this->_unset_current_user();
|
||||
public function test_insert_programmatic_sanitized() {
|
||||
$this->unset_current_user();
|
||||
|
||||
register_taxonomy( 'test_tax', 'post' );
|
||||
|
||||
@@ -804,7 +804,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 24803
|
||||
*/
|
||||
function test_wp_count_posts() {
|
||||
public function test_wp_count_posts() {
|
||||
$post_type = rand_str( 20 );
|
||||
register_post_type( $post_type );
|
||||
self::factory()->post->create(
|
||||
@@ -819,7 +819,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) );
|
||||
}
|
||||
|
||||
function test_wp_count_posts_filtered() {
|
||||
public function test_wp_count_posts_filtered() {
|
||||
$post_type = rand_str( 20 );
|
||||
register_post_type( $post_type );
|
||||
self::factory()->post->create_many(
|
||||
@@ -839,12 +839,12 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
remove_filter( 'wp_count_posts', array( $this, 'filter_wp_count_posts' ) );
|
||||
}
|
||||
|
||||
function filter_wp_count_posts( $counts ) {
|
||||
public function filter_wp_count_posts( $counts ) {
|
||||
$counts->publish = 2;
|
||||
return $counts;
|
||||
}
|
||||
|
||||
function test_wp_count_posts_insert_invalidation() {
|
||||
public function test_wp_count_posts_insert_invalidation() {
|
||||
$post_ids = self::factory()->post->create_many( 3 );
|
||||
$initial_counts = wp_count_posts();
|
||||
|
||||
@@ -862,7 +862,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertNotEquals( $initial_counts->publish, $after_draft_counts->publish );
|
||||
}
|
||||
|
||||
function test_wp_count_posts_trash_invalidation() {
|
||||
public function test_wp_count_posts_trash_invalidation() {
|
||||
$post_ids = self::factory()->post->create_many( 3 );
|
||||
$initial_counts = wp_count_posts();
|
||||
|
||||
@@ -883,7 +883,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 49685
|
||||
*/
|
||||
function test_wp_count_posts_status_changes_visible() {
|
||||
public function test_wp_count_posts_status_changes_visible() {
|
||||
self::factory()->post->create_many( 3 );
|
||||
|
||||
// Trigger a cache.
|
||||
@@ -899,7 +899,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 25566
|
||||
*/
|
||||
function test_wp_tag_cloud_link_with_post_type() {
|
||||
public function test_wp_tag_cloud_link_with_post_type() {
|
||||
$post_type = 'new_post_type';
|
||||
$tax = 'new_tag';
|
||||
register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) );
|
||||
@@ -932,7 +932,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21212
|
||||
*/
|
||||
function test_utf8mb3_post_saves_with_emoji() {
|
||||
public function test_utf8mb3_post_saves_with_emoji() {
|
||||
global $wpdb;
|
||||
|
||||
if ( 'utf8' !== $wpdb->get_col_charset( $wpdb->posts, 'post_title' ) ) {
|
||||
@@ -968,7 +968,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31168
|
||||
*/
|
||||
function test_wp_insert_post_default_comment_ping_status_open() {
|
||||
public function test_wp_insert_post_default_comment_ping_status_open() {
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_author' => self::$editor_id,
|
||||
@@ -986,7 +986,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31168
|
||||
*/
|
||||
function test_wp_insert_post_page_default_comment_ping_status_closed() {
|
||||
public function test_wp_insert_post_page_default_comment_ping_status_closed() {
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_author' => self::$editor_id,
|
||||
@@ -1005,7 +1005,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31168
|
||||
*/
|
||||
function test_wp_insert_post_cpt_default_comment_ping_status_open() {
|
||||
public function test_wp_insert_post_cpt_default_comment_ping_status_open() {
|
||||
$post_type = rand_str( 20 );
|
||||
register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
|
||||
$post_id = self::factory()->post->create(
|
||||
@@ -1027,7 +1027,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31168
|
||||
*/
|
||||
function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
|
||||
public function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
|
||||
$post_type = rand_str( 20 );
|
||||
register_post_type( $post_type );
|
||||
$post_id = self::factory()->post->create(
|
||||
@@ -1052,7 +1052,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 24153
|
||||
*/
|
||||
function test_user_without_publish_cannot_affect_sticky() {
|
||||
public function test_user_without_publish_cannot_affect_sticky() {
|
||||
wp_set_current_user( self::$grammarian_id );
|
||||
|
||||
// Sanity check.
|
||||
@@ -1090,7 +1090,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 24153
|
||||
*/
|
||||
function test_user_without_publish_cannot_affect_sticky_with_edit_post() {
|
||||
public function test_user_without_publish_cannot_affect_sticky_with_edit_post() {
|
||||
// Create a sticky post.
|
||||
$post = self::factory()->post->create_and_get(
|
||||
array(
|
||||
@@ -1130,7 +1130,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 35600
|
||||
*/
|
||||
function test_hooks_fire_when_post_gets_stuck_and_unstuck() {
|
||||
public function test_hooks_fire_when_post_gets_stuck_and_unstuck() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
@@ -1158,7 +1158,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 34865
|
||||
*/
|
||||
function test_post_updates_without_slug_provided() {
|
||||
public function test_post_updates_without_slug_provided() {
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'Stuff',
|
||||
@@ -1199,7 +1199,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 15946
|
||||
*/
|
||||
function test_wp_insert_post_should_respect_post_date_gmt() {
|
||||
public function test_wp_insert_post_should_respect_post_date_gmt() {
|
||||
$post = array(
|
||||
'post_author' => self::$editor_id,
|
||||
'post_status' => 'publish',
|
||||
@@ -1220,7 +1220,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertSame( $post['post_date_gmt'], $out->post_date_gmt );
|
||||
}
|
||||
|
||||
function test_wp_delete_post_reassign_hierarchical_post_type() {
|
||||
public function test_wp_delete_post_reassign_hierarchical_post_type() {
|
||||
$grandparent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
|
||||
$parent_page_id = self::factory()->post->create(
|
||||
array(
|
||||
@@ -1247,7 +1247,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @see _wp_customize_changeset_filter_insert_post_data()
|
||||
* @ticket 30937
|
||||
*/
|
||||
function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() {
|
||||
public function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() {
|
||||
|
||||
$this->assertSame( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) );
|
||||
|
||||
@@ -1300,7 +1300,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @see wp_unique_post_slug()
|
||||
* @ticket 21112
|
||||
*/
|
||||
function test_pre_wp_unique_post_slug_filter() {
|
||||
public function test_pre_wp_unique_post_slug_filter() {
|
||||
add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 );
|
||||
|
||||
$post_id = $this->factory->post->create(
|
||||
@@ -1316,7 +1316,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
remove_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 );
|
||||
}
|
||||
|
||||
function filter_pre_wp_unique_post_slug( $default, $slug, $post_ID, $post_status, $post_type, $post_parent ) {
|
||||
public function filter_pre_wp_unique_post_slug( $default, $slug, $post_ID, $post_status, $post_type, $post_parent ) {
|
||||
return 'override-slug-' . $post_type;
|
||||
}
|
||||
|
||||
@@ -1606,7 +1606,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 52187
|
||||
*/
|
||||
function test_wp_resolve_post_date() {
|
||||
public function test_wp_resolve_post_date() {
|
||||
$post_date = '2020-12-28 11:26:35';
|
||||
$post_date_gmt = '2020-12-29 10:11:45';
|
||||
$invalid_date = '2020-12-41 14:15:27';
|
||||
@@ -1644,7 +1644,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::stick_post
|
||||
*/
|
||||
function test_stick_post_updates_option() {
|
||||
public function test_stick_post_updates_option() {
|
||||
stick_post( 1 );
|
||||
$this->assertSameSets( array( 1 ), get_option( 'sticky_posts' ) );
|
||||
|
||||
@@ -1661,7 +1661,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @param mixed $stick Value to pass to stick_post().
|
||||
*/
|
||||
function test_stick_post_does_not_duplicate_post_ids( $stick ) {
|
||||
public function test_stick_post_does_not_duplicate_post_ids( $stick ) {
|
||||
update_option( 'sticky_posts', array( 1, 2 ) );
|
||||
|
||||
stick_post( $stick );
|
||||
@@ -1677,7 +1677,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @type mixed $stick Value to pass to stick_post().
|
||||
* }
|
||||
*/
|
||||
function data_stick_post_does_not_duplicate_post_ids() {
|
||||
public function data_stick_post_does_not_duplicate_post_ids() {
|
||||
return array(
|
||||
array( 1 ),
|
||||
array( '1' ),
|
||||
@@ -1693,7 +1693,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @param mixed $stick Value to pass to stick_post().
|
||||
*/
|
||||
function test_stick_post_removes_duplicate_post_ids_when_adding_new_value() {
|
||||
public function test_stick_post_removes_duplicate_post_ids_when_adding_new_value() {
|
||||
update_option( 'sticky_posts', array( 1, 1, 2, 2 ) );
|
||||
|
||||
stick_post( 3 );
|
||||
@@ -1705,7 +1705,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::unstick_post
|
||||
*/
|
||||
function test_unstick_post_updates_option() {
|
||||
public function test_unstick_post_updates_option() {
|
||||
update_option( 'sticky_posts', array( 1 ) );
|
||||
unstick_post( 1 );
|
||||
$this->assertEmpty( get_option( 'sticky_posts' ) );
|
||||
@@ -1727,7 +1727,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @param mixed $unstick Parameter passed to `unstick_post()`
|
||||
* @param array $expected
|
||||
*/
|
||||
function test_unstick_post_removes_duplicate_post_ids( $starting_option, $unstick, $expected ) {
|
||||
public function test_unstick_post_removes_duplicate_post_ids( $starting_option, $unstick, $expected ) {
|
||||
update_option( 'sticky_posts', $starting_option );
|
||||
unstick_post( $unstick );
|
||||
$this->assertSameSets( $expected, get_option( 'sticky_posts' ) );
|
||||
@@ -1744,7 +1744,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @type array $expected
|
||||
* }
|
||||
*/
|
||||
function data_unstick_post_removes_duplicate_post_ids() {
|
||||
public function data_unstick_post_removes_duplicate_post_ids() {
|
||||
return array(
|
||||
array(
|
||||
array( 1, 1 ),
|
||||
@@ -1780,7 +1780,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @ticket 52007
|
||||
* @covers ::stick_post
|
||||
*/
|
||||
function test_stick_post_with_duplicate_post_id_does_not_update_option() {
|
||||
public function test_stick_post_with_duplicate_post_id_does_not_update_option() {
|
||||
update_option( 'sticky_posts', array( 1, 2, 2 ) );
|
||||
stick_post( 2 );
|
||||
$this->assertSameSets( array( 1, 2, 2 ), get_option( 'sticky_posts' ) );
|
||||
@@ -1792,7 +1792,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* @ticket 52007
|
||||
* @covers ::unstick_post
|
||||
*/
|
||||
function test_unstick_post_with_non_sticky_post_id_does_not_update_option() {
|
||||
public function test_unstick_post_with_non_sticky_post_id_does_not_update_option() {
|
||||
update_option( 'sticky_posts', array( 1, 2, 2 ) );
|
||||
unstick_post( 3 );
|
||||
$this->assertSameSets( array( 1, 2, 2 ), get_option( 'sticky_posts' ) );
|
||||
|
||||
Reference in New Issue
Block a user