Code is Poetry.

WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2017-11-30 23:09:33 +00:00
parent ec6a089f98
commit 8f95800d52
1103 changed files with 105978 additions and 78184 deletions
+52 -38
View File
@@ -9,11 +9,13 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
* @ticket 11863
*/
function test_trashing_a_post_should_add_trashed_suffix_to_post_name() {
$trashed_about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish'
) );
$trashed_about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
)
);
wp_trash_post( $trashed_about_page_id );
$this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name );
}
@@ -22,12 +24,14 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
* @ticket 11863
*/
public function test_trashed_suffix_should_be_added_to_post_with__trashed_in_slug() {
$trashed_about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
'post_name' => 'foo__trashed__foo',
) );
$trashed_about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
'post_name' => 'foo__trashed__foo',
)
);
wp_trash_post( $trashed_about_page_id );
$this->assertEquals( 'foo__trashed__foo__trashed', get_post( $trashed_about_page_id )->post_name );
}
@@ -36,11 +40,13 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
* @ticket 11863
*/
function test_trashed_posts_original_post_name_should_be_reassigned_after_untrashing() {
$about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish'
) );
$about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
)
);
wp_trash_post( $about_page_id );
wp_untrash_post( $about_page_id );
@@ -51,38 +57,46 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
* @ticket 11863
*/
function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_of_trashed_posts_with_the_desired_slug() {
$trashed_about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'trash'
) );
$trashed_about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'trash',
)
);
$about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish'
) );
$about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
)
);
$this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name );
$this->assertEquals( 'about', get_post( $about_page_id )->post_name );
}
/**
* @ticket 11863
*/
* @ticket 11863
*/
function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name() {
$about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish'
) );
$about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
)
);
wp_trash_post( $about_page_id );
$another_about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish'
) );
$another_about_page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish',
)
);
wp_untrash_post( $about_page_id );