mirror of
git://develop.git.wordpress.org/
synced 2025-02-07 08:04:27 +01:00
Tests: Correctly use the factory method.
This replaces all non-static calls to the `WP_UnitTestCase_Base::factory()` method with static function calls, since the method is declared as static. This is a consistency improvement for the test suite. Follow up to [35225], [35242], [49603], [54087]. Props jrf. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@54088 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
12f5012718
commit
bfdc8eff83
@ -656,7 +656,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
$this->go_to( home_url( "/?customize_changeset_uuid=$uuid" ) );
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_status' => 'auto-draft',
|
||||
|
@ -307,7 +307,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
public function test_save_success_publish_edit() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => $uuid,
|
||||
'post_title' => 'Original',
|
||||
@ -346,7 +346,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
*/
|
||||
public function test_success_save_post_date() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => $uuid,
|
||||
'post_title' => 'Original',
|
||||
@ -446,7 +446,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
public function test_save_autosave() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => $uuid,
|
||||
'post_type' => 'customize_changeset',
|
||||
@ -614,12 +614,12 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
$this->assertFalse( $this->_last_response_parsed['success'] );
|
||||
$this->assertSame( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );
|
||||
|
||||
$other_user_id = $this->factory()->user->create();
|
||||
$other_user_id = self::factory()->user->create();
|
||||
|
||||
// Create auto-drafts.
|
||||
$user_auto_draft_ids = array();
|
||||
for ( $i = 0; $i < 3; $i++ ) {
|
||||
$user_auto_draft_ids[] = $this->factory()->post->create(
|
||||
$user_auto_draft_ids[] = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => wp_generate_uuid4(),
|
||||
'post_type' => 'customize_changeset',
|
||||
@ -631,7 +631,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
|
||||
}
|
||||
$other_user_auto_draft_ids = array();
|
||||
for ( $i = 0; $i < 3; $i++ ) {
|
||||
$other_user_auto_draft_ids[] = $this->factory()->post->create(
|
||||
$other_user_auto_draft_ids[] = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => wp_generate_uuid4(),
|
||||
'post_type' => 'customize_changeset',
|
||||
|
@ -706,7 +706,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
$this->assertSame( 'bad_nonce', $response['data'] );
|
||||
|
||||
// Bad nonce.
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
||||
$_POST = wp_slash(
|
||||
array(
|
||||
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
|
||||
@ -719,7 +719,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
|
||||
$this->assertSame( 'customize_not_allowed', $response['data'] );
|
||||
|
||||
// Missing params.
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$_POST = wp_slash(
|
||||
array(
|
||||
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
|
||||
|
@ -421,7 +421,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
'user_email' => "mail\'@example.com",
|
||||
'user_pass' => 'password',
|
||||
);
|
||||
$this->factory()->user->create( $user_args );
|
||||
self::factory()->user->create( $user_args );
|
||||
|
||||
$_POST['log'] = $user_args['user_email'];
|
||||
$_POST['pwd'] = $user_args['user_pass'];
|
||||
@ -436,7 +436,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
* @covers ::wp_validate_application_password
|
||||
*/
|
||||
public function test_application_password_authentication() {
|
||||
$user_id = $this->factory()->user->create(
|
||||
$user_id = self::factory()->user->create(
|
||||
array(
|
||||
'user_login' => 'http_auth_login',
|
||||
'user_pass' => 'http_auth_pass', // Shouldn't be allowed for API login.
|
||||
|
@ -36,7 +36,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
|
||||
'post_excerpt' => '',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
setup_postdata( $post );
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
'post_title' => 'Example',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
|
||||
global $wp_rest_server;
|
||||
$wp_rest_server = new Spy_REST_Server;
|
||||
|
@ -138,7 +138,7 @@ class Tests_Comment_CheckComment extends WP_UnitTestCase {
|
||||
* @ticket 28603
|
||||
*/
|
||||
public function test_should_return_true_when_comment_previously_approved_is_enabled_and_user_has_previously_approved_comments_with_different_email() {
|
||||
$subscriber_id = $this->factory()->user->create(
|
||||
$subscriber_id = self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'subscriber',
|
||||
'email' => 'sub@example.com',
|
||||
@ -170,7 +170,7 @@ class Tests_Comment_CheckComment extends WP_UnitTestCase {
|
||||
* @ticket 28603
|
||||
*/
|
||||
public function test_should_return_false_when_comment_previously_approved_is_enabled_and_user_does_not_have_a_previously_approved_comment_with_any_email() {
|
||||
$subscriber_id = $this->factory()->user->create(
|
||||
$subscriber_id = self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'subscriber',
|
||||
'email' => 'zig@example.com',
|
||||
|
@ -26,7 +26,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
*/
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
|
||||
$this->wp_customize = $GLOBALS['wp_customize'];
|
||||
@ -138,21 +138,21 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
$this->assertStringContainsString( '<option value="0">', $content, 'Dropdown-pages renders select even without any pages published.' );
|
||||
|
||||
// Ensure that auto-draft pages are included if they are among the nav_menus_created_posts.
|
||||
$auto_draft_page_id = $this->factory()->post->create(
|
||||
$auto_draft_page_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'auto-draft',
|
||||
'post_title' => 'Auto Draft Page',
|
||||
)
|
||||
);
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'auto-draft',
|
||||
'post_title' => 'Orphan Auto Draft Page',
|
||||
)
|
||||
);
|
||||
$auto_draft_post_id = $this->factory()->post->create(
|
||||
$auto_draft_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'auto-draft',
|
||||
|
@ -120,7 +120,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
$this->assertNull( wp_get_custom_css_post( 'twentyten' ) );
|
||||
|
||||
$original_css = 'body { color: black; }';
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $this->setting->stylesheet,
|
||||
'post_name' => $this->setting->stylesheet,
|
||||
@ -130,7 +130,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
$twentyten_css = 'body { color: red; }';
|
||||
$twentyten_post_id = $this->factory()->post->create(
|
||||
$twentyten_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'twentyten',
|
||||
'post_name' => 'twentyten',
|
||||
@ -273,7 +273,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
$this->setting->default = '/*default*/';
|
||||
$this->assertSame( '/*default*//*filtered*/', $this->setting->value() );
|
||||
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $this->setting->stylesheet,
|
||||
'post_name' => $this->setting->stylesheet,
|
||||
@ -310,7 +310,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_update_filter() {
|
||||
$original_css = 'body { color:red; }';
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $this->setting->stylesheet,
|
||||
'post_name' => $this->setting->stylesheet,
|
||||
|
@ -162,7 +162,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_constructor_deferred_changeset_uuid() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$other_admin_user_id = $this->factory()->user->create( array( 'role' => 'admin' ) );
|
||||
$other_admin_user_id = self::factory()->user->create( array( 'role' => 'admin' ) );
|
||||
|
||||
$data = array(
|
||||
'blogname' => array(
|
||||
@ -171,7 +171,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$uuid1 = wp_generate_uuid4();
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_name' => $uuid1,
|
||||
@ -187,7 +187,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* as in non-branching mode there should only be one pending changeset at a time.
|
||||
*/
|
||||
$uuid2 = wp_generate_uuid4();
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_name' => $uuid2,
|
||||
@ -424,7 +424,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_find_changeset_post_id() {
|
||||
$uuid = wp_generate_uuid4();
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => $uuid,
|
||||
'post_type' => 'customize_changeset',
|
||||
@ -454,7 +454,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
|
||||
$uuid = wp_generate_uuid4();
|
||||
$wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => $uuid,
|
||||
'post_type' => 'customize_changeset',
|
||||
@ -482,7 +482,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'blogname' => array( 'value' => 'Hello World' ),
|
||||
'blogdescription' => array( 'value' => 'Greet the world' ),
|
||||
);
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => $uuid,
|
||||
'post_type' => 'customize_changeset',
|
||||
@ -565,14 +565,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'post_name' => 'canola',
|
||||
)
|
||||
);
|
||||
$existing_published_home_page_id = $this->factory()->post->create(
|
||||
$existing_published_home_page_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => 'home',
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
$existing_auto_draft_about_page_id = $this->factory()->post->create(
|
||||
$existing_auto_draft_about_page_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => 'about',
|
||||
'post_type' => 'page',
|
||||
@ -820,7 +820,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
public function test_import_theme_starter_content_with_nested_arrays() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
|
||||
$existing_published_home_page_id = $this->factory()->post->create(
|
||||
$existing_published_home_page_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => 'home',
|
||||
'post_type' => 'page',
|
||||
@ -1878,7 +1878,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$r = $wp_customize->save_changeset_post(
|
||||
array(
|
||||
'autosave' => true,
|
||||
'user_id' => $this->factory()->user->create( array( 'role' => 'administrator' ) ),
|
||||
'user_id' => self::factory()->user->create( array( 'role' => 'administrator' ) ),
|
||||
)
|
||||
);
|
||||
$this->assertSame( 'illegal_autosave_with_non_current_user', $r->get_error_code() );
|
||||
@ -2031,7 +2031,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertGreaterThan( 2, count( $new_sidebars_widgets['sidebar-1'] ) );
|
||||
$new_sidebar_1 = array_reverse( $new_sidebars_widgets['sidebar-1'] );
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_status' => 'draft',
|
||||
@ -2335,7 +2335,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'value' => 'Changeset Tagline',
|
||||
),
|
||||
);
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_status' => 'auto-draft',
|
||||
@ -2830,7 +2830,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
}
|
||||
$this->assertFalse( $this->manager->has_published_pages() );
|
||||
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'private',
|
||||
@ -2838,7 +2838,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
);
|
||||
$this->assertFalse( $this->manager->has_published_pages() );
|
||||
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
@ -2864,7 +2864,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$setting_id = 'nav_menus_created_posts';
|
||||
$setting = $this->manager->get_setting( $setting_id );
|
||||
$this->assertInstanceOf( 'WP_Customize_Filter_Setting', $setting );
|
||||
$auto_draft_page = $this->factory()->post->create(
|
||||
$auto_draft_page = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'auto-draft',
|
||||
|
@ -851,11 +851,11 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_sanitize_nav_menus_created_posts() {
|
||||
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
|
||||
$contributor_user_id = $this->factory()->user->create( array( 'role' => 'contributor' ) );
|
||||
$author_user_id = $this->factory()->user->create( array( 'role' => 'author' ) );
|
||||
$administrator_user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
$contributor_user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
|
||||
$author_user_id = self::factory()->user->create( array( 'role' => 'author' ) );
|
||||
$administrator_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
|
||||
$contributor_post_id = $this->factory()->post->create(
|
||||
$contributor_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'auto-draft',
|
||||
'post_title' => 'Contributor Post',
|
||||
@ -863,7 +863,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'post_author' => $contributor_user_id,
|
||||
)
|
||||
);
|
||||
$author_post_id = $this->factory()->post->create(
|
||||
$author_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'auto-draft',
|
||||
'post_title' => 'Author Post',
|
||||
@ -871,7 +871,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'post_author' => $author_user_id,
|
||||
)
|
||||
);
|
||||
$administrator_post_id = $this->factory()->post->create(
|
||||
$administrator_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'auto-draft',
|
||||
'post_title' => 'Admin Post',
|
||||
@ -880,7 +880,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$draft_post_id = $this->factory()->post->create(
|
||||
$draft_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'draft',
|
||||
'post_title' => 'Draft',
|
||||
@ -888,7 +888,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$private_post_id = $this->factory()->post->create(
|
||||
$private_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'private',
|
||||
'post_title' => 'Private',
|
||||
@ -990,7 +990,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
$post_ids[] = $r->ID;
|
||||
$trashed_post_id = $r->ID;
|
||||
|
||||
$pre_published_post_id = $this->factory()->post->create( array( 'post_status' => 'publish' ) );
|
||||
$pre_published_post_id = self::factory()->post->create( array( 'post_status' => 'publish' ) );
|
||||
|
||||
$setting_id = 'nav_menus_created_posts';
|
||||
$this->wp_customize->set_post_value( $setting_id, array_merge( $post_ids, array( $pre_published_post_id ) ) );
|
||||
|
@ -137,7 +137,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Setting::value()
|
||||
*/
|
||||
public function test_preview_standard_types_non_multidimensional() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
|
||||
|
||||
// Try non-multidimensional settings.
|
||||
@ -216,7 +216,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Setting::value()
|
||||
*/
|
||||
public function test_preview_standard_types_multidimensional() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
|
||||
|
||||
foreach ( $this->standard_type_configs as $type => $type_options ) {
|
||||
@ -362,7 +362,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Setting::preview()
|
||||
*/
|
||||
public function test_preview_custom_type() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$type = 'custom_type';
|
||||
$post_data_overrides = array(
|
||||
"unset_{$type}_with_post_value" => "unset_{$type}_without_post_value\\o/",
|
||||
@ -551,7 +551,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @ticket 31428
|
||||
*/
|
||||
public function test_is_current_blog_previewed() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$type = 'option';
|
||||
$name = 'blogname';
|
||||
$post_value = __FUNCTION__;
|
||||
@ -743,7 +743,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
* @ticket 37294
|
||||
*/
|
||||
public function test_multidimensional_value_when_previewed() {
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
WP_Customize_Setting::reset_aggregated_multidimensionals();
|
||||
|
||||
$initial_value = 456;
|
||||
|
@ -522,10 +522,10 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
$yesterday = gmdate( 'Y-m-d H:i:s', strtotime( '-1 day' ) );
|
||||
|
||||
// Create a post dated last week.
|
||||
$post_id = $this->factory()->post->create( array( 'post_date' => $last_week ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => $last_week ) );
|
||||
|
||||
// Create a comment dated yesterday.
|
||||
$this->factory()->comment->create(
|
||||
self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => $post_id,
|
||||
'comment_date' => $yesterday,
|
||||
@ -561,10 +561,10 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
$yesterday = gmdate( 'Y-m-d H:i:s', strtotime( '-1 day' ) );
|
||||
|
||||
// Create a post dated last week.
|
||||
$post_id = $this->factory()->post->create( array( 'post_date' => $last_week ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => $last_week ) );
|
||||
|
||||
// Create a comment dated yesterday.
|
||||
$this->factory()->comment->create(
|
||||
self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => $post_id,
|
||||
'comment_date' => $yesterday,
|
||||
@ -601,10 +601,10 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
$today = gmdate( 'Y-m-d H:i:s' );
|
||||
|
||||
// Create a post dated last week.
|
||||
$post_id = $this->factory()->post->create( array( 'post_date' => $last_week ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => $last_week ) );
|
||||
|
||||
// Create a comment dated yesterday.
|
||||
$this->factory()->comment->create(
|
||||
self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => $post_id,
|
||||
'comment_date' => $yesterday,
|
||||
@ -612,7 +612,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
// Create a post dated today.
|
||||
$this->factory()->post->create( array( 'post_date' => $today ) );
|
||||
self::factory()->post->create( array( 'post_date' => $today ) );
|
||||
|
||||
// The Last-Modified header should have the date from today's post when it is the latest update.
|
||||
add_filter(
|
||||
|
@ -60,7 +60,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
|
||||
*/
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
self::$post_id = $this->factory()->post->create(
|
||||
self::$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_excerpt' => '', // Empty excerpt, so it has to be generated.
|
||||
'post_content' => '<!-- wp:core/fake /-->',
|
||||
|
@ -89,7 +89,7 @@ class Tests_Formatting_wpTargetedLinkRel extends WP_UnitTestCase {
|
||||
$content = '<p>Links: <a href="/" target="_blank">No rel</a></p>';
|
||||
$expected = '<p>Links: <a href="/" target="_blank" rel="noopener">No rel</a></p>';
|
||||
|
||||
$post = $this->factory()->post->create_and_get(
|
||||
$post = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'post_content' => $content,
|
||||
)
|
||||
|
@ -180,7 +180,7 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_customize_preview_wp_site_icon_empty() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
@ -198,7 +198,7 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_customize_preview_wp_site_icon_dirty() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
|
||||
$wp_customize = new WP_Customize_Manager();
|
||||
@ -598,18 +598,18 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
* @covers ::get_the_archive_title
|
||||
*/
|
||||
public function test_get_the_archive_title_is_correct_for_author_queries() {
|
||||
$user_with_posts = $this->factory()->user->create_and_get(
|
||||
$user_with_posts = self::factory()->user->create_and_get(
|
||||
array(
|
||||
'role' => 'author',
|
||||
)
|
||||
);
|
||||
$user_with_no_posts = $this->factory()->user->create_and_get(
|
||||
$user_with_no_posts = self::factory()->user->create_and_get(
|
||||
array(
|
||||
'role' => 'author',
|
||||
)
|
||||
);
|
||||
|
||||
$this->factory()->post->create(
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_author' => $user_with_posts->ID,
|
||||
)
|
||||
|
@ -309,7 +309,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_excerpt' => '',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
setup_postdata( $post );
|
||||
|
||||
$expect = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat […]</p>\n";
|
||||
@ -335,7 +335,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_excerpt' => '',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
setup_postdata( $post );
|
||||
|
||||
$expect = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore […]</p>\n";
|
||||
@ -361,7 +361,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_excerpt' => '',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
setup_postdata( $post );
|
||||
|
||||
$expect = '<p>' . str_repeat( 'あ', 110 ) . " […]</p>\n";
|
||||
@ -387,7 +387,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_excerpt' => '',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
setup_postdata( $post );
|
||||
|
||||
$expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat […]';
|
||||
@ -413,7 +413,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_excerpt' => '',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create_and_get( $args );
|
||||
$post = self::factory()->post->create_and_get( $args );
|
||||
setup_postdata( $post );
|
||||
|
||||
$expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore […]';
|
||||
@ -441,7 +441,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_status' => 'draft',
|
||||
);
|
||||
|
||||
$this->factory()->post->create( $args );
|
||||
self::factory()->post->create( $args );
|
||||
|
||||
$expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do…';
|
||||
$this->expectOutputRegex( '/' . $expect . '/' );
|
||||
@ -467,7 +467,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_status' => 'draft',
|
||||
);
|
||||
|
||||
$post = $this->factory()->post->create( $args );
|
||||
$post = self::factory()->post->create( $args );
|
||||
|
||||
$expect = 'Lorem ipsum dolor sit amet, consectetur …';
|
||||
$this->expectOutputRegex( '/' . $expect . '/' );
|
||||
@ -493,7 +493,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
'post_status' => 'draft',
|
||||
);
|
||||
|
||||
$this->factory()->post->create( $args );
|
||||
self::factory()->post->create( $args );
|
||||
|
||||
$expect = str_repeat( 'あ', 40 ) . '…';
|
||||
$this->expectOutputRegex( '/' . $expect . '/' );
|
||||
@ -514,7 +514,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
$args = array(
|
||||
'comment_content' => $this->long_text,
|
||||
);
|
||||
$comment_id = $this->factory()->comment->create( $args );
|
||||
$comment_id = self::factory()->comment->create( $args );
|
||||
$expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut…';
|
||||
$comment_excerpt = get_comment_excerpt( $comment_id );
|
||||
|
||||
@ -534,7 +534,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
$args = array(
|
||||
'comment_content' => $this->long_text,
|
||||
);
|
||||
$comment_id = $this->factory()->comment->create( $args );
|
||||
$comment_id = self::factory()->comment->create( $args );
|
||||
$expect = 'Lorem ipsum dolor sit amet, consectetur …';
|
||||
$comment_excerpt = get_comment_excerpt( $comment_id );
|
||||
|
||||
@ -554,7 +554,7 @@ class Tests_L10n extends WP_UnitTestCase {
|
||||
$args = array(
|
||||
'comment_content' => str_repeat( 'あ', 200 ),
|
||||
);
|
||||
$comment_id = $this->factory()->comment->create( $args );
|
||||
$comment_id = self::factory()->comment->create( $args );
|
||||
$expect = str_repeat( 'あ', 40 ) . '…';
|
||||
$comment_excerpt = get_comment_excerpt( $comment_id );
|
||||
|
||||
|
@ -12,7 +12,7 @@ class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
|
||||
$this->user_id = $this->factory()->user->create(
|
||||
$this->user_id = self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
'locale' => 'de_DE',
|
||||
@ -82,7 +82,7 @@ class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_user_id_argument_with_id() {
|
||||
$user_id = $this->factory()->user->create(
|
||||
$user_id = self::factory()->user->create(
|
||||
array(
|
||||
'locale' => 'es_ES',
|
||||
)
|
||||
@ -99,7 +99,7 @@ class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_user_id_argument_with_wp_user_object() {
|
||||
$user_id = $this->factory()->user->create(
|
||||
$user_id = self::factory()->user->create(
|
||||
array(
|
||||
'locale' => 'es_ES',
|
||||
)
|
||||
|
@ -326,7 +326,7 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
|
||||
$site_locale = get_locale();
|
||||
|
||||
$user_id = $this->factory()->user->create(
|
||||
$user_id = self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
'locale' => 'de_DE',
|
||||
@ -378,7 +378,7 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
|
||||
$site_locale = get_locale();
|
||||
|
||||
$user_id = $this->factory()->user->create(
|
||||
$user_id = self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
'locale' => 'de_DE',
|
||||
@ -430,7 +430,7 @@ class Tests_L10n_wpLocaleSwitcher extends WP_UnitTestCase {
|
||||
|
||||
$site_locale = get_locale();
|
||||
|
||||
$user_id = $this->factory()->user->create(
|
||||
$user_id = self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
'locale' => 'en_GB',
|
||||
|
@ -561,7 +561,7 @@ if ( is_multisite() ) :
|
||||
$new_network_id = $this->_get_next_network_id();
|
||||
$this->assertNull( get_network( $new_network_id ) );
|
||||
|
||||
$new_network = $this->factory()->network->create_and_get();
|
||||
$new_network = self::factory()->network->create_and_get();
|
||||
|
||||
// Double-check we got the ID of the new network correct.
|
||||
$this->assertSame( $new_network_id, $new_network->id );
|
||||
|
@ -2459,7 +2459,7 @@ if ( is_multisite() ) :
|
||||
$new_site_id = $this->_get_next_site_id();
|
||||
$this->assertNull( get_site( $new_site_id ) );
|
||||
|
||||
$new_site = $this->factory()->blog->create_and_get();
|
||||
$new_site = self::factory()->blog->create_and_get();
|
||||
|
||||
// Double-check we got the ID of the new site correct.
|
||||
$this->assertEquals( $new_site_id, $new_site->blog_id );
|
||||
|
@ -28,7 +28,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_message() {
|
||||
$GLOBALS['post'] = $this->factory()->post->create_and_get(
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'post_title' => 'Hello World',
|
||||
)
|
||||
@ -41,7 +41,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_maybe_run_ajax_cache_should_return_javascript() {
|
||||
$GLOBALS['post'] = $this->factory()->post->create_and_get(
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'post_title' => 'Hello World',
|
||||
)
|
||||
@ -134,7 +134,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_delete_oembed_caches() {
|
||||
$post_id = $this->factory()->post->create();
|
||||
$post_id = self::factory()->post->create();
|
||||
|
||||
add_post_meta( $post_id, '_oembed_foo', 'bar' );
|
||||
add_post_meta( $post_id, '_oembed_foo', 'baz' );
|
||||
@ -147,14 +147,14 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_cache_oembed_invalid_post_type() {
|
||||
$post_id = $this->factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
|
||||
|
||||
$this->wp_embed->cache_oembed( $post_id );
|
||||
$this->assertNotSame( $post_id, $this->wp_embed->post_ID );
|
||||
}
|
||||
|
||||
public function test_cache_oembed_empty_content() {
|
||||
$post_id = $this->factory()->post->create( array( 'post_content' => '' ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => '' ) );
|
||||
|
||||
$this->wp_embed->cache_oembed( $post_id );
|
||||
$this->assertNotSame( $post_id, $this->wp_embed->post_ID );
|
||||
@ -167,7 +167,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
$cachekey = '_oembed_' . $key_suffix;
|
||||
$cachekey_time = '_oembed_time_' . $key_suffix;
|
||||
|
||||
$post_id = $this->factory()->post->create( array( 'post_content' => 'https://example.com/' ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => 'https://example.com/' ) );
|
||||
|
||||
add_filter( 'pre_oembed_result', array( $this, '_pre_oembed_result_callback' ) );
|
||||
$this->wp_embed->cache_oembed( $post_id );
|
||||
@ -181,7 +181,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
public function test_shortcode_should_get_cached_data_from_post_meta_for_known_post() {
|
||||
global $post;
|
||||
|
||||
$post = $this->factory()->post->create_and_get();
|
||||
$post = self::factory()->post->create_and_get();
|
||||
$url = 'https://example.com/';
|
||||
$expected = '<b>Embedded content</b>';
|
||||
$key_suffix = md5( $url . serialize( wp_embed_defaults( $url ) ) );
|
||||
@ -208,7 +208,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
public function test_shortcode_should_get_cached_failure_from_post_meta_for_known_post() {
|
||||
global $post;
|
||||
|
||||
$post = $this->factory()->post->create_and_get();
|
||||
$post = self::factory()->post->create_and_get();
|
||||
$url = 'https://example.com/';
|
||||
$expected = '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>';
|
||||
$key_suffix = md5( $url . serialize( wp_embed_defaults( $url ) ) );
|
||||
|
@ -290,7 +290,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_request_invalid_format() {
|
||||
$post_id = $this->factory()->post->create();
|
||||
$post_id = self::factory()->post->create();
|
||||
|
||||
$request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
|
||||
$request->set_param( 'url', get_permalink( $post_id ) );
|
||||
@ -461,12 +461,12 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_rest_pre_serve_request() {
|
||||
$user = $this->factory()->user->create_and_get(
|
||||
$user = self::factory()->user->create_and_get(
|
||||
array(
|
||||
'display_name' => 'John Doe',
|
||||
)
|
||||
);
|
||||
$post = $this->factory()->post->create_and_get(
|
||||
$post = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'post_author' => $user->ID,
|
||||
'post_title' => 'Hello World',
|
||||
@ -485,7 +485,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_rest_pre_serve_request_wrong_format() {
|
||||
$post = $this->factory()->post->create_and_get();
|
||||
$post = self::factory()->post->create_and_get();
|
||||
|
||||
$request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
|
||||
$request->set_param( 'url', get_permalink( $post->ID ) );
|
||||
@ -497,7 +497,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_rest_pre_serve_request_wrong_method() {
|
||||
$post = $this->factory()->post->create_and_get();
|
||||
$post = self::factory()->post->create_and_get();
|
||||
|
||||
$request = new WP_REST_Request( 'HEAD', '/oembed/1.0/embed' );
|
||||
$request->set_param( 'url', get_permalink( $post->ID ) );
|
||||
@ -513,7 +513,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
$this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'json' ) );
|
||||
$this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
|
||||
|
||||
$post_id = $this->factory()->post->create();
|
||||
$post_id = self::factory()->post->create();
|
||||
$url = get_permalink( $post_id );
|
||||
$url_encoded = urlencode( $url );
|
||||
|
||||
@ -527,7 +527,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
|
||||
$this->assertSame( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url() );
|
||||
$this->assertSame( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
|
||||
|
||||
$post_id = $this->factory()->post->create();
|
||||
$post_id = self::factory()->post->create();
|
||||
$url = get_permalink( $post_id );
|
||||
$url_encoded = urlencode( $url );
|
||||
|
||||
|
@ -13,7 +13,7 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
|
||||
* @requires function xdebug_get_headers
|
||||
*/
|
||||
public function test_rest_pre_serve_request_headers() {
|
||||
$post = $this->factory()->post->create_and_get(
|
||||
$post = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'post_title' => 'Hello World',
|
||||
)
|
||||
|
@ -726,7 +726,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_use_block_editor_for_post() {
|
||||
$this->assertFalse( use_block_editor_for_post( -1 ) );
|
||||
$bogus_post_id = $this->factory()->post->create(
|
||||
$bogus_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'bogus',
|
||||
)
|
||||
@ -739,14 +739,14 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
$restless_post_id = $this->factory()->post->create(
|
||||
$restless_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'restless',
|
||||
)
|
||||
);
|
||||
$this->assertFalse( use_block_editor_for_post( $restless_post_id ) );
|
||||
|
||||
$generic_post_id = $this->factory()->post->create();
|
||||
$generic_post_id = self::factory()->post->create();
|
||||
|
||||
add_filter( 'use_block_editor_for_post', '__return_false' );
|
||||
$this->assertFalse( use_block_editor_for_post( $generic_post_id ) );
|
||||
|
@ -54,7 +54,7 @@ class Tests_Post_IsPostPubliclyViewable extends WP_UnitTestCase {
|
||||
$date = date_format( date_create( '+1 year' ), 'Y-m-d H:i:s' );
|
||||
}
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => $post_type,
|
||||
'post_status' => $post_status,
|
||||
|
@ -745,17 +745,17 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
|
||||
* @covers ::_wp_delete_customize_changeset_dependent_auto_drafts
|
||||
*/
|
||||
public function test_wp_delete_customize_changeset_dependent_auto_drafts() {
|
||||
$auto_draft_post_id = $this->factory()->post->create(
|
||||
$auto_draft_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'auto-draft',
|
||||
)
|
||||
);
|
||||
$draft_post_id = $this->factory()->post->create(
|
||||
$draft_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'draft',
|
||||
)
|
||||
);
|
||||
$private_post_id = $this->factory()->post->create(
|
||||
$private_post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'private',
|
||||
)
|
||||
|
@ -1425,7 +1425,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
public function test_contributor_cannot_set_post_slug( $post_type ) {
|
||||
wp_set_current_user( self::$user_ids['contributor'] );
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'Jefferson claim: nice to have Washington on your side.',
|
||||
'post_content' => "I’m in the cabinet. I am complicit in watching him grabbin’ at power and kiss it.\n\nIf Washington isn’t gon’ listen to disciplined dissidents, this is the difference: this kid is out!",
|
||||
@ -1464,7 +1464,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
public function test_administrator_can_set_post_slug( $post_type ) {
|
||||
wp_set_current_user( self::$user_ids['administrator'] );
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'What is the Conner Project?',
|
||||
'post_content' => 'Evan Hansen’s last link to his friend Conner is a signature on his broken arm.',
|
||||
@ -1505,7 +1505,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
public function test_administrator_cannot_set_post_slug_on_post_type_they_cannot_publish() {
|
||||
wp_set_current_user( self::$user_ids['administrator'] );
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'Everything is legal in New Jersey',
|
||||
'post_content' => 'Shortly before his death, Philip Hamilton was heard to claim everything was legal in the garden state.',
|
||||
@ -1542,7 +1542,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
|
||||
$now = new DateTimeImmutable( 'now', new DateTimeZone( 'UTC' ) );
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_date_gmt' => $now->modify( '-1 year' )->format( 'Y-m-d H:i:s' ),
|
||||
'post_status' => 'future',
|
||||
@ -1551,7 +1551,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
|
||||
$this->assertSame( 'publish', get_post_status( $post_id ) );
|
||||
|
||||
$post_id = $this->factory()->post->create(
|
||||
$post_id = self::factory()->post->create(
|
||||
array(
|
||||
'post_date_gmt' => $now->modify( '+50 years' )->format( 'Y-m-d H:i:s' ),
|
||||
'post_status' => 'future',
|
||||
|
@ -5256,7 +5256,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
*/
|
||||
public function test_draft_post_does_not_have_the_same_slug_as_existing_post() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
$this->factory()->post->create( array( 'post_name' => 'sample-slug' ) );
|
||||
self::factory()->post->create( array( 'post_name' => 'sample-slug' ) );
|
||||
|
||||
$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
|
||||
$params = $this->set_post_data(
|
||||
|
@ -136,7 +136,7 @@ class Tests_REST_WpRestBlockPatternCategoriesController extends WP_Test_REST_Con
|
||||
*/
|
||||
public function test_get_items_forbidden() {
|
||||
// Set current user without `edit_posts` capability.
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
||||
|
||||
$request = new WP_REST_Request( 'GET', static::REQUEST_ROUTE );
|
||||
$response = rest_do_request( $request );
|
||||
|
@ -162,7 +162,7 @@ class Tests_REST_WpRestBlockPatternsController extends WP_Test_REST_Controller_T
|
||||
*/
|
||||
public function test_get_items_forbidden() {
|
||||
// Set current user without `edit_posts` capability.
|
||||
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
|
||||
|
||||
$request = new WP_REST_Request( 'GET', static::REQUEST_ROUTE );
|
||||
$response = rest_do_request( $request );
|
||||
|
@ -25,7 +25,7 @@ class Tests_Term_IsTermPubliclyViewable extends WP_UnitTestCase {
|
||||
* @param bool $expected The expected result of the function call.
|
||||
*/
|
||||
public function test_is_term_publicly_viewable( $taxonomy, $expected ) {
|
||||
$term_id = $this->factory()->term->create(
|
||||
$term_id = self::factory()->term->create(
|
||||
array(
|
||||
'taxonomy' => $taxonomy,
|
||||
)
|
||||
|
@ -90,7 +90,7 @@ class Tests_Term_termCount extends WP_UnitTestCase {
|
||||
public function test_term_count_changes_for_post_statuses( $post_status, $change ) {
|
||||
$term_count = get_term( get_option( 'default_category' ) )->count;
|
||||
// Do not use shared fixture for this test as it relies on a new post.
|
||||
$post_id = $this->factory()->post->create( array( 'post_status' => $post_status ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_status' => $post_status ) );
|
||||
|
||||
$expected = $term_count + $change;
|
||||
$this->assertSame( $expected, get_term( get_option( 'default_category' ) )->count );
|
||||
@ -244,7 +244,7 @@ class Tests_Term_termCount extends WP_UnitTestCase {
|
||||
|
||||
add_filter( 'update_post_term_count_statuses', array( $this, 'add_custom_status_to_counted_statuses' ) );
|
||||
|
||||
$post_id = $this->factory()->post->create( array( 'post_status' => $post_status ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_status' => $post_status ) );
|
||||
wp_add_object_terms( $post_id, self::$attachment_term, 'wp_test_tax_counts' );
|
||||
$attachment_id = self::factory()->attachment->create_object(
|
||||
array(
|
||||
@ -296,7 +296,7 @@ class Tests_Term_termCount extends WP_UnitTestCase {
|
||||
public function test_term_count_changes_for_post_statuses_with_attachments( $post_status, $change ) {
|
||||
$term_count = get_term( self::$attachment_term )->count;
|
||||
// Do not use shared fixture for this test as it relies on a new post.
|
||||
$post_id = $this->factory()->post->create( array( 'post_status' => $post_status ) );
|
||||
$post_id = self::factory()->post->create( array( 'post_status' => $post_status ) );
|
||||
wp_add_object_terms( $post_id, self::$attachment_term, 'wp_test_tax_counts' );
|
||||
$attachment_id = self::factory()->attachment->create_object(
|
||||
array(
|
||||
|
@ -366,7 +366,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
* @covers ::_wp_keep_alive_customize_changeset_dependent_auto_drafts
|
||||
*/
|
||||
public function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() {
|
||||
$nav_created_post_ids = $this->factory()->post->create_many(
|
||||
$nav_created_post_ids = self::factory()->post->create_many(
|
||||
2,
|
||||
array(
|
||||
'post_status' => 'auto-draft',
|
||||
|
@ -1696,7 +1696,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
reset_phpmailer_instance();
|
||||
$was_confirmation_email_sent = false;
|
||||
|
||||
$user = $this->factory()->user->create_and_get(
|
||||
$user = self::factory()->user->create_and_get(
|
||||
array(
|
||||
'user_email' => 'before@example.com',
|
||||
)
|
||||
@ -1733,7 +1733,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
reset_phpmailer_instance();
|
||||
$was_confirmation_email_sent = false;
|
||||
|
||||
$user = $this->factory()->user->create_and_get(
|
||||
$user = self::factory()->user->create_and_get(
|
||||
array(
|
||||
'user_email' => 'before@example.com',
|
||||
)
|
||||
|
@ -172,7 +172,7 @@ class Tests_Widgets_wpWidgetCustomHtml extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
wp_set_current_user(
|
||||
$this->factory()->user->create(
|
||||
self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
)
|
||||
@ -241,7 +241,7 @@ class Tests_Widgets_wpWidgetCustomHtml extends WP_UnitTestCase {
|
||||
* @covers WP_Widget_Custom_HTML::enqueue_admin_scripts
|
||||
*/
|
||||
public function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_on() {
|
||||
$user = $this->factory()->user->create();
|
||||
$user = self::factory()->user->create();
|
||||
wp_set_current_user( $user );
|
||||
wp_get_current_user()->syntax_highlighting = 'true';
|
||||
set_current_screen( 'widgets.php' );
|
||||
@ -262,7 +262,7 @@ class Tests_Widgets_wpWidgetCustomHtml extends WP_UnitTestCase {
|
||||
* @covers WP_Widget_Custom_HTML::enqueue_admin_scripts
|
||||
*/
|
||||
public function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_off() {
|
||||
$user = $this->factory()->user->create();
|
||||
$user = self::factory()->user->create();
|
||||
wp_set_current_user( $user );
|
||||
update_user_meta( $user, 'syntax_highlighting', 'false' );
|
||||
set_current_screen( 'widgets.php' );
|
||||
|
@ -116,7 +116,7 @@ class Tests_Widgets_wpWidgetMedia extends WP_UnitTestCase {
|
||||
public function test_constructor_in_customize_preview() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user(
|
||||
$this->factory()->user->create(
|
||||
self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
)
|
||||
@ -159,7 +159,7 @@ class Tests_Widgets_wpWidgetMedia extends WP_UnitTestCase {
|
||||
$this->assertFalse( $widget->is_attachment_with_mime_type( 0, 'image' ) );
|
||||
$this->assertFalse( $widget->is_attachment_with_mime_type( -123, 'image' ) );
|
||||
|
||||
$post_id = $this->factory()->post->create();
|
||||
$post_id = self::factory()->post->create();
|
||||
$this->assertFalse( $widget->is_attachment_with_mime_type( $post_id, 'image' ) );
|
||||
$this->assertFalse( $widget->is_attachment_with_mime_type( $attachment_id, 'video' ) );
|
||||
$this->assertTrue( $widget->is_attachment_with_mime_type( $attachment_id, 'image' ) );
|
||||
|
@ -81,7 +81,7 @@ class Tests_Widgets_wpWidgetText extends WP_UnitTestCase {
|
||||
public function test__register_in_customize_preview() {
|
||||
global $wp_customize;
|
||||
wp_set_current_user(
|
||||
$this->factory()->user->create(
|
||||
self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
)
|
||||
@ -315,7 +315,7 @@ class Tests_Widgets_wpWidgetText extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_widget_shortcodes() {
|
||||
global $post;
|
||||
$post_id = $this->factory()->post->create();
|
||||
$post_id = self::factory()->post->create();
|
||||
$post = get_post( $post_id );
|
||||
|
||||
$args = array(
|
||||
@ -716,7 +716,7 @@ class Tests_Widgets_wpWidgetText extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
wp_set_current_user(
|
||||
$this->factory()->user->create(
|
||||
self::factory()->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user