forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickEdit.php
More file actions
86 lines (76 loc) · 2.03 KB
/
QuickEdit.php
File metadata and controls
86 lines (76 loc) · 2.03 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
<?php
/**
* Admin Ajax functions to be tested.
*/
require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Quick Edit AJAX functionality.
*
* @group ajax
*/
class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase {
/**
* @ticket 26948
*/
public function test_dont_process_terms_if_taxonomy_does_not_allow_show_on_quick_edit() {
register_taxonomy(
'wptests_tax_1',
'post',
array(
'show_in_quick_edit' => false,
'hierarchical' => true,
)
);
register_taxonomy(
'wptests_tax_2',
'post',
array(
'show_in_quick_edit' => true,
'hierarchical' => true,
)
);
$t1 = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax_1',
)
);
$t2 = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax_2',
)
);
// Become an administrator.
$this->_setRole( 'administrator' );
$post = self::factory()->post->create_and_get(
array(
'post_author' => get_current_user_id(),
)
);
// Set up a request.
$_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' );
$_POST['post_ID'] = $post->ID;
$_POST['post_type'] = $post->post_type;
$_POST['content'] = $post->post_content;
$_POST['excerpt'] = $post->post_excerpt;
$_POST['_status'] = $post->post_status;
$_POST['post_status'] = $post->post_status;
$_POST['screen'] = 'post';
$_POST['post_view'] = 'excerpt';
$_POST['tax_input'] = array(
'wptests_tax_1' => array( $t1 ),
'wptests_tax_2' => array( $t2 ),
);
// Make the request.
try {
$this->_handleAjax( 'inline-save' );
} catch ( WPAjaxDieContinueException $e ) {
unset( $e );
}
// 'wptests_tax_1' terms should have been refused.
$post_terms_1 = wp_get_object_terms( $post->ID, 'wptests_tax_1' );
$this->assertEmpty( $post_terms_1 );
// 'wptests_tax_2' terms should have been added successfully.
$post_terms_2 = wp_get_object_terms( $post->ID, 'wptests_tax_2' );
$this->assertSameSets( array( $t2 ), wp_list_pluck( $post_terms_2, 'term_id' ) );
}
}