forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpInsertPost.php
More file actions
92 lines (80 loc) · 2.62 KB
/
wpInsertPost.php
File metadata and controls
92 lines (80 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* @group post
*/
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'
) );
wp_trash_post( $trashed_about_page_id );
$this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name );
}
/**
* @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',
) );
wp_trash_post( $trashed_about_page_id );
$this->assertEquals( 'foo__trashed__foo__trashed', get_post( $trashed_about_page_id )->post_name );
}
/**
* @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'
) );
wp_trash_post( $about_page_id );
wp_untrash_post( $about_page_id );
$this->assertEquals( 'about', get_post( $about_page_id )->post_name );
}
/**
* @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'
) );
$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
*/
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'
) );
wp_trash_post( $about_page_id );
$another_about_page_id = self::factory()->post->create( array(
'post_type' => 'page',
'post_title' => 'About',
'post_status' => 'publish'
) );
wp_untrash_post( $about_page_id );
$this->assertEquals( 'about', get_post( $another_about_page_id )->post_name );
$this->assertEquals( 'about-2', get_post( $about_page_id )->post_name );
}
}