Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2018-08-17 01:50:26 +00:00
parent fed48ba3fe
commit a75d153eee
549 changed files with 9936 additions and 6721 deletions
@@ -27,7 +27,8 @@ class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post {
array(
'file' => '',
'post_parent' => 0,
), $args
),
$args
);
return wp_insert_attachment( $r, $r['file'], $r['post_parent'] );
@@ -217,7 +217,8 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
foreach ( $links as &$links_array ) {
foreach ( $links_array as &$link ) {
$attributes = array_diff_key(
$link, array(
$link,
array(
'href' => 1,
'name' => 1,
)
@@ -284,7 +285,8 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
protected function set_raw_post_data( $args = array() ) {
return wp_parse_args(
$args, $this->set_post_data(
$args,
$this->set_post_data(
array(
'title' => array(
'raw' => 'Post Title',
+2 -1
View File
@@ -206,7 +206,8 @@ class testXMLParser {
'XML error: %s at line %d',
xml_error_string( xml_get_error_code( $this->xml ) ),
xml_get_current_line_number( $this->xml )
), E_USER_ERROR
),
E_USER_ERROR
);
xml_parser_free( $this->xml );
}
+14 -8
View File
@@ -40,19 +40,25 @@ class Tests_Admin_includesFile extends WP_UnitTestCase {
$error = download_url( 'test_download_url_non_200' );
$this->assertWPError( $error );
$this->assertEquals( array(
'code' => 418,
'body' => 'This is an unexpected error message from your favorite server.',
), $error->get_error_data() );
$this->assertEquals(
array(
'code' => 418,
'body' => 'This is an unexpected error message from your favorite server.',
),
$error->get_error_data()
);
add_filter( 'download_url_error_max_body_size', array( $this, '__return_5' ) );
$error = download_url( 'test_download_url_non_200' );
$this->assertWPError( $error );
$this->assertEquals( array(
'code' => 418,
'body' => 'This ',
), $error->get_error_data() );
$this->assertEquals(
array(
'code' => 418,
'body' => 'This ',
),
$error->get_error_data()
);
remove_filter( 'download_url_error_max_body_size', array( $this, '__return_5' ) );
remove_filter( 'pre_http_request', array( $this, '_fake_download_url_non_200_response_code' ) );
@@ -81,7 +81,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 1,
'posts_per_page' => 2,
), array(
),
array(
self::$top[1]->ID,
self::$children[1][1]->ID,
)
@@ -96,7 +97,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 2,
'posts_per_page' => 2,
), array(
),
array(
self::$top[1]->ID,
self::$children[1][2]->ID,
self::$children[1][3]->ID,
@@ -113,7 +115,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
'paged' => 1,
'posts_per_page' => 2,
's' => 'Child',
), array(
),
array(
self::$children[1][1]->ID,
self::$children[1][2]->ID,
)
@@ -129,7 +132,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
'paged' => 2,
'posts_per_page' => 2,
's' => 'Top',
), array(
),
array(
self::$top[3]->ID,
self::$top[4]->ID,
)
@@ -145,7 +149,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 6,
'posts_per_page' => 2,
), array(
),
array(
self::$top[3]->ID,
self::$children[3][1]->ID,
self::$grandchildren[3][1][1]->ID,
@@ -163,7 +168,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 7,
'posts_per_page' => 2,
), array(
),
array(
self::$top[3]->ID,
self::$children[3][1]->ID,
self::$grandchildren[3][1][3]->ID,
@@ -187,7 +193,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
$args = array_merge(
array(
'post_type' => 'page',
), $args
),
$args
);
// Mimic the behaviour of `wp_edit_posts_query()`:
+3 -1
View File
@@ -389,7 +389,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
wp_set_current_user( self::$admin_id );
$p = self::factory()->attachment->create_object(
'صورة.jpg', 0, array(
'صورة.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'صورة',
+4 -2
View File
@@ -262,7 +262,8 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
$screen = get_current_screen();
$screen->add_help_tab( $tab_args );
$this->assertEquals(
$screen->get_help_tab( $tab ), array(
$screen->get_help_tab( $tab ),
array(
'id' => $tab,
'title' => 'Help!',
'content' => 'Some content',
@@ -352,7 +353,8 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
$tab_1 => $tab_1_args,
$tab_4 => $tab_4_args,
$tab_3 => $tab_3_args,
), $tabs
),
$tabs
);
$screen->remove_help_tab( $tab_1 );
+24 -12
View File
@@ -53,7 +53,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Top Level' => 'template-top-level.php',
'Sub Dir' => 'subdir/template-sub-dir.php',
'This Template Header Is On One Line' => 'template-header.php',
), get_page_templates()
),
get_page_templates()
);
$theme = wp_get_theme( 'page-templates' );
@@ -66,7 +67,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Top Level' => 'template-top-level.php',
'Sub Dir' => 'subdir/template-sub-dir.php',
'This Template Header Is On One Line' => 'template-header.php',
), get_page_templates()
),
get_page_templates()
);
}
@@ -83,13 +85,15 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
array(
'Top Level' => 'template-top-level-post-types.php',
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
), get_page_templates( null, 'foo' )
),
get_page_templates( null, 'foo' )
);
$this->assertEqualSetsWithIndex(
array(
'Top Level' => 'template-top-level-post-types.php',
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
), get_page_templates( null, 'post' )
),
get_page_templates( null, 'post' )
);
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
}
@@ -111,7 +115,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
'Tilde in Post Type.' => '38766/tilde-post-types.php',
), get_page_templates( null, 'period' )
),
get_page_templates( null, 'period' )
);
$this->assertEqualSetsWithIndex(
array(
@@ -120,7 +125,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Trailing Comma,' => '38766/trailing-comma-post-types.php',
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
), get_page_templates( null, 'full-stop' )
),
get_page_templates( null, 'full-stop' )
);
}
@@ -139,14 +145,16 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
'Top Level In A Child Theme' => 'template-top-level-post-types-child.php',
'Sub Dir In A Child Theme' => 'subdir/template-sub-dir-post-types-child.php',
), get_page_templates( null, 'foo' )
),
get_page_templates( null, 'foo' )
);
$this->assertEqualSetsWithIndex(
array(
'Top Level' => 'template-top-level-post-types.php',
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
), get_page_templates( null, 'post' )
),
get_page_templates( null, 'post' )
);
$this->assertEqualSetsWithIndex(
@@ -154,7 +162,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Top Level' => 'template-top-level.php',
'Sub Dir' => 'subdir/template-sub-dir.php',
'This Template Header Is On One Line' => 'template-header.php',
), get_page_templates()
),
get_page_templates()
);
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
@@ -177,14 +186,16 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
'template-top-level-post-types-child.php' => 'Top Level In A Child Theme',
'subdir/template-sub-dir-post-types-child.php' => 'Sub Dir In A Child Theme',
), $post_templates['foo']
),
$post_templates['foo']
);
$this->assertEqualSetsWithIndex(
array(
'template-top-level-post-types.php' => 'Top Level',
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
), $post_templates['post']
),
$post_templates['post']
);
$this->assertEqualSetsWithIndex(
@@ -192,7 +203,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'template-top-level.php' => 'Top Level',
'subdir/template-sub-dir.php' => 'Sub Dir',
'template-header.php' => 'This Template Header Is On One Line',
), $post_templates['page']
),
$post_templates['page']
);
}
+8 -4
View File
@@ -75,7 +75,8 @@ class Tests_AdminBar extends WP_UnitTestCase {
array(
'class' => 'test-class',
'some-meta' => 'value',
), $node2->meta
),
$node2->meta
);
}
@@ -491,7 +492,8 @@ class Tests_AdminBar extends WP_UnitTestCase {
*/
public function test_admin_bar_has_no_archives_link_for_non_public_cpt() {
register_post_type(
'foo-non-public', array(
'foo-non-public',
array(
'public' => false,
'has_archive' => true,
'show_in_admin_bar' => true,
@@ -514,7 +516,8 @@ class Tests_AdminBar extends WP_UnitTestCase {
*/
public function test_admin_bar_has_no_archives_link_for_cpt_without_archive() {
register_post_type(
'foo-non-public', array(
'foo-non-public',
array(
'public' => true,
'has_archive' => false,
'show_in_admin_bar' => true,
@@ -537,7 +540,8 @@ class Tests_AdminBar extends WP_UnitTestCase {
*/
public function test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar() {
register_post_type(
'foo-non-public', array(
'foo-non-public',
array(
'public' => true,
'has_archive' => true,
'show_in_admin_bar' => false,
+8 -4
View File
@@ -133,7 +133,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
array(
'action' => 'load-available-menu-items-customizer',
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
), $post_args
),
$post_args
);
// Make the request.
@@ -242,7 +243,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
array(
'action' => 'load-available-menu-items-customizer',
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
), $post_args
),
$post_args
);
// Make the request.
@@ -354,7 +356,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
array(
'action' => 'load-available-menu-items-customizer',
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
), $post_args
),
$post_args
);
// Make the request.
@@ -537,7 +540,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
array(
'action' => 'search-available-menu-items-customizer',
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
), $post_args
),
$post_args
);
$this->make_ajax_call( 'search-available-menu-items-customizer' );
+6 -2
View File
@@ -17,13 +17,17 @@ class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase {
*/
public function test_dont_process_terms_if_taxonomy_does_not_allow_show_on_quick_edit() {
register_taxonomy(
'wptests_tax_1', 'post', array(
'wptests_tax_1',
'post',
array(
'show_in_quick_edit' => false,
'hierarchical' => true,
)
);
register_taxonomy(
'wptests_tax_2', 'post', array(
'wptests_tax_2',
'post',
array(
'show_in_quick_edit' => true,
'hierarchical' => true,
)
+16 -8
View File
@@ -234,9 +234,11 @@ class Tests_Auth extends WP_UnitTestCase {
$key = wp_generate_password( 20, false );
$wpdb->update(
$wpdb->users, array(
$wpdb->users,
array(
'user_activation_key' => strtotime( '-1 hour' ) . ':' . self::$wp_hasher->HashPassword( $key ),
), array(
),
array(
'ID' => $this->user->ID,
)
);
@@ -269,9 +271,11 @@ class Tests_Auth extends WP_UnitTestCase {
$key = wp_generate_password( 20, false );
$wpdb->update(
$wpdb->users, array(
$wpdb->users,
array(
'user_activation_key' => strtotime( '-48 hours' ) . ':' . self::$wp_hasher->HashPassword( $key ),
), array(
),
array(
'ID' => $this->user->ID,
)
);
@@ -304,9 +308,11 @@ class Tests_Auth extends WP_UnitTestCase {
$key = wp_generate_password( 20, false );
$wpdb->update(
$wpdb->users, array(
$wpdb->users,
array(
'user_activation_key' => self::$wp_hasher->HashPassword( $key ),
), array(
),
array(
'ID' => $this->user->ID,
)
);
@@ -331,9 +337,11 @@ class Tests_Auth extends WP_UnitTestCase {
$key = wp_generate_password( 20, false );
$wpdb->update(
$wpdb->users, array(
$wpdb->users,
array(
'user_activation_key' => $key,
), array(
),
array(
'ID' => $this->user->ID,
)
);
@@ -12,7 +12,8 @@ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
update_option( 'show_on_front', 'page' );
update_option(
'page_for_posts', self::factory()->post->create(
'page_for_posts',
self::factory()->post->create(
array(
'post_title' => 'blog-page',
'post_type' => 'page',
@@ -20,7 +21,8 @@ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
)
);
update_option(
'page_on_front', self::factory()->post->create(
'page_on_front',
self::factory()->post->create(
array(
'post_title' => 'front-page',
'post_type' => 'page',
@@ -7,11 +7,13 @@
class Tests_Category_CategoryDescription extends WP_UnitTestCase {
public function test_success_query_by_id() {
$description = 'Foo';
$c = self::factory()->category->create( array(
'description' => $description,
) );
$c = self::factory()->category->create(
array(
'description' => $description,
)
);
$found = category_description( $c );
$found = category_description( $c );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
@@ -19,14 +21,16 @@ class Tests_Category_CategoryDescription extends WP_UnitTestCase {
public function test_success_query_by_object() {
$description = 'Foo';
$c = self::factory()->category->create( array(
'description' => $description,
'slug' => 'bar',
) );
$c = self::factory()->category->create(
array(
'description' => $description,
'slug' => 'bar',
)
);
$category = get_term( $c );
$found = category_description( $c );
$found = category_description( $c );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
@@ -41,14 +45,16 @@ class Tests_Category_CategoryDescription extends WP_UnitTestCase {
$description = 'Foo';
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'description' => $description,
) );
$t = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax',
'description' => $description,
)
);
$term = get_term( $t );
$found = category_description( $t );
$found = category_description( $t );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
@@ -63,14 +69,16 @@ class Tests_Category_CategoryDescription extends WP_UnitTestCase {
$description = 'Foo';
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'description' => $description,
) );
$t = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax',
'description' => $description,
)
);
clean_term_cache( $t );
$found = category_description( $t );
$found = category_description( $t );
$expected = apply_filters( 'term_description', $description );
$this->assertSame( $expected, $found );
@@ -8,7 +8,7 @@ class Tests_Category_GetCategoryLink extends WP_UnitTestCase {
public function test_success() {
$c = self::factory()->category->create();
$found = get_category_link( $c );
$found = get_category_link( $c );
$expected = home_url( '?cat=' . $c );
$this->assertSame( $expected, $found );
@@ -20,14 +20,16 @@ class Tests_Category_GetCategoryLink extends WP_UnitTestCase {
public function test_should_return_link_for_term_from_another_taxonomy_on_primed_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'slug' => 'test-term',
) );
$t = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax',
'slug' => 'test-term',
)
);
$term = get_term( $t );
$found = get_category_link( $t );
$found = get_category_link( $t );
$expected = home_url( '?wptests_tax=test-term' );
$this->assertSame( $expected, $found );
@@ -39,14 +41,16 @@ class Tests_Category_GetCategoryLink extends WP_UnitTestCase {
public function test_should_return_link_for_term_from_another_taxonomy_on_empty_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'slug' => 'test-term',
) );
$t = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax',
'slug' => 'test-term',
)
);
clean_term_cache( $t );
$found = get_category_link( $t );
$found = get_category_link( $t );
$expected = home_url( '?wptests_tax=test-term' );
$this->assertSame( $expected, $found );
@@ -6,9 +6,11 @@
*/
class Tests_Category_GetTheCategoryById extends WP_UnitTestCase {
public function test_success() {
$c = self::factory()->category->create( array(
'name' => 'Foo',
) );
$c = self::factory()->category->create(
array(
'name' => 'Foo',
)
);
$found = get_the_category_by_ID( $c );
@@ -21,10 +23,12 @@ class Tests_Category_GetTheCategoryById extends WP_UnitTestCase {
public function test_should_return_link_for_term_from_another_taxonomy_on_primed_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'Foo',
) );
$t = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax',
'name' => 'Foo',
)
);
$term = get_term( $t );
@@ -39,10 +43,12 @@ class Tests_Category_GetTheCategoryById extends WP_UnitTestCase {
public function test_should_return_link_for_term_from_another_taxonomy_on_empty_cache() {
register_taxonomy( 'wptests_tax', 'post' );
$t = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
'name' => 'Foo',
) );
$t = self::factory()->term->create(
array(
'taxonomy' => 'wptests_tax',
'name' => 'Foo',
)
);
clean_term_cache( $t );
@@ -146,7 +146,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
$terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
)
);
@@ -174,7 +175,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
$terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
)
);
@@ -199,7 +201,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) );
$terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
)
);
@@ -224,7 +227,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
$terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
)
);
+2 -1
View File
@@ -783,7 +783,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
'comment_parent' => '0',
'user_ID' => $user->ID,
'user_id' => $user->ID,
), $this->preprocess_comment_data
),
$this->preprocess_comment_data
);
}
@@ -200,7 +200,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link );
@@ -270,7 +271,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link );
@@ -326,7 +328,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link );
@@ -382,7 +385,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link );
@@ -433,7 +437,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 1,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link );
@@ -484,7 +489,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link );
@@ -539,7 +545,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
$link_p1 = add_query_arg(
array(
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link_p1 );
@@ -558,7 +565,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link_p2 );
@@ -630,7 +638,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
$link_p0 = add_query_arg(
array(
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link_p0 );
@@ -648,7 +657,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 2,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link_p2 );
@@ -668,7 +678,8 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'cpage' => 1,
'comments_per_page' => 2,
), get_permalink( $p )
),
get_permalink( $p )
);
$this->go_to( $link_p1 );
+2 -1
View File
@@ -50,7 +50,8 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase {
public function _get_query_result( $args = array() ) {
$args = wp_parse_args(
$args, array(
$args,
array(
'post_id' => $this->posts[1],
'orderby' => 'comment_ID', // Same order they were created
'order' => 'ASC',
@@ -64,24 +64,30 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
}
$this->assertEquals(
2, get_page_of_comment(
$trackbacks[0], array(
2,
get_page_of_comment(
$trackbacks[0],
array(
'per_page' => 2,
'type' => 'trackback',
)
)
);
$this->assertEquals(
3, get_page_of_comment(
$pingbacks[0], array(
3,
get_page_of_comment(
$pingbacks[0],
array(
'per_page' => 2,
'type' => 'pingback',
)
)
);
$this->assertEquals(
5, get_page_of_comment(
$trackbacks[0], array(
5,
get_page_of_comment(
$trackbacks[0],
array(
'per_page' => 2,
'type' => 'pings',
)
@@ -136,7 +142,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
// Prime cache for trackbacks.
$page_trackbacks = get_page_of_comment(
$trackbacks[1], array(
$trackbacks[1],
array(
'per_page' => 3,
'type' => 'trackback',
)
@@ -145,7 +152,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$num_queries = $wpdb->num_queries;
$page_comments = get_page_of_comment(
$comment, array(
$comment,
array(
'per_page' => 3,
'type' => 'comment',
)
+20 -10
View File
@@ -2812,7 +2812,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() {
$now = current_time( 'mysql', 1 );
$comments = self::factory()->comment->create_many(
5, array(
5,
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => $now,
)
@@ -2836,7 +2837,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() {
$now = current_time( 'mysql', 1 );
$comments = self::factory()->comment->create_many(
5, array(
5,
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => $now,
)
@@ -3422,7 +3424,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
*/
public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() {
$comments = self::factory()->comment->create_many(
2, array(
2,
array(
'comment_post_ID' => self::$post_id,
)
);
@@ -3459,7 +3462,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
*/
public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() {
$comments = self::factory()->comment->create_many(
2, array(
2,
array(
'comment_post_ID' => self::$post_id,
)
);
@@ -3772,7 +3776,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$top_level_comments = self::factory()->comment->create_many(
3, array(
3,
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
)
@@ -3813,7 +3818,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$top_level_comments = self::factory()->comment->create_many(
3, array(
3,
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
)
@@ -3889,7 +3895,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$query_args = array_merge(
$args, array(
$args,
array(
'post_id' => self::$post_id,
)
);
@@ -3967,7 +3974,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$query_args = array_merge(
$args, array(
$args,
array(
'post_id' => self::$post_id,
)
);
@@ -4012,7 +4020,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$top_level_comments = self::factory()->comment->create_many(
3, array(
3,
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
)
@@ -4068,7 +4077,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
);
$top_level_comments = self::factory()->comment->create_many(
3, array(
3,
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
)
+4 -2
View File
@@ -33,14 +33,16 @@ class Tests_Comment_Walker extends WP_UnitTestCase {
'callback' => array( $comment_callback, 'comment' ),
'walker' => $comment_walker,
'echo' => false,
), array( $comment_parent, $comment_child )
),
array( $comment_parent, $comment_child )
);
wp_list_comments(
array(
'callback' => array( $comment_callback, 'comment' ),
'walker' => $comment_walker,
'echo' => false,
), array( $comment_child, $comment_parent )
),
array( $comment_child, $comment_parent )
);
}
}
+2 -1
View File
@@ -13,7 +13,8 @@ class Tests_Term_WpComment extends WP_UnitTestCase {
$comment_1 = WP_Comment::get_instance( 1 );
if ( ! $comment_1 ) {
$wpdb->insert(
$wpdb->comments, array(
$wpdb->comments,
array(
'comment_ID' => 1,
)
);
@@ -158,7 +158,8 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
'echo' => false,
'per_page' => 1,
'page' => 2,
), $_comments
),
$_comments
);
preg_match_all( '|id="comment\-([0-9]+)"|', $found, $matches );
+2 -2
View File
@@ -95,10 +95,10 @@ class Tests_Compat extends WP_UnitTestCase {
$length = 5;
$unset_var = 10;
unset( $unset_var );
$heredoc = <<<EOT
$heredoc = <<<EOT
hello world
EOT;
$inputs = array(
$inputs = array(
0,
1,
12345,
+2 -2
View File
@@ -21,7 +21,7 @@ class Tests_Cron extends WP_UnitTestCase {
// make sure the schedule is clear
_set_cron_array( array() );
$this->preflight_cron_array = array();
$this->plus_thirty_minutes = strtotime( '+30 minutes' );
$this->plus_thirty_minutes = strtotime( '+30 minutes' );
}
function tearDown() {
@@ -460,7 +460,7 @@ class Tests_Cron extends WP_UnitTestCase {
add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) );
add_filter( 'pre_next_scheduled', array( $this, 'filter_pre_scheduled_event_hooks' ) );
$actual = wp_get_scheduled_event( 'preflight_event', array(), $this->plus_thirty_minutes );
$actual = wp_get_scheduled_event( 'preflight_event', array(), $this->plus_thirty_minutes );
$actual2 = wp_next_scheduled( 'preflight_event', array() );
$expected = (object) array(
+20 -7
View File
@@ -42,40 +42,51 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
function test_check_capabilities() {
do_action( 'customize_register', $this->wp_customize );
$control = new WP_Customize_Control(
$this->wp_customize, 'blogname', array(
$this->wp_customize,
'blogname',
array(
'settings' => array( 'blogname' ),
)
);
$this->assertTrue( $control->check_capabilities() );
$control = new WP_Customize_Control(
$this->wp_customize, 'blogname', array(
$this->wp_customize,
'blogname',
array(
'settings' => array( 'blogname', 'non_existing' ),
)
);
$this->assertFalse( $control->check_capabilities() );
$this->wp_customize->add_setting(
'top_secret_message', array(
'top_secret_message',
array(
'capability' => 'top_secret_clearance',
)
);
$control = new WP_Customize_Control(
$this->wp_customize, 'blogname', array(
$this->wp_customize,
'blogname',
array(
'settings' => array( 'blogname', 'top_secret_clearance' ),
)
);
$this->assertFalse( $control->check_capabilities() );
$control = new WP_Customize_Control(
$this->wp_customize, 'no_setting', array(
$this->wp_customize,
'no_setting',
array(
'settings' => array(),
)
);
$this->assertTrue( $control->check_capabilities() );
$control = new WP_Customize_Control(
$this->wp_customize, 'no_setting', array(
$this->wp_customize,
'no_setting',
array(
'settings' => array(),
'capability' => 'top_secret_clearance',
)
@@ -83,7 +94,9 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
$this->assertFalse( $control->check_capabilities() );
$control = new WP_Customize_Control(
$this->wp_customize, 'no_setting', array(
$this->wp_customize,
'no_setting',
array(
'settings' => array(),
'capability' => 'edit_theme_options',
)
@@ -169,7 +169,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
// Make sure that wp_update_custom_css_post() works as expected for updates.
$r = wp_update_custom_css_post(
'body { color:red; }', array(
'body { color:red; }',
array(
'stylesheet' => $this->setting->stylesheet,
'preprocessed' => "body\n\tcolor:red;",
)
@@ -185,7 +186,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
// Make sure that wp_update_custom_css_post() works as expected for insertion.
$r = wp_update_custom_css_post(
'body { background:black; }', array(
'body { background:black; }',
array(
'stylesheet' => 'other',
)
);
@@ -214,7 +216,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
$updated_css = 'body { background: red; }';
$post = wp_update_custom_css_post(
$inserted_css, array(
$inserted_css,
array(
'stylesheet' => 'testtheme',
)
);
@@ -225,7 +228,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
$this->assertSame( $inserted_css, $revisions[0]->post_content );
wp_update_custom_css_post(
$updated_css, array(
$updated_css,
array(
'stylesheet' => 'testtheme',
)
);
+55 -25
View File
@@ -550,7 +550,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
add_theme_support( 'custom-background' );
$existing_canola_attachment_id = self::factory()->attachment->create_object(
$this->test_file, 0, array(
$this->test_file,
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_name' => 'canola',
@@ -985,12 +987,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
// Test saving with invalid settings, ensuring transaction blocked.
$previous_saved_data = $saved_data;
$manager->add_setting(
'foo_unauthorized', array(
'foo_unauthorized',
array(
'capability' => 'do_not_allow',
)
);
$manager->add_setting(
'baz_illegal', array(
'baz_illegal',
array(
'validate_callback' => array( $this, 'return_illegal_error' ),
)
);
@@ -1098,7 +1102,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
do_action( 'customize_register', $wp_customize );
$manager->add_setting(
'scratchpad', array(
'scratchpad',
array(
'type' => 'option',
'capability' => 'exist',
)
@@ -1382,18 +1387,21 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
);
do_action( 'customize_register', $manager );
$manager->add_setting(
'blogfounded', array(
'blogfounded',
array(
'type' => 'option',
)
);
$manager->add_setting(
'blogterminated', array(
'blogterminated',
array(
'type' => 'option',
'capability' => 'do_not_allow',
)
);
$manager->add_setting(
'scratchpad', array(
'scratchpad',
array(
'type' => 'option',
'capability' => 'exist',
)
@@ -1898,7 +1906,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
*/
function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting(
'scratchpad', array(
'scratchpad',
array(
'type' => 'option',
'capability' => 'exist',
'sanitize_callback' => array( $this, 'filter_sanitize_scratchpad' ),
@@ -2194,7 +2203,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
wp_set_current_user( self::$admin_user_id );
$default_value = 'foo_default';
$setting = $this->manager->add_setting(
'foo', array(
'foo',
array(
'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
)
@@ -2262,7 +2272,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
wp_set_current_user( self::$admin_user_id );
$default_value = '0';
$setting = $this->manager->add_setting(
'numeric', array(
'numeric',
array(
'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
)
@@ -2308,7 +2319,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
function test_validate_setting_values() {
wp_set_current_user( self::$admin_user_id );
$setting = $this->manager->add_setting(
'foo', array(
'foo',
array(
'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
)
@@ -2433,7 +2445,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
function test_validate_setting_values_validation_sanitization_order() {
wp_set_current_user( self::$admin_user_id );
$setting = $this->manager->add_setting(
'numeric', array(
'numeric',
array(
'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
)
@@ -2477,7 +2490,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
function test_set_post_value() {
wp_set_current_user( self::$admin_user_id );
$this->manager->add_setting(
'foo', array(
'foo',
array(
'sanitize_callback' => array( $this, 'sanitize_foo_for_test_set_post_value' ),
)
);
@@ -2970,7 +2984,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$section_id = 'foo-section';
wp_set_current_user( self::$admin_user_id );
$manager->add_section(
$section_id, array(
$section_id,
array(
'title' => 'Section',
'priority' => 1,
)
@@ -2983,7 +2998,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$added_control_ids[] = $id;
$manager->add_setting( $id );
$control = new WP_Customize_Control(
$manager, $id, array(
$manager,
$id,
array(
'section' => $section_id,
'priority' => 1,
'setting' => $id,
@@ -3007,7 +3024,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$section_id = 'foo-section';
$result_section = $manager->add_section(
$section_id, array(
$section_id,
array(
'title' => 'Section',
'priority' => 1,
)
@@ -3017,7 +3035,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$this->assertEquals( $section_id, $result_section->id );
$section = new WP_Customize_Section(
$manager, $section_id, array(
$manager,
$section_id,
array(
'title' => 'Section 2',
'priority' => 2,
)
@@ -3109,7 +3129,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$panel_id = 'foo-panel';
$result_panel = $manager->add_panel(
$panel_id, array(
$panel_id,
array(
'title' => 'Test Panel',
'priority' => 2,
)
@@ -3119,7 +3140,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$this->assertEquals( $panel_id, $result_panel->id );
$panel = new WP_Customize_Panel(
$manager, $panel_id, array(
$manager,
$panel_id,
array(
'title' => 'Test Panel 2',
)
);
@@ -3138,7 +3161,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$section_id = 'foo-section';
wp_set_current_user( self::$admin_user_id );
$manager->add_section(
$section_id, array(
$section_id,
array(
'title' => 'Section',
'priority' => 1,
)
@@ -3148,7 +3172,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$manager->add_setting( $control_id );
$result_control = $manager->add_control(
$control_id, array(
$control_id,
array(
'section' => $section_id,
'priority' => 1,
'setting' => $control_id,
@@ -3158,7 +3183,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$this->assertEquals( $control_id, $result_control->id );
$control = new WP_Customize_Control(
$manager, $control_id, array(
$manager,
$control_id,
array(
'section' => $section_id,
'priority' => 1,
'setting' => $control_id,
@@ -3253,7 +3280,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
foreach ( $controls as $control_id => $priority ) {
$this->manager->add_setting( $control_id );
$this->manager->add_control(
$control_id, array(
$control_id,
array(
'priority' => $priority,
'section' => 'foosection',
)
@@ -3282,7 +3310,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
foreach ( $sections as $section_id => $priority ) {
$this->manager->add_section(
$section_id, array(
$section_id,
array(
'priority' => $priority,
)
);
@@ -3310,7 +3339,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
foreach ( $panels as $panel_id => $priority ) {
$this->manager->add_panel(
$panel_id, array(
$panel_id,
array(
'priority' => $priority,
)
);
@@ -154,7 +154,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$menu_id = wp_create_nav_menu( 'Menu' );
$item_title = 'Greetings';
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -179,7 +181,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$other_menu_id = wp_create_nav_menu( 'Menu2' );
wp_update_nav_menu_item(
$other_menu_id, $item_id, array(
$other_menu_id,
$item_id,
array(
'menu-item-title' => 'Hola',
)
);
@@ -201,7 +205,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$menu_id = wp_create_nav_menu( 'Menu' );
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -231,7 +237,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$menu_id = wp_create_nav_menu( 'Menu' );
$item_title = 'Greetings';
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'category',
'menu-item-object-id' => $tax_id,
@@ -266,7 +274,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$menu_id = wp_create_nav_menu( 'Menu' );
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'custom_type',
'menu-item-object' => 'custom_object',
'menu-item-title' => 'Cool beans',
@@ -310,7 +320,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -343,7 +355,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
$item_title = 'Greetings';
$item_id = wp_update_nav_menu_item(
$primary_menu_id, 0, array(
$primary_menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $first_post_id,
@@ -394,7 +408,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -451,7 +467,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -573,7 +591,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
}
$nav_menu_item_id = wp_update_nav_menu_item(
$menu_id, 0, wp_slash(
$menu_id,
0,
wp_slash(
array(
'menu-item-object-id' => $unsanitized['object_id'],
'menu-item-object' => $unsanitized['object'],
@@ -625,7 +645,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
$item_title = 'Greetings';
$item_id = wp_update_nav_menu_item(
$primary_menu_id, 0, array(
$primary_menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $first_post_id,
@@ -690,7 +712,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -761,7 +785,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$item_ids = array();
for ( $i = 0; $i < 5; $i += 1 ) {
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -806,7 +832,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_invalid_nav_menu_item() {
$menu_id = wp_create_nav_menu( 'Primary' );
register_post_type(
'poem', array(
'poem',
array(
'public' => true,
)
);
@@ -819,7 +846,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$post = get_post( $post_id );
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'poem',
'menu-item-object-id' => $post_id,
@@ -920,7 +949,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_value_as_wp_post_nav_menu_item_term_urls() {
$term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
register_post_type(
'press_release', array(
'press_release',
array(
'has_archive' => true,
)
);
@@ -932,7 +962,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[-1]'
);
$this->wp_customize->set_post_value(
$setting->id, array(
$setting->id,
array(
'type' => 'taxonomy',
'object' => 'category',
'object_id' => $term_id,
@@ -950,7 +981,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[-2]'
);
$this->wp_customize->set_post_value(
$setting->id, array(
$setting->id,
array(
'type' => 'post_type',
'object' => 'press_release',
'object_id' => $post_id,
@@ -968,7 +1000,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[-3]'
);
$this->wp_customize->set_post_value(
$setting->id, array(
$setting->id,
array(
'type' => 'post_type_archive',
'object' => 'press_release',
'title' => 'PR',
@@ -989,7 +1022,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
function test_get_original_title() {
$menu_id = wp_create_nav_menu( 'Menu' );
register_post_type(
'press_release', array(
'press_release',
array(
'has_archive' => true,
'labels' => array(
'name' => 'PRs',
@@ -1015,7 +1049,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
// Post: existing nav menu item.
$nav_menu_item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-object-id' => $post_id,
'menu-item-type' => 'post_type',
'menu-item-object' => 'press_release',
@@ -1044,7 +1080,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[-1]'
);
$this->wp_customize->set_post_value(
$setting->id, array(
$setting->id,
array(
'object_id' => $post_id,
'type' => 'post_type',
'object' => 'press_release',
@@ -1066,7 +1103,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
// Term: existing nav menu item.
$nav_menu_item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-object-id' => $term_id,
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'category',
@@ -1095,7 +1134,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[-2]'
);
$this->wp_customize->set_post_value(
$setting->id, array(
$setting->id,
array(
'object_id' => $term_id,
'type' => 'taxonomy',
'object' => 'category',
@@ -1117,7 +1157,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
// Post Type Archive: existing nav menu item.
$nav_menu_item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type_archive',
'menu-item-object' => 'press_release',
'menu-item-title' => '',
@@ -1145,7 +1187,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[-3]'
);
$this->wp_customize->set_post_value(
$setting->id, array(
$setting->id,
array(
'type' => 'post_type_archive',
'object' => 'press_release',
'title' => '',
@@ -135,7 +135,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$parent_menu_id = wp_create_nav_menu( wp_slash( "Parent $menu_name" ) );
$description = 'Hello my world \\o/.';
$menu_id = wp_update_nav_menu_object(
0, wp_slash(
0,
wp_slash(
array(
'menu-name' => $menu_name,
'parent' => $parent_menu_id,
@@ -171,7 +172,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_update_nav_menu_object(
0, wp_slash(
0,
wp_slash(
array(
'menu-name' => 'Name 1 \\o/',
'description' => 'Description 1 \\o/',
@@ -282,7 +284,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_update_nav_menu_object(
0, wp_slash(
0,
wp_slash(
array(
'menu-name' => 'Name 1 \\o/',
'description' => 'Description 1 \\o/',
@@ -351,7 +354,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$menu_id = wp_update_nav_menu_object(
0, wp_slash(
0,
wp_slash(
array(
'menu-name' => 'Name 1 \\o/',
'description' => 'Description 1 \\o/',
+8 -3
View File
@@ -426,7 +426,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
if ( 'cat' === $args['s'] ) {
array_unshift(
$items, array(
$items,
array(
'id' => 'home',
'title' => 'COOL CAT!',
'type' => 'custom',
@@ -499,7 +500,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menu_id = wp_create_nav_menu( 'Primary' );
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
$item_id = wp_update_nav_menu_item(
$menu_id, 0, array(
$menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -1138,7 +1141,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menu = wp_create_nav_menu( 'Foo' );
wp_update_nav_menu_item(
$menu, 0, array(
$menu,
0,
array(
'menu-item-type' => 'custom',
'menu-item-title' => 'WordPress.org',
'menu-item-url' => 'https://wordpress.org',
+3 -1
View File
@@ -81,7 +81,9 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
$this->assertTrue( $panel->active() );
$panel = new WP_Customize_Panel(
$this->manager, 'foo', array(
$this->manager,
'foo',
array(
'active_callback' => '__return_false',
)
);
+32 -11
View File
@@ -116,7 +116,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
$this->assertContains( 'Lorem Ipsum', $partial->render() );
$partial = new WP_Customize_Partial(
$this->selective_refresh, $partial_id, array(
$this->selective_refresh,
$partial_id,
array(
'settings' => 'blogdescription',
)
);
@@ -221,7 +223,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
*/
function test_render_with_bad_callback_should_give_preference_to_return_value() {
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'foo', array(
$this->selective_refresh,
'foo',
array(
'render_callback' => array( $this, 'render_echo_and_return' ),
)
);
@@ -236,7 +240,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
*/
function test_render_echo_callback() {
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'foo', array(
$this->selective_refresh,
'foo',
array(
'render_callback' => array( $this, 'render_echo' ),
)
);
@@ -257,7 +263,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
*/
function test_render_return_callback() {
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'foo', array(
$this->selective_refresh,
'foo',
array(
'render_callback' => array( $this, 'render_return' ),
)
);
@@ -319,40 +327,51 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
do_action( 'customize_register', $this->wp_customize );
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'blogname', array(
$this->selective_refresh,
'blogname',
array(
'settings' => array( 'blogname' ),
)
);
$this->assertTrue( $partial->check_capabilities() );
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'blogname', array(
$this->selective_refresh,
'blogname',
array(
'settings' => array( 'blogname', 'non_existing' ),
)
);
$this->assertFalse( $partial->check_capabilities() );
$this->wp_customize->add_setting(
'top_secret_message', array(
'top_secret_message',
array(
'capability' => 'top_secret_clearance',
)
);
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'blogname', array(
$this->selective_refresh,
'blogname',
array(
'settings' => array( 'blogname', 'top_secret_clearance' ),
)
);
$this->assertFalse( $partial->check_capabilities() );
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'no_setting', array(
$this->selective_refresh,
'no_setting',
array(
'settings' => array(),
)
);
$this->assertTrue( $partial->check_capabilities() );
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'no_setting', array(
$this->selective_refresh,
'no_setting',
array(
'settings' => array(),
'capability' => 'top_secret_clearance',
)
@@ -360,7 +379,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
$this->assertFalse( $partial->check_capabilities() );
$partial = new WP_Customize_Partial(
$this->selective_refresh, 'no_setting', array(
$this->selective_refresh,
'no_setting',
array(
'settings' => array(),
'capability' => 'edit_theme_options',
)
+3 -1
View File
@@ -90,7 +90,9 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
$this->assertTrue( $section->active() );
$section = new WP_Customize_Section(
$this->manager, 'foo', array(
$this->manager,
'foo',
array(
'active_callback' => '__return_false',
)
);
@@ -217,7 +217,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
$this->setup_valid_render_partials_request_environment();
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
$this->wp_customize->add_setting(
'secret_message', array(
'secret_message',
array(
'capability' => 'top_secret_clearance',
)
);
@@ -309,7 +310,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
$this->setup_valid_render_partials_request_environment();
$this->wp_customize->selective_refresh->add_partial(
'test_blogname', array(
'test_blogname',
array(
'settings' => array( 'blogname' ),
'render_callback' => array( $this, 'render_callback_blogname' ),
)
@@ -462,13 +464,15 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
$this->setup_valid_render_partials_request_environment();
$this->wp_customize->selective_refresh->add_partial(
'test_blogname', array(
'test_blogname',
array(
'settings' => array( 'blogname' ),
'render_callback' => array( $this, 'render_callback_blogname' ),
)
);
$this->wp_customize->selective_refresh->add_partial(
'test_blogdescription', array(
'test_blogdescription',
array(
'settings' => array( 'blogdescription' ),
'render_callback' => array( $this, 'render_callback_blogdescription' ),
)
@@ -143,17 +143,20 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$user->remove_cap( 'top_secret_clearance' );
$this->wp_customize->add_setting(
'top_secret_message', array(
'top_secret_message',
array(
'capability' => 'top_secret_clearance', // The administrator role lacks this.
)
);
$this->selective_refresh->add_partial(
'blogname', array(
'blogname',
array(
'selector' => '#site-title',
)
);
$this->selective_refresh->add_partial(
'top_secret_message', array(
'top_secret_message',
array(
'settings' => array( 'top_secret_message' ),
)
);
+22 -8
View File
@@ -444,7 +444,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
// Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter.
$setting_id = 'custom_without_previewing_value_filter';
$setting = $this->manager->add_setting(
$setting_id, array(
$setting_id,
array(
'type' => 'custom_preview_test',
'default' => 123,
'sanitize_callback' => array( $this->manager->nav_menus, 'intval_base10' ),
@@ -599,7 +600,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = 'autoloaded1';
$setting = new WP_Customize_Setting(
$this->manager, $name, array(
$this->manager,
$name,
array(
'type' => 'option',
)
);
@@ -612,7 +615,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = 'autoloaded2';
$setting = new WP_Customize_Setting(
$this->manager, $name, array(
$this->manager,
$name,
array(
'type' => 'option',
'autoload' => true,
)
@@ -626,7 +631,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = 'not-autoloaded1';
$setting = new WP_Customize_Setting(
$this->manager, $name, array(
$this->manager,
$name,
array(
'type' => 'option',
'autoload' => false,
)
@@ -640,12 +647,16 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$id_base = 'multi-not-autoloaded';
$setting1 = new WP_Customize_Setting(
$this->manager, $id_base . '[foo]', array(
$this->manager,
$id_base . '[foo]',
array(
'type' => 'option',
)
);
$setting2 = new WP_Customize_Setting(
$this->manager, $id_base . '[bar]', array(
$this->manager,
$id_base . '[bar]',
array(
'type' => 'option',
'autoload' => false,
)
@@ -695,7 +706,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
*/
public function test_validate() {
$setting = new WP_Customize_Setting(
$this->manager, 'name', array(
$this->manager,
'name',
array(
'type' => 'key',
'validate_callback' => array( $this, 'filter_validate_for_test_validate' ),
)
@@ -735,7 +748,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$initial_value = 456;
set_theme_mod(
'nav_menu_locations', array(
'nav_menu_locations',
array(
'primary' => $initial_value,
)
);
+10 -5
View File
@@ -395,7 +395,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
$q = new WP_Date_Query( array() );
$found = $q->build_value(
'BETWEEN', array(
'BETWEEN',
array(
2 => 4,
3 => 5,
)
@@ -455,7 +456,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
$q = new WP_Date_Query( array() );
$found = $q->build_value(
'NOT BETWEEN', array(
'NOT BETWEEN',
array(
2 => 4,
3 => 5,
)
@@ -513,7 +515,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
$found = $q->build_mysql_datetime(
array(
'year' => 2011,
), true
),
true
);
$this->assertSame( '2011-12-31 23:59:59', $found );
}
@@ -524,7 +527,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
$found = $q->build_mysql_datetime(
array(
'year' => 2011,
), false
),
false
);
$this->assertSame( '2011-01-01 00:00:00', $found );
}
@@ -535,7 +539,8 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
$found = $q->build_mysql_datetime(
array(
'year' => 2011,
), false
),
false
);
$this->assertSame( '2011-01-01 00:00:00', $found );
}
+2 -1
View File
@@ -578,7 +578,8 @@ class Tests_DB extends WP_UnitTestCase {
$last = $wpdb->insert_id;
$rows2 = $wpdb->replace(
$wpdb->users, array(
$wpdb->users,
array(
'ID' => $last,
'display_name' => 'Walter Replace Sobchak',
)
+42 -21
View File
@@ -87,9 +87,11 @@ class Tests_dbDelta extends WP_UnitTestCase {
$this->assertEquals( $expected, $updates );
$this->assertEquals(
"{$wpdb->prefix}dbdelta_create_test", $wpdb->get_var(
"{$wpdb->prefix}dbdelta_create_test",
$wpdb->get_var(
$wpdb->prepare(
'SHOW TABLES LIKE %s', $wpdb->esc_like( "{$wpdb->prefix}dbdelta_create_test" )
'SHOW TABLES LIKE %s',
$wpdb->esc_like( "{$wpdb->prefix}dbdelta_create_test" )
)
)
);
@@ -143,7 +145,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
array(
"{$wpdb->prefix}dbdelta_test.id"
=> "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint(20) to int(11)",
), $updates
),
$updates
);
}
@@ -171,7 +174,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
array(
"{$wpdb->prefix}dbdelta_test.extra_col"
=> "Added column {$wpdb->prefix}dbdelta_test.extra_col",
), $updates
),
$updates
);
$this->assertTableHasColumn( 'column_1', $wpdb->prefix . 'dbdelta_test' );
@@ -222,14 +226,16 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY key_1 (column_1({$this->max_index_length})),
KEY compound_key (id,column_1($this->max_index_length))
)
", false // Don't execute.
",
false // Don't execute.
);
$this->assertEquals(
array(
"{$wpdb->prefix}dbdelta_test.extra_col"
=> "Added column {$wpdb->prefix}dbdelta_test.extra_col",
), $updates
),
$updates
);
$this->assertTableHasNotColumn( 'extra_col', $wpdb->prefix . 'dbdelta_test' );
@@ -246,7 +252,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
);
$this->assertEquals(
array(), $insert
array(),
$insert
);
$this->assertTableRowHasValue( 'column_1', 'wcphilly2015', $wpdb->prefix . 'dbdelta_test' );
@@ -271,7 +278,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
)
", false
",
false
);
$this->assertEmpty( $updates );
@@ -328,11 +336,14 @@ class Tests_dbDelta extends WP_UnitTestCase {
$table_indices = $wpdb->get_results( "SHOW INDEX FROM {$table}" );
$this->assertCount(
1, wp_list_filter(
$table_indices, array(
1,
wp_list_filter(
$table_indices,
array(
'Key_name' => 'PRIMARY',
'Column_name' => $column,
), 'AND'
),
'AND'
)
);
}
@@ -407,7 +418,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM
", false
",
false
);
$this->assertSame( array(), $result );
@@ -431,7 +443,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM
", false
",
false
);
$this->assertSame( array(), $result );
@@ -455,14 +468,16 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM
", false
",
false
);
$this->assertSame(
array(
"{$wpdb->prefix}dbdelta_test.column_2"
=> "Changed type of {$wpdb->prefix}dbdelta_test.column_2 from text to bigtext",
), $result
),
$result
);
}
@@ -484,14 +499,16 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM
", false
",
false
);
$this->assertSame(
array(
"{$wpdb->prefix}dbdelta_test.column_3"
=> "Changed type of {$wpdb->prefix}dbdelta_test.column_3 from blob to mediumblob",
), $result
),
$result
);
}
@@ -563,7 +580,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
array(
"{$wpdb->prefix}spatial_index_test.spatial_value2" => "Added column {$wpdb->prefix}spatial_index_test.spatial_value2",
"Added index {$wpdb->prefix}spatial_index_test SPATIAL KEY `spatial_key2` (`spatial_value2`)",
), $updates
),
$updates
);
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}spatial_index_test" );
@@ -852,7 +870,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compOUND_key (id,column_1($this->max_index_length)),
FULLTEXT KEY FULLtext_kEY (column_1)
) ENGINE=MyISAM
", false
",
false
);
$this->assertEmpty( $updates );
@@ -876,7 +895,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
) ENGINE=MyISAM
", false
",
false
);
$this->assertEmpty( $updates );
@@ -907,7 +927,8 @@ class Tests_dbDelta extends WP_UnitTestCase {
$this->assertSame(
array(
"Added index {$wpdb->prefix}dbdelta_test KEY `changing_key_length` (`column_1`(20))",
), $updates
),
$updates
);
$updates = dbDelta(
+8 -4
View File
@@ -10,7 +10,8 @@ if ( ! class_exists( '_WP_Editors', false ) ) {
class Tests_WP_Editors extends WP_UnitTestCase {
public function wp_link_query_callback( $results ) {
return array_merge(
$results, array(
$results,
array(
array(
'ID' => 123,
'title' => 'foo',
@@ -39,7 +40,8 @@ class Tests_WP_Editors extends WP_UnitTestCase {
'permalink' => get_permalink( $post->ID ),
'info' => mysql2date( __( 'Y/m/d' ), $post->post_date ),
),
), $actual
),
$actual
);
}
@@ -59,7 +61,8 @@ class Tests_WP_Editors extends WP_UnitTestCase {
'permalink' => 'bar',
'info' => 'baz',
),
), $actual
),
$actual
);
}
@@ -84,7 +87,8 @@ class Tests_WP_Editors extends WP_UnitTestCase {
'permalink' => 'bar',
'info' => 'baz',
),
), $actual
),
$actual
);
}
}
+2 -1
View File
@@ -38,7 +38,8 @@ class Tests_Feeds_Atom extends WP_UnitTestCase {
// Create a few posts
self::$posts = $factory->post->create_many(
$count, array(
$count,
array(
'post_author' => self::$user_id,
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec velit massa, ultrices eu est suscipit, mattis posuere est. Donec vitae purus lacus. Cras vitae odio odio.',
'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
+2 -1
View File
@@ -42,7 +42,8 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase {
// Create a few posts
self::$posts = $factory->post->create_many(
$count, array(
$count,
array(
'post_author' => self::$user_id,
'post_date' => self::$post_date,
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec velit massa, ultrices eu est suscipit, mattis posuere est. Donec vitae purus lacus. Cras vitae odio odio.',
+24 -12
View File
@@ -52,7 +52,8 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
'path' => '/path;p=1',
'query' => 'query=2&r[]=3',
'fragment' => 'fragment',
), parse_url( $url )
),
parse_url( $url )
);
$this->assertEquals( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url_raw( $url ) );
$this->assertEquals( 'https://user:pass@host.example.com:1234/path;p=1?query=2&#038;r%5B%5D=3#fragment', esc_url( $url ) );
@@ -83,22 +84,28 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
$this->assertEquals( 'http://example.com', esc_url( 'http://example.com' ) );
$this->assertEquals( '', esc_url( 'nasty://example.com/' ) );
$this->assertEquals(
'', esc_url(
'example.com', array(
'',
esc_url(
'example.com',
array(
'https',
)
)
);
$this->assertEquals(
'', esc_url(
'http://example.com', array(
'',
esc_url(
'http://example.com',
array(
'https',
)
)
);
$this->assertEquals(
'https://example.com', esc_url(
'https://example.com', array(
'https://example.com',
esc_url(
'https://example.com',
array(
'http',
'https',
)
@@ -108,11 +115,14 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
foreach ( wp_allowed_protocols() as $scheme ) {
$this->assertEquals( "{$scheme}://example.com", esc_url( "{$scheme}://example.com" ), $scheme );
$this->assertEquals(
"{$scheme}://example.com", esc_url(
"{$scheme}://example.com", array(
"{$scheme}://example.com",
esc_url(
"{$scheme}://example.com",
array(
$scheme,
)
), $scheme
),
$scheme
);
}
@@ -121,8 +131,10 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
$this->assertTrue( ! in_array( 'foo', wp_allowed_protocols(), true ) );
$this->assertEquals(
'foo://example.com', esc_url(
'foo://example.com', array(
'foo://example.com',
esc_url(
'foo://example.com',
array(
'foo',
)
)
+28 -14
View File
@@ -15,11 +15,13 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
array(
'ababa',
'xbaba',
), map_deep(
),
map_deep(
array(
'a',
'x',
), array( $this, 'append_baba' )
),
array( $this, 'append_baba' )
)
);
}
@@ -31,13 +33,15 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
array(
'xbaba',
),
), map_deep(
),
map_deep(
array(
'a',
array(
'x',
),
), array( $this, 'append_baba' )
),
array( $this, 'append_baba' )
)
);
}
@@ -49,13 +53,15 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
'var1' => (object) array(
'var0' => 'xbaba',
),
), map_deep(
),
map_deep(
array(
'var0' => 'a',
'var1' => (object) array(
'var0' => 'x',
),
), array( $this, 'append_baba' )
),
array( $this, 'append_baba' )
)
);
}
@@ -73,11 +79,13 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
(object) array(
'var0' => 'ababa',
'var1' => 'xbaba',
), map_deep(
),
map_deep(
(object) array(
'var0' => 'a',
'var1' => 'x',
), array( $this, 'append_baba' )
),
array( $this, 'append_baba' )
)
);
}
@@ -89,13 +97,15 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
'var1' => array(
'xbaba',
),
), map_deep(
),
map_deep(
(object) array(
'var0' => 'a',
'var1' => array(
'x',
),
), array( $this, 'append_baba' )
),
array( $this, 'append_baba' )
)
);
}
@@ -107,13 +117,15 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
'var1' => (object) array(
'var0' => 'xbaba',
),
), map_deep(
),
map_deep(
(object) array(
'var0' => 'a',
'var1' => (object) array(
'var0' => 'x',
),
), array( $this, 'append_baba' )
),
array( $this, 'append_baba' )
)
);
}
@@ -131,7 +143,8 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
(object) array(
'var0' => 'ababa',
'var1' => 'xbaba',
), map_deep( $object_b, array( $this, 'append_baba' ) )
),
map_deep( $object_b, array( $this, 'append_baba' ) )
);
}
@@ -148,7 +161,8 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase {
array(
'var0' => 'ababa',
'var1' => 'xbaba',
), map_deep( $array_b, array( $this, 'append_baba' ) )
),
map_deep( $array_b, array( $this, 'append_baba' ) )
);
}
+48 -24
View File
@@ -14,7 +14,8 @@ class Tests_Functions extends WP_UnitTestCase {
'_baba' => 5,
'yZ' => 'baba',
'a' => array( 5, 111, 'x' ),
), wp_parse_args( $x )
),
wp_parse_args( $x )
);
$y = new MockClass;
$this->assertEquals( array(), wp_parse_args( $y ) );
@@ -34,7 +35,8 @@ class Tests_Functions extends WP_UnitTestCase {
'_baba' => 5,
'yZ' => 'baba',
'a' => array( 5, 111, 'x' ),
), wp_parse_args( $b )
),
wp_parse_args( $b )
);
}
@@ -50,7 +52,8 @@ class Tests_Functions extends WP_UnitTestCase {
'_baba' => 5,
'yZ' => 'baba',
'a' => array( 5, 111, 'x' ),
), wp_parse_args( $x, $d )
),
wp_parse_args( $x, $d )
);
$e = array( '_baba' => 6 );
$this->assertEquals(
@@ -58,7 +61,8 @@ class Tests_Functions extends WP_UnitTestCase {
'_baba' => 5,
'yZ' => 'baba',
'a' => array( 5, 111, 'x' ),
), wp_parse_args( $x, $e )
),
wp_parse_args( $x, $e )
);
}
@@ -299,19 +303,23 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1', $url ) );
$this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ), $url ) );
$this->assertEquals(
"$url?foo=2", add_query_arg(
"$url?foo=2",
add_query_arg(
array(
'foo' => '1',
'foo' => '2',
), $url
),
$url
)
);
$this->assertEquals(
"$url?foo=1&bar=2", add_query_arg(
"$url?foo=1&bar=2",
add_query_arg(
array(
'foo' => '1',
'bar' => '2',
), $url
),
$url
)
);
@@ -320,7 +328,8 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1' ) );
$this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ) ) );
$this->assertEquals(
"$url?foo=2", add_query_arg(
"$url?foo=2",
add_query_arg(
array(
'foo' => '1',
'foo' => '2',
@@ -328,7 +337,8 @@ class Tests_Functions extends WP_UnitTestCase {
)
);
$this->assertEquals(
"$url?foo=1&bar=2", add_query_arg(
"$url?foo=1&bar=2",
add_query_arg(
array(
'foo' => '1',
'bar' => '2',
@@ -344,19 +354,23 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1', $frag_url ) );
$this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ), $frag_url ) );
$this->assertEquals(
"$url?foo=2#frag", add_query_arg(
"$url?foo=2#frag",
add_query_arg(
array(
'foo' => '1',
'foo' => '2',
), $frag_url
),
$frag_url
)
);
$this->assertEquals(
"$url?foo=1&bar=2#frag", add_query_arg(
"$url?foo=1&bar=2#frag",
add_query_arg(
array(
'foo' => '1',
'bar' => '2',
), $frag_url
),
$frag_url
)
);
@@ -365,7 +379,8 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1' ) );
$this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ) ) );
$this->assertEquals(
"$url?foo=2#frag", add_query_arg(
"$url?foo=2#frag",
add_query_arg(
array(
'foo' => '1',
'foo' => '2',
@@ -373,7 +388,8 @@ class Tests_Functions extends WP_UnitTestCase {
)
);
$this->assertEquals(
"$url?foo=1&bar=2#frag", add_query_arg(
"$url?foo=1&bar=2#frag",
add_query_arg(
array(
'foo' => '1',
'bar' => '2',
@@ -400,19 +416,23 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1', $url ) );
$this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ), $url ) );
$this->assertEquals(
"$url&foo=2", add_query_arg(
"$url&foo=2",
add_query_arg(
array(
'foo' => '1',
'foo' => '2',
), $url
),
$url
)
);
$this->assertEquals(
"$url&foo=1&bar=2", add_query_arg(
"$url&foo=1&bar=2",
add_query_arg(
array(
'foo' => '1',
'bar' => '2',
), $url
),
$url
)
);
@@ -421,7 +441,8 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1' ) );
$this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ) ) );
$this->assertEquals(
"$url&foo=2", add_query_arg(
"$url&foo=2",
add_query_arg(
array(
'foo' => '1',
'foo' => '2',
@@ -429,7 +450,8 @@ class Tests_Functions extends WP_UnitTestCase {
)
);
$this->assertEquals(
"$url&foo=1&bar=2", add_query_arg(
"$url&foo=1&bar=2",
add_query_arg(
array(
'foo' => '1',
'bar' => '2',
@@ -452,7 +474,8 @@ class Tests_Functions extends WP_UnitTestCase {
array(
'foo' => 'bar',
'1' => '2',
), '1=1'
),
'1=1'
);
$this->assertEquals( '1=2&foo=bar', $url );
@@ -1270,7 +1293,8 @@ class Tests_Functions extends WP_UnitTestCase {
// Test a few additional file types on single sites.
if ( ! is_multisite() ) {
$data = array_merge(
$data, array(
$data,
array(
// Standard non-image file.
array(
DIR_TESTDATA . '/formatting/big5.txt',
@@ -252,7 +252,7 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase {
*/
public function test_anonymize_with_filter() {
add_filter( 'wp_privacy_anonymize_data', array( $this, 'filter_wp_privacy_anonymize_data' ), 10, 3 );
$actual_url = wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' );
$actual_url = wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' );
remove_filter( 'wp_privacy_anonymize_data', array( $this, 'filter_wp_privacy_anonymize_data' ), 10 );
$this->assertSame( 'http://local.host/why-this-was-removed', $actual_url );
+16 -8
View File
@@ -21,7 +21,8 @@ class Tests_Get_Archives extends WP_UnitTestCase {
public static function wpSetUpBeforeClass( $factory ) {
self::$post_ids = $factory->post->create_many(
8, array(
8,
array(
'post_type' => 'post',
'post_author' => '1',
)
@@ -36,7 +37,8 @@ class Tests_Get_Archives extends WP_UnitTestCase {
function test_wp_get_archives_type() {
$expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . '</a></li>';
$this->assertEquals(
$expected['type'], trim(
$expected['type'],
trim(
wp_get_archives(
array(
'echo' => false,
@@ -70,7 +72,8 @@ class Tests_Get_Archives extends WP_UnitTestCase {
<li><a href='$link5'>$title5</a></li>
EOF;
$this->assertEquals(
$expected['limit'], trim(
$expected['limit'],
trim(
wp_get_archives(
array(
'echo' => false,
@@ -85,7 +88,8 @@ EOF;
function test_wp_get_archives_format() {
$expected['format'] = "<option value='" . $this->month_url . "'> " . date( 'F Y' ) . ' </option>';
$this->assertEquals(
$expected['format'], trim(
$expected['format'],
trim(
wp_get_archives(
array(
'echo' => false,
@@ -99,7 +103,8 @@ EOF;
function test_wp_get_archives_before_and_after() {
$expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></div>';
$this->assertEquals(
$expected['before_and_after'], trim(
$expected['before_and_after'],
trim(
wp_get_archives(
array(
'echo' => false,
@@ -115,7 +120,8 @@ EOF;
function test_wp_get_archives_show_post_count() {
$expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a>&nbsp;(8)</li>';
$this->assertEquals(
$expected['show_post_count'], trim(
$expected['show_post_count'],
trim(
wp_get_archives(
array(
'echo' => false,
@@ -148,7 +154,8 @@ EOF;
<li><a href='{$this->month_url}'>$date_full</a></li>
EOF;
$this->assertEquals(
$expected['order_asc'], trim(
$expected['order_asc'],
trim(
wp_get_archives(
array(
'echo' => false,
@@ -163,7 +170,8 @@ EOF;
<li><a href='{$oct_url}'>October 2012</a></li>
EOF;
$this->assertEquals(
$expected['order_desc'], trim(
$expected['order_desc'],
trim(
wp_get_archives(
array(
'echo' => false,
+58 -27
View File
@@ -42,10 +42,12 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
function test_filter_object_list_and() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field1' => true,
'field2' => true,
), 'AND'
),
'AND'
);
$this->assertEquals( 2, count( $list ) );
$this->assertArrayHasKey( 'foo', $list );
@@ -54,10 +56,12 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
function test_filter_object_list_or() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field1' => true,
'field2' => true,
), 'OR'
),
'OR'
);
$this->assertEquals( 3, count( $list ) );
$this->assertArrayHasKey( 'foo', $list );
@@ -67,10 +71,12 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
function test_filter_object_list_not() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field2' => true,
'field3' => true,
), 'NOT'
),
'NOT'
);
$this->assertEquals( 1, count( $list ) );
$this->assertArrayHasKey( 'baz', $list );
@@ -78,40 +84,51 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
function test_filter_object_list_and_field() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field1' => true,
'field2' => true,
), 'AND', 'name'
),
'AND',
'name'
);
$this->assertEquals(
array(
'foo' => 'foo',
'bar' => 'bar',
), $list
),
$list
);
}
function test_filter_object_list_or_field() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field2' => true,
'field3' => true,
), 'OR', 'name'
),
'OR',
'name'
);
$this->assertEquals(
array(
'foo' => 'foo',
'bar' => 'bar',
), $list
),
$list
);
}
function test_filter_object_list_not_field() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field2' => true,
'field3' => true,
), 'NOT', 'name'
),
'NOT',
'name'
);
$this->assertEquals( array( 'baz' => 'baz' ), $list );
}
@@ -123,7 +140,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
'foo' => 'foo',
'bar' => 'bar',
'baz' => 'baz',
), $list
),
$list
);
$list = wp_list_pluck( $this->array_list, 'name' );
@@ -132,7 +150,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
'foo' => 'foo',
'bar' => 'bar',
'baz' => 'baz',
), $list
),
$list
);
}
@@ -146,7 +165,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
'f' => 'foo',
'b' => 'bar',
'z' => 'baz',
), $list
),
$list
);
}
@@ -160,7 +180,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
'f' => 'foo',
'b' => 'bar',
'z' => 'baz',
), $list
),
$list
);
}
@@ -174,7 +195,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
0 => 'foo',
1 => 'bar',
2 => 'baz',
), $list
),
$list
);
}
@@ -190,7 +212,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
'f' => 'foo',
0 => 'bar',
'z' => 'baz',
), $list
),
$list
);
}
@@ -206,7 +229,8 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
'f' => 'foo',
'b' => 'bar',
'z' => 'baz',
), $list
),
$list
);
}
@@ -275,10 +299,12 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
function test_filter_object_list_nested_array_or() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field3' => true,
'field4' => array( 'blue' ),
), 'OR'
),
'OR'
);
$this->assertEquals( 2, count( $list ) );
$this->assertArrayHasKey( 'foo', $list );
@@ -303,22 +329,27 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
array(
'foo' => 'foo',
'baz' => 'baz',
), $list
),
$list
);
}
function test_filter_object_list_nested_array_or_field() {
$list = wp_filter_object_list(
$this->object_list, array(
$this->object_list,
array(
'field3' => true,
'field4' => array( 'blue' ),
), 'OR', 'name'
),
'OR',
'name'
);
$this->assertEquals(
array(
'foo' => 'foo',
'baz' => 'baz',
), $list
),
$list
);
}
}
@@ -90,7 +90,8 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
function test_front_page_title() {
update_option( 'show_on_front', 'page' );
update_option(
'page_on_front', $this->factory->post->create(
'page_on_front',
$this->factory->post->create(
array(
'post_title' => 'front-page',
'post_type' => 'page',
@@ -184,7 +185,8 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
function test_post_type_archive_title() {
register_post_type(
'cpt', array(
'cpt',
array(
'public' => true,
'has_archive' => true,
'labels' => array(
@@ -205,7 +205,8 @@ EXPECTED;
array(
'foo' => 'bar',
's' => 'search+term',
), $url
),
$url
);
}
+4 -1
View File
@@ -366,7 +366,10 @@ class Tests_General_Template extends WP_UnitTestCase {
update_post_meta( $this->custom_logo_id, '_wp_attachment_image_alt', $image_alt );
$image = wp_get_attachment_image(
$this->custom_logo_id, 'full', false, array(
$this->custom_logo_id,
'full',
false,
array(
'class' => 'custom-logo',
'itemprop' => 'logo',
)
+10 -5
View File
@@ -137,7 +137,8 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
function test_redirect_on_head() {
// Redirections on HEAD request when Requested
$res = wp_remote_request(
$this->redirection_script . '?rt=' . 5, array(
$this->redirection_script . '?rt=' . 5,
array(
'redirection' => 5,
'method' => 'HEAD',
)
@@ -208,7 +209,8 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
// Test 301 - POST to POST
$res = wp_remote_request(
$url, array(
$url,
array(
'method' => 'PUT',
'timeout' => 30,
)
@@ -255,7 +257,8 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
$url = $this->fileStreamUrl;
$size = 153204;
$res = wp_remote_request(
$url, array(
$url,
array(
'stream' => true,
'timeout' => 30,
)
@@ -282,7 +285,8 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
$url = $this->fileStreamUrl;
$size = 10000;
$res = wp_remote_request(
$url, array(
$url,
array(
'stream' => true,
'timeout' => 30,
'limit_response_size' => $size,
@@ -311,7 +315,8 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
$size = 10000;
$res = wp_remote_request(
$url, array(
$url,
array(
'timeout' => 30,
'limit_response_size' => $size,
)
+2 -1
View File
@@ -15,7 +15,8 @@ class Tests_HTTP_curl extends WP_HTTP_UnitTestCase {
public function test_http_api_curl_stream_parameter_is_a_reference() {
add_action( 'http_api_curl', array( $this, '_action_test_http_api_curl_stream_parameter_is_a_reference' ), 10, 3 );
wp_remote_request(
$this->fileStreamUrl, array(
$this->fileStreamUrl,
array(
'stream' => true,
'timeout' => 30,
)
+4 -2
View File
@@ -148,7 +148,8 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
$url = 'http://example.org';
$response = wp_remote_get(
$url, array(
$url,
array(
'cookies' => array(
new WP_Http_Cookie(
array(
@@ -179,7 +180,8 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
$url = 'http://example.org';
$response = wp_remote_get(
$url, array(
$url,
array(
'cookies' => array(
'test' => 'foo',
),
+2 -1
View File
@@ -190,7 +190,8 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
'path' => '/path',
'query' => 'arg1=value1&arg2=value2',
'fragment' => 'anchor',
), $actual
),
$actual
);
}
+2 -1
View File
@@ -122,7 +122,8 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase {
$property = new ReflectionProperty( $editor, 'size' );
$property->setAccessible( true );
$property->setValue(
$editor, array(
$editor,
array(
'height' => 50,
'width' => 100,
)
+43 -9
View File
@@ -308,7 +308,12 @@ class Tests_Image_Functions extends WP_UnitTestCase {
$file = wp_crop_image(
DIR_TESTDATA . '/images/canola.jpg',
0, 0, 100, 100, 100, 100
0,
0,
100,
100,
100,
100
);
$this->assertNotWPError( $file );
$this->assertFileExists( $file );
@@ -331,7 +336,13 @@ class Tests_Image_Functions extends WP_UnitTestCase {
$file = wp_crop_image(
'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
0, 0, 100, 100, 100, 100, false,
0,
0,
100,
100,
100,
100,
false,
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg'
);
$this->assertNotWPError( $file );
@@ -347,7 +358,12 @@ class Tests_Image_Functions extends WP_UnitTestCase {
public function test_wp_crop_image_file_not_exist() {
$file = wp_crop_image(
DIR_TESTDATA . '/images/canoladoesnotexist.jpg',
0, 0, 100, 100, 100, 100
0,
0,
100,
100,
100,
100
);
$this->assertInstanceOf( 'WP_Error', $file );
}
@@ -359,7 +375,12 @@ class Tests_Image_Functions extends WP_UnitTestCase {
$file = wp_crop_image(
'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
0, 0, 100, 100, 100, 100
0,
0,
100,
100,
100,
100
);
$this->assertInstanceOf( 'WP_Error', $file );
}
@@ -377,7 +398,12 @@ class Tests_Image_Functions extends WP_UnitTestCase {
$file = wp_crop_image(
DIR_TESTDATA . '/images/canola.jpg',
0, 0, 100, 100, 100, 100
0,
0,
100,
100,
100,
100
);
$this->assertInstanceOf( 'WP_Error', $file );
@@ -398,7 +424,9 @@ class Tests_Image_Functions extends WP_UnitTestCase {
copy( $orig_file, $test_file );
$attachment_id = $this->factory->attachment->create_object(
$test_file, 0, array(
$test_file,
0,
array(
'post_mime_type' => 'application/pdf',
)
);
@@ -461,7 +489,9 @@ class Tests_Image_Functions extends WP_UnitTestCase {
copy( $orig_file, $test_file );
$attachment_id = $this->factory->attachment->create_object(
$test_file, 0, array(
$test_file,
0,
array(
'post_mime_type' => 'application/pdf',
)
);
@@ -519,7 +549,9 @@ class Tests_Image_Functions extends WP_UnitTestCase {
copy( $orig_file, $test_file );
$attachment_id = $this->factory->attachment->create_object(
$test_file, 0, array(
$test_file,
0,
array(
'post_mime_type' => 'application/pdf',
)
);
@@ -577,7 +609,9 @@ class Tests_Image_Functions extends WP_UnitTestCase {
copy( DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf', $pdf_path );
$attachment_id = $this->factory->attachment->create_object(
$pdf_path, 0, array(
$pdf_path,
0,
array(
'post_mime_type' => 'application/pdf',
)
);
+2 -1
View File
@@ -264,7 +264,8 @@ class Tests_Import_Import extends WP_Import_UnitTestCase {
'def1' => array( 'def1' ),
'xyz1' => array( 'xyz1' ),
'XYZ2' => array( 'XYZ2' ),
), get_importers()
),
get_importers()
);
$wp_importers = $_wp_importers; // Restore global state
}
+30 -10
View File
@@ -68,7 +68,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'author_display_name' => 'John Doe',
'author_first_name' => 'John',
'author_last_name' => 'Doe',
), $result['authors']['john'], $message
),
$result['authors']['john'],
$message
);
$this->assertEquals(
array(
@@ -77,7 +79,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'category_parent' => '',
'cat_name' => 'alpha',
'category_description' => 'The alpha category',
), $result['categories'][0], $message
),
$result['categories'][0],
$message
);
$this->assertEquals(
array(
@@ -85,7 +89,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'tag_slug' => 'clippable',
'tag_name' => 'Clippable',
'tag_description' => 'The Clippable post_tag',
), $result['tags'][0], $message
),
$result['tags'][0],
$message
);
$this->assertEquals(
array(
@@ -95,7 +101,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'term_parent' => '',
'term_name' => 'bieup',
'term_description' => 'The bieup post_tax',
), $result['terms'][0], $message
),
$result['terms'][0],
$message
);
$this->assertEquals( 2, count( $result['posts'] ), $message );
@@ -118,7 +126,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'slug' => 'bieup',
'domain' => 'post_tax',
),
), $result['posts'][0]['terms'], $message
),
$result['posts'][0]['terms'],
$message
);
$this->assertEquals(
array(
@@ -126,7 +136,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'key' => '_wp_page_template',
'value' => 'default',
),
), $result['posts'][1]['postmeta'], $message
),
$result['posts'][1]['postmeta'],
$message
);
}
}
@@ -159,7 +171,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'slug' => 'uncategorized',
'domain' => 'category',
),
), $result['posts'][0]['terms'], $message
),
$result['posts'][0]['terms'],
$message
);
$this->assertEquals(
array(
@@ -178,7 +192,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'slug' => 'roar',
'domain' => 'tag',
),
), $result['posts'][2]['terms'], $message
),
$result['posts'][2]['terms'],
$message
);
$this->assertEquals(
array(
@@ -197,7 +213,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'slug' => 'face',
'domain' => 'tag',
),
), $result['posts'][3]['terms'], $message
),
$result['posts'][3]['terms'],
$message
);
$this->assertEquals(
@@ -206,7 +224,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
'key' => '_wp_page_template',
'value' => 'default',
),
), $result['posts'][1]['postmeta'], $message
),
$result['posts'][1]['postmeta'],
$message
);
}
}
+8 -3
View File
@@ -139,7 +139,8 @@ class Tests_Link extends WP_UnitTestCase {
array(
'post_type' => 'wptests_pt',
'p' => $p,
), trailingslashit( home_url() )
),
trailingslashit( home_url() )
);
$this->assertEquals( $non_pretty_permalink, get_permalink( $p ) );
@@ -152,7 +153,9 @@ class Tests_Link extends WP_UnitTestCase {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'An Attachment!',
@@ -180,7 +183,9 @@ class Tests_Link extends WP_UnitTestCase {
$post_id = self::factory()->post->create( array( 'post_type' => 'not_a_post_type' ) );
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'An Attachment!',
+6 -3
View File
@@ -93,7 +93,8 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase {
// Bump term_taxonomy to mimic shared term offsets.
global $wpdb;
$wpdb->insert(
$wpdb->term_taxonomy, array(
$wpdb->term_taxonomy,
array(
'taxonomy' => 'foo',
'term_id' => 12345,
'description' => '',
@@ -250,7 +251,8 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'post' );
$terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
)
);
@@ -283,7 +285,8 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'post' );
$terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
)
);
@@ -12,7 +12,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
array(
'feed' => get_default_feed(),
'p' => $post_id,
), home_url( '/' )
),
home_url( '/' )
);
$this->assertEquals( $expected, $link );
@@ -32,7 +33,9 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_attachment_link() {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -43,7 +46,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
array(
'feed' => get_default_feed(),
'p' => $attachment_id,
), home_url( '/' )
),
home_url( '/' )
);
$this->assertEquals( $expected, $link );
@@ -58,7 +62,9 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
)
);
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'Burrito',
@@ -78,7 +84,9 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -92,7 +100,9 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
public function test_unattached_link() {
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -103,7 +113,8 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
array(
'feed' => get_default_feed(),
'attachment_id' => $attachment_id,
), home_url( '/' )
),
home_url( '/' )
);
$this->assertEquals( $expected, $link );
@@ -113,7 +124,9 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -19,12 +19,15 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase {
'foo' => 'bar',
'bar' => 'baz',
'preview' => 'true',
), get_permalink( $post )
),
get_permalink( $post )
);
$this->assertEquals(
$expected, get_preview_post_link(
$post, array(
$expected,
get_preview_post_link(
$post,
array(
'foo' => 'bar',
'bar' => 'baz',
)
@@ -38,11 +41,14 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase {
$expected = 'https://google.com/?foo=bar&bar=baz&preview=true';
$this->assertEquals(
$expected, get_preview_post_link(
$post, array(
$expected,
get_preview_post_link(
$post,
array(
'foo' => 'bar',
'bar' => 'baz',
), 'https://google.com/'
),
'https://google.com/'
)
);
}
@@ -63,7 +69,8 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase {
public function test_get_preview_post_link_should_return_empty_string_for_non_viewable_post_type() {
$post_type = register_post_type(
'non_viewable_cpt', array(
'non_viewable_cpt',
array(
'public' => false,
)
);
+12 -6
View File
@@ -51,7 +51,8 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
array(
'page' => 2,
'foo' => 'bar',
), get_permalink( self::$post_id )
),
get_permalink( self::$post_id )
);
$this->go_to( $link );
@@ -59,7 +60,8 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
$expected = add_query_arg(
array(
'page' => 2,
), get_permalink( self::$post_id )
),
get_permalink( self::$post_id )
);
$this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) );
@@ -76,7 +78,8 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
array(
'page' => $page,
'foo' => 'bar',
), get_permalink( self::$post_id )
),
get_permalink( self::$post_id )
);
$this->go_to( $link );
@@ -96,7 +99,8 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
array(
'cpage' => $cpage,
'foo' => 'bar',
), get_permalink( self::$post_id )
),
get_permalink( self::$post_id )
);
$this->go_to( $link );
@@ -104,7 +108,8 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
$expected = add_query_arg(
array(
'cpage' => $cpage,
), get_permalink( self::$post_id ) . '#comments'
),
get_permalink( self::$post_id ) . '#comments'
);
$this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) );
@@ -123,7 +128,8 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
array(
'cpage' => $cpage,
'foo' => 'bar',
), get_permalink( self::$post_id )
),
get_permalink( self::$post_id )
);
$this->go_to( $link );
+51 -16
View File
@@ -403,7 +403,8 @@ https://w.org</a>',
// Add attachment metadata without sizes.
wp_update_attachment_metadata(
$id, array(
$id,
array(
'width' => 50,
'height' => 50,
'file' => 'test-image.jpg',
@@ -460,7 +461,9 @@ https://w.org</a>',
function test_get_attached_images() {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
$this->img_name, $post_id, array(
$this->img_name,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -478,7 +481,9 @@ https://w.org</a>',
$ids1_srcs = array();
foreach ( range( 1, 3 ) as $i ) {
$attachment_id = self::factory()->attachment->create_object(
"image$i.jpg", 0, array(
"image$i.jpg",
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -493,7 +498,9 @@ https://w.org</a>',
$ids2_srcs = array();
foreach ( range( 4, 6 ) as $i ) {
$attachment_id = self::factory()->attachment->create_object(
"image$i.jpg", 0, array(
"image$i.jpg",
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -624,7 +631,9 @@ BLOB;
$ids1_srcs = array();
foreach ( range( 1, 3 ) as $i ) {
$attachment_id = self::factory()->attachment->create_object(
"image$i.jpg", 0, array(
"image$i.jpg",
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -639,7 +648,9 @@ BLOB;
$ids2_srcs = array();
foreach ( range( 4, 6 ) as $i ) {
$attachment_id = self::factory()->attachment->create_object(
"image$i.jpg", 0, array(
"image$i.jpg",
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -1035,7 +1046,9 @@ VIDEO;
function test_attachment_url_to_postid() {
$image_path = '2014/11/' . $this->img_name;
$attachment_id = self::factory()->attachment->create_object(
$image_path, 0, array(
$image_path,
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -1048,7 +1061,9 @@ VIDEO;
function test_attachment_url_to_postid_schemes() {
$image_path = '2014/11/' . $this->img_name;
$attachment_id = self::factory()->attachment->create_object(
$image_path, 0, array(
$image_path,
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -1064,7 +1079,9 @@ VIDEO;
function test_attachment_url_to_postid_filtered() {
$image_path = '2014/11/' . $this->img_name;
$attachment_id = self::factory()->attachment->create_object(
$image_path, 0, array(
$image_path,
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -1110,7 +1127,10 @@ VIDEO;
);
$post_id = media_handle_upload(
'upload', 0, array(), array(
'upload',
0,
array(),
array(
'action' => 'test_iptc_upload',
'test_form' => false,
)
@@ -1146,7 +1166,10 @@ VIDEO;
);
$post_id = media_handle_upload(
'upload', 0, array(), array(
'upload',
0,
array(),
array(
'action' => 'test_upload_titles',
'test_form' => false,
)
@@ -1312,7 +1335,9 @@ EOF;
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
$this->img_name, $post_id, array(
$this->img_name,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -1333,7 +1358,9 @@ EOF;
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
$this->img_name, $post_id, array(
$this->img_name,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_excerpt' => $caption,
@@ -1351,7 +1378,9 @@ EOF;
function test_wp_get_attachment_caption_empty() {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
$this->img_name, $post_id, array(
$this->img_name,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_excerpt' => '',
@@ -2376,7 +2405,10 @@ EOF;
$parent_id = self::factory()->post->create( array( 'post_date' => '2010-01-01' ) );
$post_id = media_handle_upload(
'upload', $parent_id, array(), array(
'upload',
$parent_id,
array(),
array(
'action' => 'test_iptc_upload',
'test_form' => false,
)
@@ -2425,7 +2457,10 @@ EOF;
$parent = get_post( $parent_id );
$post_id = media_handle_upload(
'upload', $parent_id, array(), array(
'upload',
$parent_id,
array(),
array(
'action' => 'test_iptc_upload',
'test_form' => false,
)
@@ -9,7 +9,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'attachment' );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -26,7 +28,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'attachment:image' );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -43,7 +47,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'attachment:image/jpeg' );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -60,7 +66,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'attachment:jpg' );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -77,7 +85,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', array( 'attachment', 'attachment:image/jpeg' ) );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -97,7 +107,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax2', 'attachment:image' );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -119,7 +131,9 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax2', array( 'attachment:image', 'attachment:image/jpeg' ) );
$a = self::factory()->attachment->create_object(
'image.jpg', 0, array(
'image.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
)
@@ -39,7 +39,8 @@ class Tests_Menu_WpAjaxMenuQuickSeach extends WP_UnitTestCase {
include_once ABSPATH . 'wp-admin/includes/nav-menu.php';
self::factory()->post->create_many(
3, array(
3,
array(
'post_type' => 'page',
'post_content' => 'foo',
)
+6 -3
View File
@@ -144,7 +144,8 @@ class Tests_Meta extends WP_UnitTestCase {
// Test EXISTS and NOT EXISTS together, no users should be found
$this->assertEquals(
0, count(
0,
count(
get_users(
array(
'meta_query' => array(
@@ -163,7 +164,8 @@ class Tests_Meta extends WP_UnitTestCase {
);
$this->assertEquals(
2, count(
2,
count(
get_users(
array(
'meta_query' => array(
@@ -180,7 +182,8 @@ class Tests_Meta extends WP_UnitTestCase {
delete_metadata( 'user', $this->author->ID, 'meta_key' );
$this->assertEquals(
2, count(
2,
count(
get_users(
array(
'meta_query' => array(
+26 -13
View File
@@ -68,7 +68,8 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase {
array(
'auth' => 10,
'sanitize' => 10,
), $has_filters
),
$has_filters
);
}
@@ -430,23 +431,35 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase {
register_meta( $type, 'registered_key1', array() );
// This will override the above registration for objects of $subtype.
register_meta( $type, 'registered_key1', array(
'object_subtype' => $subtype,
'single' => true,
) );
register_meta(
$type,
'registered_key1',
array(
'object_subtype' => $subtype,
'single' => true,
)
);
// For testing with $single => false.
register_meta( $type, 'registered_key2', array(
'object_subtype' => $subtype,
) );
register_meta(
$type,
'registered_key2',
array(
'object_subtype' => $subtype,
)
);
// Register another meta key for a different subtype.
register_meta( $type, 'registered_key3', array(
'object_subtype' => 'other_subtype',
) );
register_meta(
$type,
'registered_key3',
array(
'object_subtype' => 'other_subtype',
)
);
$object_property_name = $type . '_id';
$object_id = self::$$object_property_name;
$object_id = self::$$object_property_name;
add_metadata( $type, $object_id, 'registered_key1', 'value1' );
add_metadata( $type, $object_id, 'registered_key2', 'value2' );
@@ -473,7 +486,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase {
*/
public function test_get_object_subtype( $type, $expected_subtype ) {
$object_property_name = $type . '_id';
$object_id = self::$$object_property_name;
$object_id = self::$$object_property_name;
$this->assertSame( $expected_subtype, get_object_subtype( $type, $object_id ) );
}
@@ -152,7 +152,8 @@ if ( is_multisite() ) :
array(
'domain' => 'wordpress.org',
'path' => '/',
), $get_all
),
$get_all
);
$result = array_keys( get_object_vars( $site ) );
@@ -170,7 +171,8 @@ if ( is_multisite() ) :
array(
'domain' => 'wordpress.org',
'path' => '/',
), $get_all
),
$get_all
);
$result = array();
@@ -206,7 +208,8 @@ if ( is_multisite() ) :
if ( $all ) {
$fields = array_merge(
$fields, array(
$fields,
array(
'blogname',
'siteurl',
'post_count',
+66 -43
View File
@@ -9,7 +9,7 @@ if ( is_multisite() ) :
* @group multisite
*/
class Tests_Multisite_Site extends WP_UnitTestCase {
protected $suppress = false;
protected $suppress = false;
protected $site_status_hooks = array();
protected static $network_ids;
protected static $site_ids;
@@ -1459,13 +1459,13 @@ if ( is_multisite() ) :
*/
public function test_wp_update_site_cleans_cache() {
$site_id = self::factory()->blog->create();
$site1 = get_site( $site_id );
$site1 = get_site( $site_id );
$result = wp_update_site( $site_id, array( 'public' => 0 ) );
$site2 = get_site( $site_id );
$site2 = get_site( $site_id );
$result = wp_update_site( $site_id, array( 'public' => 1 ) );
$site3 = get_site( $site_id );
$site3 = get_site( $site_id );
$this->assertEquals( 1, $site1->public );
$this->assertEquals( 0, $site2->public );
@@ -1709,11 +1709,13 @@ if ( is_multisite() ) :
*/
public function test_site_dates_are_gmt() {
$first_date = current_time( 'mysql', true );
$site_id = wp_insert_site( array(
'domain' => 'valid-domain.com',
'path' => '/valid-path/',
'network_id' => 1,
) );
$site_id = wp_insert_site(
array(
'domain' => 'valid-domain.com',
'path' => '/valid-path/',
'network_id' => 1,
)
);
$this->assertInternalType( 'integer', $site_id );
$site = get_site( $site_id );
@@ -1749,26 +1751,35 @@ if ( is_multisite() ) :
$old_domain = 'old.wordpress.org';
$new_domain = 'new.wordpress.org';
$site = self::factory()->blog->create_and_get( array(
'domain' => $old_domain,
'path' => '/',
) );
$site = self::factory()->blog->create_and_get(
array(
'domain' => $old_domain,
'path' => '/',
)
);
// Populate the caches.
get_blog_details( array(
'domain' => $old_domain,
'path' => '/',
) );
get_blog_details(
array(
'domain' => $old_domain,
'path' => '/',
)
);
get_blog_id_from_url( $old_domain, '/' );
get_blog_details( array(
'domain' => $new_domain,
'path' => '/',
) );
get_blog_details(
array(
'domain' => $new_domain,
'path' => '/',
)
);
get_blog_id_from_url( $new_domain, '/' );
wp_update_site( $site->id, array(
'domain' => $new_domain,
) );
wp_update_site(
$site->id,
array(
'domain' => $new_domain,
)
);
$domain_path_key_old = md5( $old_domain . '/' );
$domain_path_key_new = md5( $new_domain . '/' );
@@ -1795,26 +1806,35 @@ if ( is_multisite() ) :
$old_path = '/foo/';
$new_path = '/bar/';
$site = self::factory()->blog->create_and_get( array(
'domain' => 'test.wordpress.org',
'path' => $old_path,
) );
$site = self::factory()->blog->create_and_get(
array(
'domain' => 'test.wordpress.org',
'path' => $old_path,
)
);
// Populate the caches.
get_blog_details( array(
'domain' => 'test.wordpress.org',
'path' => $old_path,
) );
get_blog_details(
array(
'domain' => 'test.wordpress.org',
'path' => $old_path,
)
);
get_blog_id_from_url( 'test.wordpress.org', $old_path );
get_blog_details( array(
'domain' => 'test.wordpress.org',
'path' => $new_path,
) );
get_blog_details(
array(
'domain' => 'test.wordpress.org',
'path' => $new_path,
)
);
get_blog_id_from_url( 'test.wordpress.org', $new_path );
wp_update_site( $site->id, array(
'path' => $new_path,
) );
wp_update_site(
$site->id,
array(
'path' => $new_path,
)
);
$domain_path_key_old = md5( 'test.wordpress.org' . $old_path );
$domain_path_key_new = md5( 'test.wordpress.org' . $new_path );
@@ -1840,10 +1860,13 @@ if ( is_multisite() ) :
// First: Insert a site.
$this->listen_to_site_status_hooks();
$site_data = array_merge( array(
'domain' => 'example-site.com',
'path' => '/',
), $insert_site_data );
$site_data = array_merge(
array(
'domain' => 'example-site.com',
'path' => '/',
),
$insert_site_data
);
$site_id = wp_insert_site( $site_data );
+384 -353
View File
@@ -2,376 +2,407 @@
if ( is_multisite() ) :
/**
* @group ms-site
* @group multisite
* @group meta
* @ticket 37923
*/
class Tests_Multisite_Site_Meta extends WP_UnitTestCase {
protected static $site_id;
protected static $site_id2;
protected static $flag_was_set;
public static function wpSetUpBeforeClass( $factory ) {
self::$site_id = $factory->blog->create( array( 'domain' => 'wordpress.org', 'path' => '/' ) );
self::$site_id2 = $factory->blog->create( array( 'domain' => 'wordpress.org', 'path' => '/foo/' ) );
// Populate the main network flag as necessary.
self::$flag_was_set = true;
if ( false === get_network_option( get_main_network_id(), 'site_meta_supported', false ) ) {
self::$flag_was_set = false;
is_site_meta_supported();
}
}
public static function wpTearDownAfterClass() {
// Delete the possibly previously populated main network flag.
if ( ! self::$flag_was_set ) {
delete_network_option( get_main_network_id(), 'site_meta_supported' );
}
wpmu_delete_blog( self::$site_id, true );
wpmu_delete_blog( self::$site_id2, true );
wp_update_network_site_counts();
}
public function test_is_site_meta_supported() {
$this->assertTrue( is_site_meta_supported() );
}
public function test_is_site_meta_supported_filtered() {
add_filter( 'pre_site_option_site_meta_supported', '__return_zero' );
$this->assertFalse( is_site_meta_supported() );
}
public function test_add() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
$this->assertSame( 'bar', get_site_meta( self::$site_id, 'foo', true ) );
}
public function test_add_unique() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
$this->assertFalse( add_site_meta( self::$site_id, 'foo', 'bar', true ) );
}
public function test_delete() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
$this->assertTrue( delete_site_meta( self::$site_id, 'foo' ) );
$this->assertEmpty( get_site_meta( self::$site_id, 'foo', true ) );
}
public function test_delete_with_invalid_meta_key_should_return_false() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$this->assertFalse( delete_site_meta( self::$site_id, 'foo' ) );
}
public function test_delete_should_respect_meta_value() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo', 'baz' );
$this->assertTrue( delete_site_meta( self::$site_id, 'foo', 'bar' ) );
$metas = get_site_meta( self::$site_id, 'foo' );
$this->assertSame( array( 'baz' ), $metas );
}
public function test_get_with_no_key_should_fetch_all_keys() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo1', 'baz' );
$found = get_site_meta( self::$site_id );
$expected = array(
'foo' => array( 'bar' ),
'foo1' => array( 'baz' ),
);
$this->assertEqualSets( $expected, $found );
}
public function test_get_with_key_should_fetch_all_for_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo', 'baz' );
add_site_meta( self::$site_id, 'foo1', 'baz' );
$found = get_site_meta( self::$site_id, 'foo' );
$expected = array( 'bar', 'baz' );
$this->assertEqualSets( $expected, $found );
}
public function test_get_should_respect_single_true() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo', 'baz' );
$found = get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( 'bar', $found );
}
public function test_update_should_pass_to_add_when_no_value_exists_for_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$actual = update_site_meta( self::$site_id, 'foo', 'bar' );
$this->assertInternalType( 'int', $actual );
$this->assertNotEmpty( $actual );
$meta = get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( 'bar', $meta );
}
public function test_update_should_return_true_when_updating_existing_value_for_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
$actual = update_site_meta( self::$site_id, 'foo', 'baz' );
$this->assertTrue( $actual );
$meta = get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( 'baz', $meta );
}
public function test_delete_by_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'unique_delete_by_key', 'value', true );
add_site_meta( self::$site_id2, 'unique_delete_by_key', 'value', true );
$this->assertEquals( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
$this->assertEquals( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
$this->assertTrue( delete_site_meta_by_key( 'unique_delete_by_key' ) );
$this->assertEquals( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
$this->assertEquals( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
}
public function test_site_meta_should_be_deleted_when_site_is_deleted() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$site_id = self::factory()->blog->create( array( 'domain' => 'foo.org', 'path' => '/' ) );
add_site_meta( $site_id, 'foo', 'bar' );
add_site_meta( $site_id, 'foo1', 'bar' );
$this->assertSame( 'bar', get_site_meta( $site_id, 'foo', true ) );
$this->assertSame( 'bar', get_site_meta( $site_id, 'foo1', true ) );
wpmu_delete_blog( $site_id, true );
$this->assertSame( '', get_site_meta( $site_id, 'foo', true ) );
$this->assertSame( '', get_site_meta( $site_id, 'foo1', true ) );
}
public function test_update_site_meta_cache() {
global $wpdb;
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
update_site_meta( self::$site_id, 'foo', 'bar' );
update_sitemeta_cache( array( self::$site_id ) );
$num_queries = $wpdb->num_queries;
get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( $num_queries, $wpdb->num_queries);
}
public function test_query_update_site_meta_cache_true() {
global $wpdb;
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
update_site_meta( self::$site_id, 'foo', 'bar' );
// Do not include 'update_site_meta_cache' as true as its the default.
new WP_Site_Query( array(
'ID' => self::$site_id,
) );
$num_queries = $wpdb->num_queries;
get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( $num_queries, $wpdb->num_queries);
}
public function test_query_update_site_meta_cache_false() {
global $wpdb;
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
update_site_meta( self::$site_id, 'foo', 'bar' );
new WP_Site_Query( array(
'ID' => self::$site_id,
'update_site_meta_cache' => false,
) );
$num_queries = $wpdb->num_queries;
get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( $num_queries + 1, $wpdb->num_queries);
}
/**
* @ticket 40229
* @group ms-site
* @group multisite
* @group meta
* @ticket 37923
*/
public function test_add_site_meta_should_bust_get_sites_cache() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
class Tests_Multisite_Site_Meta extends WP_UnitTestCase {
protected static $site_id;
protected static $site_id2;
protected static $flag_was_set;
public static function wpSetUpBeforeClass( $factory ) {
self::$site_id = $factory->blog->create(
array(
'domain' => 'wordpress.org',
'path' => '/',
)
);
self::$site_id2 = $factory->blog->create(
array(
'domain' => 'wordpress.org',
'path' => '/foo/',
)
);
// Populate the main network flag as necessary.
self::$flag_was_set = true;
if ( false === get_network_option( get_main_network_id(), 'site_meta_supported', false ) ) {
self::$flag_was_set = false;
is_site_meta_supported();
}
}
add_site_meta( self::$site_id, 'foo', 'bar' );
public static function wpTearDownAfterClass() {
// Delete the possibly previously populated main network flag.
if ( ! self::$flag_was_set ) {
delete_network_option( get_main_network_id(), 'site_meta_supported' );
}
// Prime cache.
$found = get_sites( array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
) );
wpmu_delete_blog( self::$site_id, true );
wpmu_delete_blog( self::$site_id2, true );
$this->assertEqualSets( array( self::$site_id ), $found );
add_site_meta( self::$site_id2, 'foo', 'bar' );
$found = get_sites( array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
) );
$this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
}
/**
* @ticket 40229
*/
public function test_update_site_meta_should_bust_get_sites_cache() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
wp_update_network_site_counts();
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id2, 'foo', 'baz' );
// Prime cache.
$found = get_sites( array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
) );
$this->assertEqualSets( array( self::$site_id ), $found );
update_site_meta( self::$site_id2, 'foo', 'bar' );
$found = get_sites( array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
) );
$this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
}
/**
* @ticket 40229
*/
public function test_delete_site_meta_should_bust_get_sites_cache() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
public function test_is_site_meta_supported() {
$this->assertTrue( is_site_meta_supported() );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id2, 'foo', 'bar' );
public function test_is_site_meta_supported_filtered() {
add_filter( 'pre_site_option_site_meta_supported', '__return_zero' );
$this->assertFalse( is_site_meta_supported() );
}
// Prime cache.
$found = get_sites( array(
'fields' => 'ids',
'meta_query' => array(
public function test_add() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
$this->assertSame( 'bar', get_site_meta( self::$site_id, 'foo', true ) );
}
public function test_add_unique() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
$this->assertFalse( add_site_meta( self::$site_id, 'foo', 'bar', true ) );
}
public function test_delete() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
$this->assertTrue( delete_site_meta( self::$site_id, 'foo' ) );
$this->assertEmpty( get_site_meta( self::$site_id, 'foo', true ) );
}
public function test_delete_with_invalid_meta_key_should_return_false() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$this->assertFalse( delete_site_meta( self::$site_id, 'foo' ) );
}
public function test_delete_should_respect_meta_value() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo', 'baz' );
$this->assertTrue( delete_site_meta( self::$site_id, 'foo', 'bar' ) );
$metas = get_site_meta( self::$site_id, 'foo' );
$this->assertSame( array( 'baz' ), $metas );
}
public function test_get_with_no_key_should_fetch_all_keys() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo1', 'baz' );
$found = get_site_meta( self::$site_id );
$expected = array(
'foo' => array( 'bar' ),
'foo1' => array( 'baz' ),
);
$this->assertEqualSets( $expected, $found );
}
public function test_get_with_key_should_fetch_all_for_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo', 'baz' );
add_site_meta( self::$site_id, 'foo1', 'baz' );
$found = get_site_meta( self::$site_id, 'foo' );
$expected = array( 'bar', 'baz' );
$this->assertEqualSets( $expected, $found );
}
public function test_get_should_respect_single_true() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id, 'foo', 'baz' );
$found = get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( 'bar', $found );
}
public function test_update_should_pass_to_add_when_no_value_exists_for_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$actual = update_site_meta( self::$site_id, 'foo', 'bar' );
$this->assertInternalType( 'int', $actual );
$this->assertNotEmpty( $actual );
$meta = get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( 'bar', $meta );
}
public function test_update_should_return_true_when_updating_existing_value_for_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
$actual = update_site_meta( self::$site_id, 'foo', 'baz' );
$this->assertTrue( $actual );
$meta = get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( 'baz', $meta );
}
public function test_delete_by_key() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'unique_delete_by_key', 'value', true );
add_site_meta( self::$site_id2, 'unique_delete_by_key', 'value', true );
$this->assertEquals( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
$this->assertEquals( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
$this->assertTrue( delete_site_meta_by_key( 'unique_delete_by_key' ) );
$this->assertEquals( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
$this->assertEquals( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
}
public function test_site_meta_should_be_deleted_when_site_is_deleted() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
$site_id = self::factory()->blog->create(
array(
'key' => 'foo',
'value' => 'bar',
),
),
) );
'domain' => 'foo.org',
'path' => '/',
)
);
$this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
add_site_meta( $site_id, 'foo', 'bar' );
add_site_meta( $site_id, 'foo1', 'bar' );
delete_site_meta( self::$site_id2, 'foo', 'bar' );
$this->assertSame( 'bar', get_site_meta( $site_id, 'foo', true ) );
$this->assertSame( 'bar', get_site_meta( $site_id, 'foo1', true ) );
$found = get_sites( array(
'fields' => 'ids',
'meta_query' => array(
wpmu_delete_blog( $site_id, true );
$this->assertSame( '', get_site_meta( $site_id, 'foo', true ) );
$this->assertSame( '', get_site_meta( $site_id, 'foo1', true ) );
}
public function test_update_site_meta_cache() {
global $wpdb;
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
update_site_meta( self::$site_id, 'foo', 'bar' );
update_sitemeta_cache( array( self::$site_id ) );
$num_queries = $wpdb->num_queries;
get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( $num_queries, $wpdb->num_queries );
}
public function test_query_update_site_meta_cache_true() {
global $wpdb;
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
update_site_meta( self::$site_id, 'foo', 'bar' );
// Do not include 'update_site_meta_cache' as true as its the default.
new WP_Site_Query(
array(
'key' => 'foo',
'value' => 'bar',
),
),
) );
'ID' => self::$site_id,
)
);
$this->assertEqualSets( array( self::$site_id ), $found );
$num_queries = $wpdb->num_queries;
get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( $num_queries, $wpdb->num_queries );
}
public function test_query_update_site_meta_cache_false() {
global $wpdb;
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
update_site_meta( self::$site_id, 'foo', 'bar' );
new WP_Site_Query(
array(
'ID' => self::$site_id,
'update_site_meta_cache' => false,
)
);
$num_queries = $wpdb->num_queries;
get_site_meta( self::$site_id, 'foo', true );
$this->assertSame( $num_queries + 1, $wpdb->num_queries );
}
/**
* @ticket 40229
*/
public function test_add_site_meta_should_bust_get_sites_cache() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
// Prime cache.
$found = get_sites(
array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
)
);
$this->assertEqualSets( array( self::$site_id ), $found );
add_site_meta( self::$site_id2, 'foo', 'bar' );
$found = get_sites(
array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
)
);
$this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
}
/**
* @ticket 40229
*/
public function test_update_site_meta_should_bust_get_sites_cache() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id2, 'foo', 'baz' );
// Prime cache.
$found = get_sites(
array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
)
);
$this->assertEqualSets( array( self::$site_id ), $found );
update_site_meta( self::$site_id2, 'foo', 'bar' );
$found = get_sites(
array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
)
);
$this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
}
/**
* @ticket 40229
*/
public function test_delete_site_meta_should_bust_get_sites_cache() {
if ( ! is_site_meta_supported() ) {
$this->markTestSkipped( 'Tests only runs with the blogmeta database table installed' );
}
add_site_meta( self::$site_id, 'foo', 'bar' );
add_site_meta( self::$site_id2, 'foo', 'bar' );
// Prime cache.
$found = get_sites(
array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
)
);
$this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
delete_site_meta( self::$site_id2, 'foo', 'bar' );
$found = get_sites(
array(
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'foo',
'value' => 'bar',
),
),
)
);
$this->assertEqualSets( array( self::$site_id ), $found );
}
}
}
endif;
@@ -28,7 +28,8 @@ if ( is_multisite() ) :
$blog_id = self::factory()->blog->create();
$result = update_blog_details(
$blog_id, array(
$blog_id,
array(
'domain' => 'example.com',
'path' => 'my_path/',
)
+4 -2
View File
@@ -61,13 +61,15 @@ class Tests_WP_Embed extends WP_UnitTestCase {
$this->assertEqualSets(
array(
'youtube_embed_url',
), array_keys( $GLOBALS['wp_embed']->handlers[10] )
),
array_keys( $GLOBALS['wp_embed']->handlers[10] )
);
$this->assertEqualSets(
array(
'audio',
'video',
), array_keys( $GLOBALS['wp_embed']->handlers[9999] )
),
array_keys( $GLOBALS['wp_embed']->handlers[9999] )
);
}
+5 -2
View File
@@ -20,7 +20,8 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
function test_add_oembed_discovery_links_static_front_page() {
update_option( 'show_on_front', 'page' );
update_option(
'page_on_front', self::factory()->post->create(
'page_on_front',
self::factory()->post->create(
array(
'post_title' => 'front-page',
'post_type' => 'page',
@@ -69,7 +70,9 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
)
);
+12 -5
View File
@@ -29,7 +29,8 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
'width' => 400,
'height' => 225,
'html' => get_post_embed_html( 400, 225, $post ),
), $data
),
$data
);
}
@@ -64,7 +65,8 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
'width' => 400,
'height' => 225,
'html' => get_post_embed_html( 400, 225, $post ),
), $data
),
$data
);
}
@@ -88,7 +90,8 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
'author_url' => get_home_url( '/' ),
'title' => 'Some Post',
'type' => 'link',
), $data
),
$data
);
add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 );
@@ -161,7 +164,9 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
$post = self::factory()->post->create_and_get();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = self::factory()->attachment->create_object(
$file, $post->ID, array(
$file,
$post->ID,
array(
'post_mime_type' => 'image/jpeg',
)
);
@@ -179,7 +184,9 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase {
$parent = self::factory()->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
$post = self::factory()->attachment->create_object(
$file, $parent, array(
$file,
$parent,
array(
'post_mime_type' => 'image/jpeg',
)
);
+9 -3
View File
@@ -43,7 +43,9 @@ class Tests_Embed_Template extends WP_UnitTestCase {
);
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
)
);
@@ -83,7 +85,9 @@ class Tests_Embed_Template extends WP_UnitTestCase {
$post = self::factory()->post->create_and_get();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = self::factory()->attachment->create_object(
$file, $post->ID, array(
$file,
$post->ID,
array(
'post_mime_type' => 'image/jpeg',
'post_title' => 'Hello World',
'post_content' => 'Foo Bar',
@@ -244,7 +248,9 @@ class Tests_Embed_Template extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
)
);
+15 -5
View File
@@ -28,7 +28,9 @@ class Tests_Option_Registration extends WP_UnitTestCase {
public function test_register_with_array() {
register_setting(
'test_group', 'test_option', array(
'test_group',
'test_option',
array(
'sanitize_callback' => array( $this, 'filter_registered_setting' ),
)
);
@@ -46,7 +48,9 @@ class Tests_Option_Registration extends WP_UnitTestCase {
*/
public function test_register_with_default() {
register_setting(
'test_group', 'test_default', array(
'test_group',
'test_default',
array(
'default' => 'Got that Viper with them rally stripes',
)
);
@@ -59,7 +63,9 @@ class Tests_Option_Registration extends WP_UnitTestCase {
*/
public function test_register_with_default_override() {
register_setting(
'test_group', 'test_default', array(
'test_group',
'test_default',
array(
'default' => 'Got that Viper with them rally stripes',
)
);
@@ -74,7 +80,9 @@ class Tests_Option_Registration extends WP_UnitTestCase {
*/
public function test_add_option_with_no_options_cache() {
register_setting(
'test_group', 'test_default', array(
'test_group',
'test_default',
array(
'default' => 'My Default :)',
)
);
@@ -102,7 +110,9 @@ class Tests_Option_Registration extends WP_UnitTestCase {
*/
public function test_unregister_setting_removes_default() {
register_setting(
'test_group', 'test_default', array(
'test_group',
'test_default',
array(
'default' => 'Got that Viper with them rally stripes',
)
);
+2 -1
View File
@@ -263,7 +263,8 @@ class Tests_Pluggable extends WP_UnitTestCase {
// Pluggable function signatures are not tested when an external object cache is in use. #31491
if ( ! wp_using_ext_object_cache() ) {
$signatures = array_merge(
$signatures, array(
$signatures,
array(
// wp-includes/cache.php:
'wp_cache_add' => array(
+2 -1
View File
@@ -12,7 +12,8 @@ class Tests_POMO_MO extends WP_UnitTestCase {
array(
'Project-Id-Version' => 'WordPress 2.6-bleeding',
'Report-Msgid-Bugs-To' => 'wp-polyglots@lists.automattic.com',
), $mo->headers
),
$mo->headers
);
$this->assertEquals( 2, count( $mo->entries ) );
$this->assertEquals( array( 'dyado' ), $mo->entries['baba']->translations );
+16 -8
View File
@@ -91,7 +91,8 @@ http://wordpress.org/
'msgid "baba"
msgid_plural "babas"
msgstr[0] ""
msgstr[1] ""', $po->export_entry( $entry )
msgstr[1] ""',
$po->export_entry( $entry )
);
$entry = new Translation_Entry(
array(
@@ -103,7 +104,8 @@ msgstr[1] ""', $po->export_entry( $entry )
'# baba
# dyado
msgid "baba"
msgstr ""', $po->export_entry( $entry )
msgstr ""',
$po->export_entry( $entry )
);
$entry = new Translation_Entry(
array(
@@ -114,7 +116,8 @@ msgstr ""', $po->export_entry( $entry )
$this->assertEquals(
'#. baba
msgid "baba"
msgstr ""', $po->export_entry( $entry )
msgstr ""',
$po->export_entry( $entry )
);
$entry = new Translation_Entry(
array(
@@ -128,7 +131,8 @@ msgstr ""', $po->export_entry( $entry )
#: 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
msgid "baba"
msgstr ""', $po->export_entry( $entry )
msgstr ""',
$po->export_entry( $entry )
);
$entry = new Translation_Entry(
array(
@@ -156,7 +160,8 @@ msgstr ""', $po->export_entry( $entry )
$this->assertEquals(
'msgid "baba"
msgid_plural "babas"
msgstr[0] "кукубуку"', $po->export_entry( $entry )
msgstr[0] "кукубуку"',
$po->export_entry( $entry )
);
$entry = new Translation_Entry(
@@ -171,7 +176,8 @@ msgstr[0] "кукубуку"', $po->export_entry( $entry )
msgid_plural "babas"
msgstr[0] "кукубуку"
msgstr[1] "кукуруку"
msgstr[2] "бабаяга"', $po->export_entry( $entry )
msgstr[2] "бабаяга"',
$po->export_entry( $entry )
);
// context
$entry = new Translation_Entry(
@@ -190,7 +196,8 @@ msgid "baba"
msgid_plural "babas"
msgstr[0] "кукубуку"
msgstr[1] "кукуруку"
msgstr[2] "бабаяга"', $po->export_entry( $entry )
msgstr[2] "бабаяга"',
$po->export_entry( $entry )
);
}
@@ -250,7 +257,8 @@ msgstr[2] "бабаяга"', $po->export_entry( $entry )
array(
'Project-Id-Version' => 'WordPress 2.6-bleeding',
'Plural-Forms' => 'nplurals=2; plural=n != 1;',
), $po->headers
),
$po->headers
);
$simple_entry = new Translation_Entry( array( 'singular' => 'moon' ) );
+4 -2
View File
@@ -22,7 +22,8 @@ class Tests_POMO_Translations extends WP_UnitTestCase {
array(
$entry->key() => $entry,
$entry2->key() => $entry2,
), $po->entries
),
$po->entries
);
// add empty entry
$this->assertEquals( false, $po->add_entry( $empty ) );
@@ -30,7 +31,8 @@ class Tests_POMO_Translations extends WP_UnitTestCase {
array(
$entry->key() => $entry,
$entry2->key() => $entry2,
), $po->entries
),
$po->entries
);
// give add_entry() the arguments and let it create the entry itself
+5 -2
View File
@@ -13,7 +13,9 @@ class Tests_Post extends WP_UnitTestCase {
self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
add_role(
'grammarian', 'Grammarian', array(
'grammarian',
'Grammarian',
array(
'read' => true,
'edit_posts' => true,
'edit_others_posts' => true,
@@ -813,7 +815,8 @@ class Tests_Post extends WP_UnitTestCase {
$post_type = rand_str( 20 );
register_post_type( $post_type );
self::factory()->post->create_many(
3, array(
3,
array(
'post_type' => $post_type,
'post_author' => self::$editor_id,
)
+3 -1
View File
@@ -187,7 +187,9 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
)
);
+14 -7
View File
@@ -107,7 +107,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
*/
public function test_cache_should_be_invalidated_by_add_post_meta() {
$posts = self::factory()->post->create_many(
2, array(
2,
array(
'post_type' => 'page',
)
);
@@ -142,7 +143,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
*/
public function test_cache_should_be_invalidated_by_update_post_meta() {
$posts = self::factory()->post->create_many(
2, array(
2,
array(
'post_type' => 'page',
)
);
@@ -178,7 +180,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
*/
public function test_cache_should_be_invalidated_by_delete_post_meta() {
$posts = self::factory()->post->create_many(
2, array(
2,
array(
'post_type' => 'page',
)
);
@@ -214,7 +217,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
*/
public function test_cache_should_be_invalidated_by_delete_post_meta_by_key() {
$posts = self::factory()->post->create_many(
2, array(
2,
array(
'post_type' => 'page',
)
);
@@ -255,7 +259,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
add_post_meta( $posts[2], 'some-meta-key', '1' );
$this->assertEquals(
1, count(
1,
count(
get_pages(
array(
'meta_key' => 'some-meta-key',
@@ -265,7 +270,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
)
);
$this->assertEquals(
1, count(
1,
count(
get_pages(
array(
'meta_key' => 'some-meta-key',
@@ -618,7 +624,8 @@ class Tests_Post_getPages extends WP_UnitTestCase {
function test_wp_list_pages_classes() {
$type = 'taco';
register_post_type(
$type, array(
$type,
array(
'hierarchical' => true,
'public' => true,
)
+67 -46
View File
@@ -5,76 +5,94 @@
*/
class Tests_Get_Post_Type_Labels extends WP_UnitTestCase {
public function test_returns_an_object() {
$this->assertInternalType( 'object', get_post_type_labels( (object) array(
'name' => 'foo',
'labels' => array(),
'hierarchical' => false,
) ) );
$this->assertInternalType(
'object',
get_post_type_labels(
(object) array(
'name' => 'foo',
'labels' => array(),
'hierarchical' => false,
)
)
);
}
public function test_returns_hierachical_labels() {
$labels = get_post_type_labels( (object) array(
'name' => 'foo',
'labels' => array(),
'hierarchical' => true,
) );
$labels = get_post_type_labels(
(object) array(
'name' => 'foo',
'labels' => array(),
'hierarchical' => true,
)
);
$this->assertSame( 'Pages', $labels->name );
}
public function test_existing_labels_are_not_overridden() {
$labels = get_post_type_labels( (object) array(
'name' => 'foo',
'labels' => array(
'singular_name' => 'Foo',
),
'hierarchical' => false,
) );
$labels = get_post_type_labels(
(object) array(
'name' => 'foo',
'labels' => array(
'singular_name' => 'Foo',
),
'hierarchical' => false,
)
);
$this->assertSame( 'Foo', $labels->singular_name );
}
public function test_name_admin_bar_label_should_fall_back_to_singular_name() {
$labels = get_post_type_labels( (object) array(
'name' => 'foo',
'labels' => array(
'singular_name' => 'Foo',
),
'hierarchical' => false,
) );
$labels = get_post_type_labels(
(object) array(
'name' => 'foo',
'labels' => array(
'singular_name' => 'Foo',
),
'hierarchical' => false,
)
);
$this->assertSame( 'Foo', $labels->name_admin_bar );
}
public function test_name_admin_bar_label_should_fall_back_to_post_type_name() {
$labels = get_post_type_labels( (object) array(
'name' => 'bar',
'labels' => array(),
'hierarchical' => false,
) );
$labels = get_post_type_labels(
(object) array(
'name' => 'bar',
'labels' => array(),
'hierarchical' => false,
)
);
$this->assertSame( 'bar', $labels->name_admin_bar );
}
public function test_menu_name_should_fall_back_to_name() {
$labels = get_post_type_labels( (object) array(
'name' => 'foo',
'labels' => array(
'name' => 'Bar',
),
'hierarchical' => false,
) );
$labels = get_post_type_labels(
(object) array(
'name' => 'foo',
'labels' => array(
'name' => 'Bar',
),
'hierarchical' => false,
)
);
$this->assertSame( 'Bar', $labels->menu_name );
}
public function test_labels_should_be_added_when_registering_a_post_type() {
$post_type_object = register_post_type( 'foo', array(
'labels' => array(
'singular_name' => 'bar',
),
) );
$post_type_object = register_post_type(
'foo',
array(
'labels' => array(
'singular_name' => 'bar',
),
)
);
unregister_post_type( 'foo' );
@@ -84,11 +102,14 @@ class Tests_Get_Post_Type_Labels extends WP_UnitTestCase {
}
public function test_label_should_be_derived_from_labels_when_registering_a_post_type() {
$post_type_object = register_post_type( 'foo', array(
'labels' => array(
'name' => 'bar',
),
) );
$post_type_object = register_post_type(
'foo',
array(
'labels' => array(
'name' => 'bar',
),
)
);
$this->assertSame( 'bar', $post_type_object->label );
@@ -6,7 +6,8 @@
class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
public function test_should_return_false_for_non_publicly_queryable_types() {
register_post_type(
'wptests_pt', array(
'wptests_pt',
array(
'publicly_queryable' => false,
'_builtin' => false,
'public' => true,
@@ -20,7 +21,8 @@ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
public function test_should_return_true_for_publicly_queryable_types() {
register_post_type(
'wptests_pt', array(
'wptests_pt',
array(
'publicly_queryable' => true,
'_builtin' => false,
'public' => false,
@@ -34,7 +36,8 @@ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
public function test_should_return_false_for_builtin_nonpublic_types() {
register_post_type(
'wptests_pt', array(
'wptests_pt',
array(
'publicly_queryable' => false,
'_builtin' => true,
'public' => false,
@@ -48,7 +51,8 @@ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
public function test_should_return_false_for_nonbuiltin_public_types() {
register_post_type(
'wptests_pt', array(
'wptests_pt',
array(
'publicly_queryable' => false,
'_builtin' => false,
'public' => true,
@@ -62,7 +66,8 @@ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
public function test_should_return_true_for_builtin_public_types() {
register_post_type(
'wptests_pt', array(
'wptests_pt',
array(
'publicly_queryable' => false,
'_builtin' => true,
'public' => true,
@@ -87,7 +92,8 @@ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
*/
public function test_should_accept_post_type_name() {
register_post_type(
'wptests_pt', array(
'wptests_pt',
array(
'publicly_queryable' => true,
'_builtin' => false,
'public' => false,
+17 -13
View File
@@ -19,19 +19,23 @@ class Tests_Post_Meta extends WP_UnitTestCase {
public static function wpSetUpBeforeClass( $factory ) {
self::$author = $factory->user->create_and_get( array( 'role' => 'editor' ) );
self::$post_id = $factory->post->create( array(
'post_author' => self::$author->ID,
'post_status' => 'publish',
'post_content' => rand_str(),
'post_title' => rand_str(),
) );
self::$post_id = $factory->post->create(
array(
'post_author' => self::$author->ID,
'post_status' => 'publish',
'post_content' => rand_str(),
'post_title' => rand_str(),
)
);
self::$post_id_2 = $factory->post->create( array(
'post_author' => self::$author->ID,
'post_status' => 'publish',
'post_content' => rand_str(),
'post_title' => rand_str(),
) );
self::$post_id_2 = $factory->post->create(
array(
'post_author' => self::$author->ID,
'post_status' => 'publish',
'post_content' => rand_str(),
'post_title' => rand_str(),
)
);
}
public static function wpTearDownAfterClass() {
@@ -304,5 +308,5 @@ class Tests_Post_Meta extends WP_UnitTestCase {
array( 'page', 'registered_key2' ),
array( '', 'registered_key3' ),
);
}
}
}
+90 -32
View File
@@ -22,7 +22,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$tag_id = self::factory()->tag->create();
wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'post_tag',
'menu-item-object-id' => $tag_id,
@@ -49,7 +51,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
$tag_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'post_tag',
'menu-item-object-id' => $tag_id,
@@ -58,7 +62,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$cat_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'category',
'menu-item-object-id' => $cat_id,
@@ -67,7 +73,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$post_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -77,7 +85,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
// Item without menu-item-object arg
$post_2_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object-id' => $post_2_id,
'menu-item-status' => 'publish',
@@ -85,7 +95,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$page_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $page_id,
@@ -132,7 +144,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
// Create an orphan nav menu item
$custom_item_id = wp_update_nav_menu_item(
0, 0, array(
0,
0,
array(
'menu-item-type' => 'custom',
'menu-item-title' => 'Wordpress.org',
'menu-item-link' => 'http://wordpress.org',
@@ -146,7 +160,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
// Update the orphan with an associated nav menu
wp_update_nav_menu_item(
$this->menu_id, $custom_item_id, array(
$this->menu_id,
$custom_item_id,
array(
'menu-item-title' => 'WordPress.org',
)
);
@@ -161,14 +177,17 @@ class Test_Nav_Menus extends WP_UnitTestCase {
register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
$t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
$child_terms = self::factory()->term->create_many(
2, array(
2,
array(
'taxonomy' => 'wptests_tax',
'parent' => $t,
)
);
$term_menu_item = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'wptests_tax',
'menu-item-object-id' => $t,
@@ -216,7 +235,8 @@ class Test_Nav_Menus extends WP_UnitTestCase {
// This is the expected array of menu names
$expected_nav_menus_names = wp_list_pluck(
get_terms(
'nav_menu', array(
'nav_menu',
array(
'hide_empty' => false,
'orderby' => 'name',
)
@@ -238,7 +258,8 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$post_type_slug = rand_str( 12 );
$post_type_description = rand_str();
register_post_type(
$post_type_slug, array(
$post_type_slug,
array(
'public' => true,
'has_archive' => true,
'description' => $post_type_description,
@@ -247,7 +268,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$post_type_archive_item_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type_archive',
'menu-item-object' => $post_type_slug,
'menu-item-description' => $post_type_description,
@@ -268,7 +291,8 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$post_type_slug = rand_str( 12 );
$post_type_description = '';
register_post_type(
$post_type_slug, array(
$post_type_slug,
array(
'public' => true,
'has_archive' => true,
'label' => $post_type_slug,
@@ -276,7 +300,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$post_type_archive_item_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type_archive',
'menu-item-object' => $post_type_slug,
'menu-item-status' => 'publish',
@@ -296,7 +322,8 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$post_type_slug = rand_str( 12 );
$post_type_description = rand_str();
register_post_type(
$post_type_slug, array(
$post_type_slug,
array(
'public' => true,
'has_archive' => true,
'description' => $post_type_description,
@@ -307,7 +334,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$menu_item_description = rand_str();
$post_type_archive_item_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type_archive',
'menu-item-object' => $post_type_slug,
'menu-item-description' => $menu_item_description,
@@ -328,7 +357,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$post_type_slug = rand_str( 12 );
$post_type_archive_item_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type_archive',
'menu-item-object' => $post_type_slug,
'menu-item-status' => 'publish',
@@ -350,7 +381,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$menu_item_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id,
@@ -373,7 +406,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$post_id4 = self::factory()->post->create();
$post_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id1,
@@ -382,7 +417,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$post_inser2 = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-object-id' => $post_id2,
@@ -391,7 +428,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$post_insert3 = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-parent-id' => $post_insert,
@@ -401,7 +440,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$post_insert4 = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'post',
'menu-item-parent-id' => $post_insert,
@@ -449,7 +490,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
$tag_id = self::factory()->tag->create();
$tag_insert = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'post_tag',
'menu-item-object-id' => $tag_id,
@@ -540,7 +583,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $page_id,
@@ -570,7 +615,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
update_option( 'page_on_front', $page_id );
wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $page_id,
@@ -611,7 +658,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
update_option( 'page_on_front', $new_id );
wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'taxonomy',
'menu-item-object' => 'post_tag',
'menu-item-object-id' => $new_id,
@@ -689,7 +738,8 @@ class Test_Nav_Menus extends WP_UnitTestCase {
function test_parent_ancestor_for_post_archive() {
register_post_type(
'books', array(
'books',
array(
'label' => 'Books',
'public' => true,
'has_archive' => true,
@@ -710,7 +760,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$first_menu_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $first_page_id,
@@ -719,7 +771,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
$second_menu_id = wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $second_page_id,
@@ -729,7 +783,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
);
wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-type' => 'post_type_archive',
'menu-item-object' => 'books',
'menu-item-status' => 'publish',
@@ -782,7 +838,9 @@ class Test_Nav_Menus extends WP_UnitTestCase {
*/
function test_iri_current_menu_item( $custom_link, $current = true ) {
wp_update_nav_menu_item(
$this->menu_id, 0, array(
$this->menu_id,
0,
array(
'menu-item-status' => 'publish',
'menu-item-type' => 'custom',
'menu-item-url' => $custom_link,
+2 -1
View File
@@ -33,7 +33,8 @@ class Tests_Post_Output extends WP_UnitTestCase {
shortcode_atts(
array(
'class' => 'graf',
), $atts
),
$atts
)
);
return "<p class='$class'>$content</p>\n";
+15 -5
View File
@@ -179,31 +179,41 @@ class Tests_Post_Query extends WP_UnitTestCase {
$att_ids = array();
$file = DIR_TESTDATA . '/images/canola.jpg';
$att_ids[1] = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 ),
)
);
$att_ids[2] = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 ),
)
);
$att_ids[3] = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 ),
)
);
$att_ids[4] = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 ),
)
);
$att_ids[5] = self::factory()->attachment->create_object(
$file, $post_id, array(
$file,
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'menu_order' => rand( 1, 100 ),
)
+8 -4
View File
@@ -322,7 +322,8 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
*/
function test_revision_view_caps_cpt() {
register_post_type(
$this->post_type, array(
$this->post_type,
array(
'capability_type' => 'event',
'map_meta_cap' => true,
'supports' => array( 'revisions' ),
@@ -363,7 +364,8 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
*/
function test_revision_restore_caps_cpt() {
register_post_type(
$this->post_type, array(
$this->post_type,
array(
'capability_type' => 'event',
'map_meta_cap' => true,
'supports' => array( 'revisions' ),
@@ -408,7 +410,8 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
*/
function test_revision_restore_caps_before_publish() {
register_post_type(
$this->post_type, array(
$this->post_type,
array(
'capability_type' => 'post',
'capabilities' => array(
// No one can edit this post type once published.
@@ -467,7 +470,8 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
*/
function test_revision_diff_caps_cpt() {
register_post_type(
$this->post_type, array(
$this->post_type,
array(
'capability_type' => 'event',
'map_meta_cap' => true,
'supports' => array( 'revisions' ),
+20 -6
View File
@@ -18,7 +18,9 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
$file = DIR_TESTDATA . '/images/canola.jpg';
self::$attachment_id = $factory->attachment->create_upload_object(
$file, self::$post->ID, array(
$file,
self::$post->ID,
array(
'post_mime_type' => 'image/jpeg',
)
);
@@ -94,7 +96,9 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_excerpt' => $caption,
@@ -112,7 +116,9 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
function test_get_the_post_thumbnail_caption_empty() {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_excerpt' => '',
@@ -132,7 +138,9 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
$attachment_id = self::factory()->attachment->create_object(
'image.jpg', $post_id, array(
'image.jpg',
$post_id,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_excerpt' => $caption,
@@ -151,7 +159,10 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
set_post_thumbnail( self::$post, self::$attachment_id );
$expected = wp_get_attachment_image(
self::$attachment_id, 'post-thumbnail', false, array(
self::$attachment_id,
'post-thumbnail',
false,
array(
'class' => 'attachment-post-thumbnail size-post-thumbnail wp-post-image',
)
);
@@ -176,7 +187,10 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
set_post_thumbnail( self::$post, self::$attachment_id );
$expected = wp_get_attachment_image(
self::$attachment_id, 'post-thumbnail', false, array(
self::$attachment_id,
'post-thumbnail',
false,
array(
'class' => 'attachment-post-thumbnail size-post-thumbnail wp-post-image',
)
);
+20 -10
View File
@@ -298,7 +298,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'query_var' => 'bar',
)
@@ -318,7 +319,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp_rewrite;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'query_var' => 'bar',
)
@@ -343,7 +345,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp_rewrite;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'has_archive' => true,
)
@@ -361,7 +364,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $post_type_meta_caps;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'capability_type' => 'bar',
'map_meta_cap' => true,
@@ -386,7 +390,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $_wp_post_type_features;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'supports' => array( 'editor', 'author', 'title' ),
)
@@ -411,7 +416,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp_taxonomies;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'taxonomies' => array( 'category', 'post_tag' ),
)
@@ -432,7 +438,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp_filter;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
)
);
@@ -450,7 +457,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp_filter;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
'register_meta_box_cb' => '__return_empty_string',
)
@@ -469,7 +477,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
global $wp_post_types;
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
)
);
@@ -488,7 +497,8 @@ class Tests_Post_Types extends WP_UnitTestCase {
*/
public function test_post_type_does_not_exist_after_unregister_post_type() {
register_post_type(
'foo', array(
'foo',
array(
'public' => true,
)
);
+85 -60
View File
@@ -12,12 +12,16 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
static function wpSetUpBeforeClass( $factory ) {
self::$user_ids = array(
'administrator' => $factory->user->create( array(
'role' => 'administrator',
) ),
'contributor' => $factory->user->create( array(
'role' => 'contributor',
) ),
'administrator' => $factory->user->create(
array(
'role' => 'administrator',
)
),
'contributor' => $factory->user->create(
array(
'role' => 'contributor',
)
),
);
$role = get_role( 'administrator' );
@@ -36,20 +40,29 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
function setUp() {
parent::setUp();
register_post_type( 'mapped_meta_caps', array(
'capability_type' => array( 'mapped_meta_cap', 'mapped_meta_caps' ),
'map_meta_cap' => true,
) );
register_post_type(
'mapped_meta_caps',
array(
'capability_type' => array( 'mapped_meta_cap', 'mapped_meta_caps' ),
'map_meta_cap' => true,
)
);
register_post_type( 'unmapped_meta_caps', array(
'capability_type' => array( 'unmapped_meta_cap', 'unmapped_meta_caps' ),
'map_meta_cap' => false,
) );
register_post_type(
'unmapped_meta_caps',
array(
'capability_type' => array( 'unmapped_meta_cap', 'unmapped_meta_caps' ),
'map_meta_cap' => false,
)
);
register_post_type( 'no_admin_caps', array(
'capability_type' => array( 'no_admin_cap', 'no_admin_caps' ),
'map_meta_cap' => false,
) );
register_post_type(
'no_admin_caps',
array(
'capability_type' => array( 'no_admin_cap', 'no_admin_caps' ),
'map_meta_cap' => false,
)
);
}
/**
@@ -179,28 +192,32 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
function test_contributor_cannot_set_post_slug( $post_type ) {
wp_set_current_user( self::$user_ids['contributor'] );
$post_id = $this->factory()->post->create( array(
'post_title' => 'Jefferson claim: nice to have Washington on your side.',
'post_content' => "Im in the cabinet. I am complicit in watching him grabbin at power and kiss it.\n\nIf Washington isnt gon listen to disciplined dissidents, this is the difference: this kid is out!",
'post_type' => $post_type,
'post_name' => 'new-washington',
'post_status' => 'pending',
) );
$post_id = $this->factory()->post->create(
array(
'post_title' => 'Jefferson claim: nice to have Washington on your side.',
'post_content' => "Im in the cabinet. I am complicit in watching him grabbin at power and kiss it.\n\nIf Washington isnt gon listen to disciplined dissidents, this is the difference: this kid is out!",
'post_type' => $post_type,
'post_name' => 'new-washington',
'post_status' => 'pending',
)
);
$expected = '';
$actual = get_post_field( 'post_name', $post_id );
$actual = get_post_field( 'post_name', $post_id );
$this->assertSame( $expected, $actual );
// Now update the post.
wp_update_post( array(
'ID' => $post_id,
'post_title' => 'Hamilton has Washington on side: Jefferson',
'post_name' => 'edited-washington',
) );
wp_update_post(
array(
'ID' => $post_id,
'post_title' => 'Hamilton has Washington on side: Jefferson',
'post_name' => 'edited-washington',
)
);
$expected = '';
$actual = get_post_field( 'post_name', $post_id );
$actual = get_post_field( 'post_name', $post_id );
$this->assertSame( $expected, $actual );
}
@@ -214,28 +231,32 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
function test_administrator_can_set_post_slug( $post_type ) {
wp_set_current_user( self::$user_ids['administrator'] );
$post_id = $this->factory()->post->create( array(
'post_title' => 'What is the Conner Project?',
'post_content' => "Evan Hansens last link to his friend Conner is a signature on his broken arm.",
'post_type' => $post_type,
'post_name' => 'dear-evan-hansen-explainer',
'post_status' => 'pending',
) );
$post_id = $this->factory()->post->create(
array(
'post_title' => 'What is the Conner Project?',
'post_content' => 'Evan Hansens last link to his friend Conner is a signature on his broken arm.',
'post_type' => $post_type,
'post_name' => 'dear-evan-hansen-explainer',
'post_status' => 'pending',
)
);
$expected = 'dear-evan-hansen-explainer';
$actual = get_post_field( 'post_name', $post_id );
$actual = get_post_field( 'post_name', $post_id );
$this->assertSame( $expected, $actual );
// Now update the post.
wp_update_post( array(
'ID' => $post_id,
'post_title' => 'Conner Project to close',
'post_name' => 'dear-evan-hansen-spoiler',
) );
wp_update_post(
array(
'ID' => $post_id,
'post_title' => 'Conner Project to close',
'post_name' => 'dear-evan-hansen-spoiler',
)
);
$expected = 'dear-evan-hansen-spoiler';
$actual = get_post_field( 'post_name', $post_id );
$actual = get_post_field( 'post_name', $post_id );
$this->assertSame( $expected, $actual );
}
@@ -251,28 +272,32 @@ class Tests_WPInsertPost extends WP_UnitTestCase {
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( 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.',
'post_type' => 'no_admin_caps',
'post_name' => 'yet-another-duel',
'post_status' => 'pending',
) );
$post_id = $this->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.',
'post_type' => 'no_admin_caps',
'post_name' => 'yet-another-duel',
'post_status' => 'pending',
)
);
$expected = '';
$actual = get_post_field( 'post_name', $post_id );
$actual = get_post_field( 'post_name', $post_id );
$this->assertSame( $expected, $actual );
// Now update the post.
wp_update_post( array(
'ID' => $post_id,
'post_title' => 'Ten things illegal in New Jersey',
'post_name' => 'foreshadowing-in-nj',
) );
wp_update_post(
array(
'ID' => $post_id,
'post_title' => 'Ten things illegal in New Jersey',
'post_name' => 'foreshadowing-in-nj',
)
);
$expected = '';
$actual = get_post_field( 'post_name', $post_id );
$actual = get_post_field( 'post_name', $post_id );
$this->assertSame( $expected, $actual );
}
+2 -1
View File
@@ -12,7 +12,8 @@ class Tests_Post_WpPost extends WP_UnitTestCase {
// Ensure that there is a post with ID 1.
if ( ! get_post( 1 ) ) {
$wpdb->insert(
$wpdb->posts, array(
$wpdb->posts,
array(
'ID' => 1,
'post_title' => 'Post 1',
)
+12 -6
View File
@@ -26,7 +26,8 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
array(
'title' => true,
'editor' => true,
), $post_type_supports
),
$post_type_supports
);
$this->assertEqualSets( array(), $post_type_supports_after );
}
@@ -34,7 +35,8 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
public function test_add_supports_custom() {
$post_type = 'cpt';
$post_type_object = new WP_Post_Type(
$post_type, array(
$post_type,
array(
'supports' => array(
'editor',
'comments',
@@ -54,7 +56,8 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
'editor' => true,
'comments' => true,
'revisions' => true,
), $post_type_supports
),
$post_type_supports
);
$this->assertEqualSets( array(), $post_type_supports_after );
}
@@ -67,7 +70,8 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
$post_type = 'cpt';
$post_type_object = new WP_Post_Type(
$post_type, array(
$post_type,
array(
'rewrite' => false,
'query_var' => 'foobar',
)
@@ -85,7 +89,8 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
$post_type = 'cpt';
$post_type_object = new WP_Post_Type(
$post_type, array(
$post_type,
array(
'public' => true,
'rewrite' => false,
'query_var' => 'foobar',
@@ -110,7 +115,8 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
$post_type = 'cpt';
$post_type_object = new WP_Post_Type(
$post_type, array(
$post_type,
array(
'public' => true,
'rewrite' => true,
)

Some files were not shown because too many files have changed in this diff Show More