summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/wp-admin/css/revisions.css30
-rw-r--r--src/wp-admin/includes/class-wp-filesystem-ftpext.php9
-rw-r--r--src/wp-admin/includes/revision.php72
-rw-r--r--src/wp-admin/includes/template.php3
-rw-r--r--src/wp-content/themes/twentyfourteen/inc/block-patterns.php2
-rw-r--r--src/wp-content/themes/twentyseventeen/inc/block-patterns.php60
-rw-r--r--src/wp-includes/class-wpdb.php8
-rw-r--r--src/wp-includes/comment-template.php4
-rw-r--r--src/wp-includes/css/wp-embed-template.css17
-rw-r--r--src/wp-includes/formatting.php9
-rw-r--r--src/wp-includes/ms-load.php8
-rw-r--r--src/wp-includes/plugin.php4
-rw-r--r--src/wp-includes/rest-api/class-wp-rest-response.php4
-rw-r--r--src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php8
-rw-r--r--src/wp-includes/taxonomy.php8
-rw-r--r--tests/e2e/specs/install.test.js2
-rw-r--r--tests/phpunit/tests/admin/includesPlugin.php21
-rw-r--r--tests/phpunit/tests/admin/includesTemplate.php14
-rw-r--r--tests/phpunit/tests/admin/wpPluginsListTable.php2
-rw-r--r--tests/phpunit/tests/ajax/wpAjaxSendAttachmentToEditor.php38
-rw-r--r--tests/phpunit/tests/ajax/wpCustomizeNavMenus.php37
-rw-r--r--tests/phpunit/tests/auth.php11
-rw-r--r--tests/phpunit/tests/comment.php20
-rw-r--r--tests/phpunit/tests/comment/commentsTemplate.php15
-rw-r--r--tests/phpunit/tests/comment/metaCache.php34
-rw-r--r--tests/phpunit/tests/comment/wpHandleCommentSubmission.php39
-rw-r--r--tests/phpunit/tests/customize/control.php18
-rw-r--r--tests/phpunit/tests/customize/custom-css-setting.php32
-rw-r--r--tests/phpunit/tests/customize/manager.php24
-rw-r--r--tests/phpunit/tests/customize/nav-menu-item-setting.php18
-rw-r--r--tests/phpunit/tests/customize/nav-menu-setting.php18
-rw-r--r--tests/phpunit/tests/customize/nav-menus.php54
-rw-r--r--tests/phpunit/tests/customize/panel.php25
-rw-r--r--tests/phpunit/tests/customize/selective-refresh-ajax.php26
-rw-r--r--tests/phpunit/tests/customize/setting.php32
-rw-r--r--tests/phpunit/tests/customize/widgets.php19
-rw-r--r--tests/phpunit/tests/db/charset.php8
-rw-r--r--tests/phpunit/tests/feed/atom.php2
-rw-r--r--tests/phpunit/tests/feed/rss2.php2
-rw-r--r--tests/phpunit/tests/file.php6
-rw-r--r--tests/phpunit/tests/formatting/escUrl.php6
-rw-r--r--tests/phpunit/tests/formatting/sanitizePost.php3
-rw-r--r--tests/phpunit/tests/formatting/wpSpecialchars.php2
-rw-r--r--tests/phpunit/tests/formatting/wpTrimExcerpt.php22
-rw-r--r--tests/phpunit/tests/functions.php2
-rw-r--r--tests/phpunit/tests/general/template.php38
-rw-r--r--tests/phpunit/tests/kses.php2
-rw-r--r--tests/phpunit/tests/l10n.php17
-rw-r--r--tests/phpunit/tests/l10n/getUserLocale.php53
-rw-r--r--tests/phpunit/tests/media.php6
-rw-r--r--tests/phpunit/tests/meta.php117
-rw-r--r--tests/phpunit/tests/oembed/controller.php24
-rw-r--r--tests/phpunit/tests/oembed/wpOembed.php26
-rw-r--r--tests/phpunit/tests/post.php3
-rw-r--r--tests/phpunit/tests/post/getPages.php71
-rw-r--r--tests/phpunit/tests/post/getPostsByAuthorSql.php36
-rw-r--r--tests/phpunit/tests/post/revisions.php2
-rw-r--r--tests/phpunit/tests/post/wpPostType.php2
-rw-r--r--tests/phpunit/tests/query.php3
-rw-r--r--tests/phpunit/tests/query/conditionals.php40
-rw-r--r--tests/phpunit/tests/query/postStatus.php6
-rw-r--r--tests/phpunit/tests/query/setupPostdata.php12
-rw-r--r--tests/phpunit/tests/rest-api/rest-comments-controller.php4
-rw-r--r--tests/phpunit/tests/rest-api/rest-posts-controller.php3
-rw-r--r--tests/phpunit/tests/rest-api/rest-server.php2
-rw-r--r--tests/phpunit/tests/rest-api/rest-users-controller.php6
-rw-r--r--tests/phpunit/tests/shortcode.php3
-rw-r--r--tests/phpunit/tests/taxonomy.php28
-rw-r--r--tests/phpunit/tests/term/cache.php2
-rw-r--r--tests/phpunit/tests/term/meta.php64
-rw-r--r--tests/phpunit/tests/term/wpGenerateTagCloud.php4
-rw-r--r--tests/phpunit/tests/term/wpGetObjectTerms.php5
-rw-r--r--tests/phpunit/tests/term/wpTaxonomy.php2
-rw-r--r--tests/phpunit/tests/theme.php11
-rw-r--r--tests/phpunit/tests/url.php17
-rw-r--r--tests/phpunit/tests/user.php28
-rw-r--r--tests/phpunit/tests/xmlrpc/wp/getComments.php2
-rw-r--r--tests/phpunit/tests/xmlrpc/wp/getPageList.php1
-rw-r--r--tests/phpunit/tests/xmlrpc/wp/getPages.php1
-rw-r--r--tests/phpunit/tests/xmlrpc/wp/getPosts.php2
-rw-r--r--tests/phpunit/tests/xmlrpc/wp/getTerms.php1
-rw-r--r--tests/phpunit/tests/xmlrpc/wp/getUsers.php1
-rw-r--r--tools/local-env/scripts/install.js2
83 files changed, 949 insertions, 496 deletions
diff --git a/src/wp-admin/css/revisions.css b/src/wp-admin/css/revisions.css
index 9d3a0b3a91..e16143cf48 100644
--- a/src/wp-admin/css/revisions.css
+++ b/src/wp-admin/css/revisions.css
@@ -572,6 +572,28 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
}
}
+@media screen and (max-width: 600px) {
+ .revisions-meta .author-card:not(.comparing-two-revisions .author-card) {
+ display: flex;
+ flex-direction: column;
+ width: fit-content;
+ gap: 16px;
+ }
+
+ .comparing-two-revisions .revisions-meta .restore-revision {
+ margin-top: 16px;
+ }
+
+ .revisions-controls {
+ padding-top: 0;
+ }
+
+ .revision-toggle-compare-mode {
+ position: relative;
+ padding: 1rem 0;
+ }
+}
+
@media screen and (max-width: 782px) {
#diff-next-revision,
#diff-previous-revision {
@@ -585,14 +607,18 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
.revisions-controls,
.comparing-two-revisions .revisions-controls {
- height: 170px;
+ height: fit-content;
}
.revisions-tooltip {
- bottom: 130px;
+ bottom: 155px;
z-index: 2;
}
+ .comparing-two-revisions .revisions-tooltip {
+ bottom: 200px;
+ }
+
.diff-meta {
overflow: hidden;
}
diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php
index 0294720ccd..7c721734c3 100644
--- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php
+++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php
@@ -601,9 +601,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
- * @param string $line
- * @return array {
- * Array of file information.
+ * Parses an individual entry from the FTP LIST command output.
+ *
+ * @param string $line A line from the directory listing.
+ * @return array|string {
+ * Array of file information. Empty string if the line could not be parsed.
*
* @type string $name Name of the file or directory.
* @type string $perms *nix representation of permissions.
@@ -658,7 +660,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY );
if ( $lucifer ) {
- // echo $line."\n";
$lcount = count( $lucifer );
if ( $lcount < 8 ) {
diff --git a/src/wp-admin/includes/revision.php b/src/wp-admin/includes/revision.php
index df7201e958..ec2460c0ca 100644
--- a/src/wp-admin/includes/revision.php
+++ b/src/wp-admin/includes/revision.php
@@ -407,41 +407,43 @@ function wp_print_revision_templates() {
<strong id="diff-title-to"><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
<# } #>
<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
- {{{ data.attributes.author.avatar }}}
- <div class="author-info" id="diff-title-author">
- <# if ( data.attributes.autosave ) { #>
- <span class="byline">
- <?php
- printf(
- /* translators: %s: User's display name. */
- __( 'Autosave by %s' ),
- '<span class="author-name">{{ data.attributes.author.name }}</span>'
- );
- ?>
- </span>
- <# } else if ( data.attributes.current ) { #>
- <span class="byline">
- <?php
- printf(
- /* translators: %s: User's display name. */
- __( 'Current Revision by %s' ),
- '<span class="author-name">{{ data.attributes.author.name }}</span>'
- );
- ?>
- </span>
- <# } else { #>
- <span class="byline">
- <?php
- printf(
- /* translators: %s: User's display name. */
- __( 'Revision by %s' ),
- '<span class="author-name">{{ data.attributes.author.name }}</span>'
- );
- ?>
- </span>
- <# } #>
- <span class="time-ago">{{ data.attributes.timeAgo }}</span>
- <span class="date">({{ data.attributes.dateShort }})</span>
+ <div>
+ {{{ data.attributes.author.avatar }}}
+ <div class="author-info" id="diff-title-author">
+ <# if ( data.attributes.autosave ) { #>
+ <span class="byline">
+ <?php
+ printf(
+ /* translators: %s: User's display name. */
+ __( 'Autosave by %s' ),
+ '<span class="author-name">{{ data.attributes.author.name }}</span>'
+ );
+ ?>
+ </span>
+ <# } else if ( data.attributes.current ) { #>
+ <span class="byline">
+ <?php
+ printf(
+ /* translators: %s: User's display name. */
+ __( 'Current Revision by %s' ),
+ '<span class="author-name">{{ data.attributes.author.name }}</span>'
+ );
+ ?>
+ </span>
+ <# } else { #>
+ <span class="byline">
+ <?php
+ printf(
+ /* translators: %s: User's display name. */
+ __( 'Revision by %s' ),
+ '<span class="author-name">{{ data.attributes.author.name }}</span>'
+ );
+ ?>
+ </span>
+ <# } #>
+ <span class="time-ago">{{ data.attributes.timeAgo }}</span>
+ <span class="date">({{ data.attributes.dateShort }})</span>
+ </div>
</div>
<# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
<input <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php
index 127027d8f5..16da3388ae 100644
--- a/src/wp-admin/includes/template.php
+++ b/src/wp-admin/includes/template.php
@@ -817,9 +817,6 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
$tab_index_attribute = " tabindex=\"$tab_index\"";
}
- // @todo Remove this?
- // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
-
$post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
$jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
$mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
diff --git a/src/wp-content/themes/twentyfourteen/inc/block-patterns.php b/src/wp-content/themes/twentyfourteen/inc/block-patterns.php
index ac40532cfb..b3bc376192 100644
--- a/src/wp-content/themes/twentyfourteen/inc/block-patterns.php
+++ b/src/wp-content/themes/twentyfourteen/inc/block-patterns.php
@@ -55,7 +55,7 @@ if ( function_exists( 'register_block_pattern' ) ) {
'title' => esc_html__( 'Summary', 'twentyfourteen' ),
'categories' => array( 'twentyfourteen' ),
'viewportWidth' => 1000,
- 'content' => '<!-- wp:group {"backgroundColor":"light-gray"} --><div class="wp-block-group has-light-gray-background-color has-background"><div class="wp-block-group__inner-container"><!-- wp:spacer {"height":50} --><div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div><!-- /wp:spacer --><!-- wp:heading {"level":3,"style":{"typography":{"lineHeight":"1.5"}}} --><h3 style="line-height:1.5">' . esc_html__( 'Traveling Nostalgia', 'twentyfourteen' ) . '</h3><!-- /wp:heading --><!-- wp:paragraph --><p><em>' . esc_html__( 'Here are some photos from my all-time favorite destinations.', 'twentyfourteen' ) . '</em></p><!-- /wp:paragraph --><!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/sunset.jpg" alt="' . esc_html__( 'Photo of a sunset', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Sunset', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/bridge.jpg" alt="' . esc_attr__( 'Photo of a bridge', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Bridge', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/street.jpg" alt="' . esc_attr__( 'Photo of a streetscape', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Streetscape', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/clouds.jpg" alt="' . esc_attr__( 'Photo of a cloudy mountain', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Clouds', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --></div><!-- /wp:column --></div><!-- /wp:columns --><!-- wp:buttons --><div class="wp-block-buttons"><!-- wp:button {"borderRadius":0,"backgroundColor":"dark-gray"} --><div class="wp-block-button"><a class="wp-block-button__link has-dark-gray-background-color has-background no-border-radius">' . esc_html__( 'Read More', 'twentyfourteen' ) . '</a></div><!-- /wp:button --></div><!-- /wp:buttons --><!-- wp:spacer {"height":50} --><div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div><!-- /wp:spacer --></div></div><!-- /wp:group -->',
+ 'content' => '<!-- wp:group {"backgroundColor":"light-gray"} --><div class="wp-block-group has-light-gray-background-color has-background"><div class="wp-block-group__inner-container"><!-- wp:spacer {"height":50} --><div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div><!-- /wp:spacer --><!-- wp:heading {"level":3,"style":{"typography":{"lineHeight":"1.5"}}} --><h3 style="line-height:1.5">' . esc_html__( 'Traveling Nostalgia', 'twentyfourteen' ) . '</h3><!-- /wp:heading --><!-- wp:paragraph --><p><em>' . esc_html__( 'Here are some photos from my all-time favorite destinations.', 'twentyfourteen' ) . '</em></p><!-- /wp:paragraph --><!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/sunset.jpg" alt="' . esc_attr__( 'Photo of a sunset', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Sunset', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/bridge.jpg" alt="' . esc_attr__( 'Photo of a bridge', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Bridge', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/street.jpg" alt="' . esc_attr__( 'Photo of a streetscape', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Streetscape', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --><!-- wp:image {"id":null,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/images/clouds.jpg" alt="' . esc_attr__( 'Photo of a cloudy mountain', 'twentyfourteen' ) . '"/><figcaption><span class="has-inline-color has-dark-gray-color">' . esc_html__( 'Clouds', 'twentyfourteen' ) . '</span></figcaption></figure><!-- /wp:image --></div><!-- /wp:column --></div><!-- /wp:columns --><!-- wp:buttons --><div class="wp-block-buttons"><!-- wp:button {"borderRadius":0,"backgroundColor":"dark-gray"} --><div class="wp-block-button"><a class="wp-block-button__link has-dark-gray-background-color has-background no-border-radius">' . esc_html__( 'Read More', 'twentyfourteen' ) . '</a></div><!-- /wp:button --></div><!-- /wp:buttons --><!-- wp:spacer {"height":50} --><div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div><!-- /wp:spacer --></div></div><!-- /wp:group -->',
)
);
diff --git a/src/wp-content/themes/twentyseventeen/inc/block-patterns.php b/src/wp-content/themes/twentyseventeen/inc/block-patterns.php
index f013aa9a54..e924ce7e29 100644
--- a/src/wp-content/themes/twentyseventeen/inc/block-patterns.php
+++ b/src/wp-content/themes/twentyseventeen/inc/block-patterns.php
@@ -14,7 +14,7 @@ if ( function_exists( 'register_block_pattern_category' ) ) {
register_block_pattern_category(
'twentyseventeen',
- array( 'label' => __( 'Twenty Seventeen', 'twentyseventeen' ) )
+ array( 'label' => esc_html__( 'Twenty Seventeen', 'twentyseventeen' ) )
);
}
@@ -25,15 +25,15 @@ if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'twentyseventeen/large-heading-with-button',
array(
- 'title' => __( 'Large Heading with Button', 'twentyseventeen' ),
+ 'title' => esc_html__( 'Large Heading with Button', 'twentyseventeen' ),
'categories' => array( 'twentyseventeen' ),
'content' => '<!-- wp:heading {"level":1,"textColor":"black","style":{"typography":{"fontSize":50}}} -->
- <h1 class="has-black-color has-text-color" style="font-size:50px">' . __( 'Attract Leads with Marketing Campaigns that Work', 'twentyseventeen' ) . '</h1>
+ <h1 class="has-black-color has-text-color" style="font-size:50px">' . esc_html__( 'Attract Leads with Marketing Campaigns that Work', 'twentyseventeen' ) . '</h1>
<!-- /wp:heading -->
<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"borderRadius":0,"className":"is-style-fill"} -->
- <div class="wp-block-button is-style-fill"><a class="wp-block-button__link no-border-radius">' . __( 'Our Services', 'twentyseventeen' ) . '</a></div>
+ <div class="wp-block-button is-style-fill"><a class="wp-block-button__link no-border-radius">' . esc_html__( 'Our Services', 'twentyseventeen' ) . '</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->',
)
@@ -42,7 +42,7 @@ if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'twentyseventeen/images-with-text-and-link',
array(
- 'title' => __( 'Images with Text and Link', 'twentyseventeen' ),
+ 'title' => esc_html__( 'Images with Text and Link', 'twentyseventeen' ),
'categories' => array( 'twentyseventeen' ),
'content' => '<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
@@ -51,16 +51,16 @@ if ( function_exists( 'register_block_pattern' ) ) {
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column">
<!-- wp:image {"className":"size-large"} -->
- <figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/stripes.jpg" alt="' . __( 'Black Stripes', 'twentyseventeen' ) . '"/></figure>
+ <figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/stripes.jpg" alt="' . esc_attr__( 'Black Stripes', 'twentyseventeen' ) . '"/></figure>
<!-- /wp:image -->
<!-- wp:heading {"textColor":"black","style":{"typography":{"fontSize":45}}} -->
- <h2 class="has-black-color has-text-color" style="font-size:45px">' . __( 'Branding', 'twentyseventeen' ) . '</h2>
+ <h2 class="has-black-color has-text-color" style="font-size:45px">' . esc_html__( 'Branding', 'twentyseventeen' ) . '</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"textColor":"black","style":{"typography":{"lineHeight":"1.8"}}} -->
- <p class="has-black-color has-text-color" style="line-height:1.8">' . __( 'Communicate your purpose and goals with a beautiful logo that encapsulates your business.', 'twentyseventeen' ) . '</p>
+ <p class="has-black-color has-text-color" style="line-height:1.8">' . esc_html__( 'Communicate your purpose and goals with a beautiful logo that encapsulates your business.', 'twentyseventeen' ) . '</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph {"style":{"typography":{"lineHeight":"3"}}} -->
- <p style="line-height:3"><a href="#"><strong>' . __( 'See Case Study', 'twentyseventeen' ) . ' →</strong></a></p>
+ <p style="line-height:3"><a href="#"><strong>' . esc_html__( 'See Case Study', 'twentyseventeen' ) . ' →</strong></a></p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->
<!-- wp:column -->
@@ -68,16 +68,16 @@ if ( function_exists( 'register_block_pattern' ) ) {
<div style="height:254px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:image {"className":"size-large"} -->
- <figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/white-border.jpg" alt="' . __( 'White border', 'twentyseventeen' ) . '"/></figure>
+ <figure class="wp-block-image size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/white-border.jpg" alt="' . esc_attr__( 'White border', 'twentyseventeen' ) . '"/></figure>
<!-- /wp:image -->
<!-- wp:heading {"textColor":"black","style":{"typography":{"fontSize":45}}} -->
- <h2 class="has-black-color has-text-color" style="font-size:45px">' . __( 'Web Design', 'twentyseventeen' ) . '</h2>
+ <h2 class="has-black-color has-text-color" style="font-size:45px">' . esc_html__( 'Web Design', 'twentyseventeen' ) . '</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"textColor":"black","style":{"typography":{"lineHeight":"1.8"}}} -->
- <p class="has-black-color has-text-color" style="line-height:1.8">' . __( 'Need a website? We&#39;ve got you covered. Our design team will create a stunning design to transform your brand.', 'twentyseventeen' ) . '</p>
+ <p class="has-black-color has-text-color" style="line-height:1.8">' . esc_html__( 'Need a website? We&#39;ve got you covered. Our design team will create a stunning design to transform your brand.', 'twentyseventeen' ) . '</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph {"style":{"typography":{"lineHeight":"3.0"}}} -->
- <p style="line-height:3.0"><a href="#"><strong>' . __( 'See Case Study', 'twentyseventeen' ) . ' →</strong></a></p>
+ <p style="line-height:3.0"><a href="#"><strong>' . esc_html__( 'See Case Study', 'twentyseventeen' ) . ' →</strong></a></p>
<!-- /wp:paragraph --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->',
@@ -87,7 +87,7 @@ if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'twentyseventeen/images-with-link',
array(
- 'title' => __( 'Images with Link', 'twentyseventeen' ),
+ 'title' => esc_html__( 'Images with Link', 'twentyseventeen' ),
'categories' => array( 'twentyseventeen' ),
'content' => '<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
@@ -97,13 +97,13 @@ if ( function_exists( 'register_block_pattern' ) ) {
<div class="wp-block-column"><!-- wp:group -->
<div class="wp-block-group"><div class="wp-block-group__inner-container">
<!-- wp:image {"align":"center","sizeSlug":"large","className":"is-style-default"} -->
- <div class="wp-block-image is-style-default"><figure class="aligncenter size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/stripes.jpg" alt="' . __( 'Black Stripes', 'twentyseventeen' ) . '"/></figure></div>
+ <div class="wp-block-image is-style-default"><figure class="aligncenter size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/stripes.jpg" alt="' . esc_attr__( 'Black Stripes', 'twentyseventeen' ) . '"/></figure></div>
<!-- /wp:image -->
<!-- wp:heading {"align":"left","textColor":"black","style":{"typography":{"fontSize":30}}} -->
- <h2 class="has-text-align-left has-black-color has-text-color" style="font-size:30px">' . __( 'Branding', 'twentyseventeen' ) . '</h2>
+ <h2 class="has-text-align-left has-black-color has-text-color" style="font-size:30px">' . esc_html__( 'Branding', 'twentyseventeen' ) . '</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"left"} -->
- <p class="has-text-align-left"><a href="#">' . __( 'See Case Study', 'twentyseventeen' ) . ' →</a></p>
+ <p class="has-text-align-left"><a href="#">' . esc_html__( 'See Case Study', 'twentyseventeen' ) . ' →</a></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:group --></div>
<!-- /wp:column -->
@@ -111,13 +111,13 @@ if ( function_exists( 'register_block_pattern' ) ) {
<div class="wp-block-column"><!-- wp:group -->
<div class="wp-block-group"><div class="wp-block-group__inner-container">
<!-- wp:image {"align":"center","sizeSlug":"large","className":"is-style-default"} -->
- <div class="wp-block-image is-style-default"><figure class="aligncenter size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/white-border.jpg" alt="' . __( 'White border', 'twentyseventeen' ) . '"/></figure></div>
+ <div class="wp-block-image is-style-default"><figure class="aligncenter size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/white-border.jpg" alt="' . esc_attr__( 'White border', 'twentyseventeen' ) . '"/></figure></div>
<!-- /wp:image -->
<!-- wp:heading {"align":"left","textColor":"black","style":{"typography":{"fontSize":30}}} -->
- <h2 class="has-text-align-left has-black-color has-text-color" style="font-size:30px">' . __( 'Design', 'twentyseventeen' ) . '</h2>
+ <h2 class="has-text-align-left has-black-color has-text-color" style="font-size:30px">' . esc_html__( 'Design', 'twentyseventeen' ) . '</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"left"} -->
- <p class="has-text-align-left"><a href="#">' . __( 'See Case Study', 'twentyseventeen' ) . ' →</a></p>
+ <p class="has-text-align-left"><a href="#">' . esc_html__( 'See Case Study', 'twentyseventeen' ) . ' →</a></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:group --></div>
<!-- /wp:column -->
@@ -125,13 +125,13 @@ if ( function_exists( 'register_block_pattern' ) ) {
<div class="wp-block-column"><!-- wp:group -->
<div class="wp-block-group"><div class="wp-block-group__inner-container">
<!-- wp:image {"align":"center","sizeSlug":"large","className":"is-style-default"} -->
- <div class="wp-block-image is-style-default"><figure class="aligncenter size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/direct-light.jpg" alt="' . __( 'Direct Light', 'twentyseventeen' ) . '"/></figure></div>
+ <div class="wp-block-image is-style-default"><figure class="aligncenter size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/direct-light.jpg" alt="' . esc_attr__( 'Direct Light', 'twentyseventeen' ) . '"/></figure></div>
<!-- /wp:image -->
<!-- wp:heading {"align":"left","textColor":"black","style":{"typography":{"fontSize":30}}} -->
- <h2 class="has-text-align-left has-black-color has-text-color" style="font-size:30px">' . __( 'Strategy', 'twentyseventeen' ) . '</h2>
+ <h2 class="has-text-align-left has-black-color has-text-color" style="font-size:30px">' . esc_html__( 'Strategy', 'twentyseventeen' ) . '</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"left"} -->
- <p class="has-text-align-left"><a href="#">' . __( 'See Case Study', 'twentyseventeen' ) . ' →</a></p>
+ <p class="has-text-align-left"><a href="#">' . esc_html__( 'See Case Study', 'twentyseventeen' ) . ' →</a></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:group --></div>
<!-- /wp:column --></div>
@@ -145,21 +145,21 @@ if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'twentyseventeen/services',
array(
- 'title' => __( 'Services', 'twentyseventeen' ),
+ 'title' => esc_html__( 'Services', 'twentyseventeen' ),
'categories' => array( 'twentyseventeen' ),
'content' => '<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:heading {"level":1,"style":{"typography":{"fontSize":50}}} -->
- <h1 style="font-size:50px">' . __( 'Our Services', 'twentyseventeen' ) . '</h1>
+ <h1 style="font-size:50px">' . esc_html__( 'Our Services', 'twentyseventeen' ) . '</h1>
<!-- /wp:heading -->
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column">
<!-- wp:paragraph {"style":{"typography":{"fontSize":21, "lineHeight":"2.5"}}} -->
- <p style="font-size:21px"><a href="#">' . __( 'Branding', 'twentyseventeen' ) . ' →</a><br><a href="#">' . __( 'Web Design', 'twentyseventeen' ) . ' →</a><br><a href="#">' . __( 'Web Development', 'twentyseventeen' ) . ' →</a></p>
+ <p style="font-size:21px"><a href="#">' . esc_html__( 'Branding', 'twentyseventeen' ) . ' →</a><br><a href="#">' . esc_html__( 'Web Design', 'twentyseventeen' ) . ' →</a><br><a href="#">' . esc_html__( 'Web Development', 'twentyseventeen' ) . ' →</a></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
@@ -167,7 +167,7 @@ if ( function_exists( 'register_block_pattern' ) ) {
<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:paragraph {"style":{"typography":{"fontSize":21, "lineHeight":"2.5"}}} -->
- <p style="font-size:21px"><a href="#">' . __( 'Content Strategy', 'twentyseventeen' ) . ' →</a><br><a href="#">' . __( 'Marketing &amp; SEO', 'twentyseventeen' ) . ' →</a><br><a href="#">' . __( 'Video Production', 'twentyseventeen' ) . ' →</a></p>
+ <p style="font-size:21px"><a href="#">' . esc_html__( 'Content Strategy', 'twentyseventeen' ) . ' →</a><br><a href="#">' . esc_html__( 'Marketing &amp; SEO', 'twentyseventeen' ) . ' →</a><br><a href="#">' . esc_html__( 'Video Production', 'twentyseventeen' ) . ' →</a></p>
<!-- /wp:paragraph --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
@@ -181,16 +181,16 @@ if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'twentyseventeen/contact-us',
array(
- 'title' => __( 'Contact Us', 'twentyseventeen' ),
+ 'title' => esc_html__( 'Contact Us', 'twentyseventeen' ),
'categories' => array( 'twentyseventeen' ),
'content' => '<!-- wp:cover {"customOverlayColor":"#93aab8","minHeight":700,"align":"center"} -->
<div class="wp-block-cover aligncenter has-background-dim" style="background-color:#93aab8;min-height:700px"><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"left","textColor":"white","style":{"typography":{"fontSize":50}}} -->
- <p class="has-text-align-left has-white-color has-text-color" style="font-size:50px">' . __( 'We are proud to serve outstanding clients.', 'twentyseventeen' ) . '</p>
+ <p class="has-text-align-left has-white-color has-text-color" style="font-size:50px">' . esc_html__( 'We are proud to serve outstanding clients.', 'twentyseventeen' ) . '</p>
<!-- /wp:paragraph -->
<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"borderRadius":0,"backgroundColor":"black","textColor":"white","className":"is-style-fill"} -->
- <div class="wp-block-button is-style-fill"><a class="wp-block-button__link has-white-color has-black-background-color has-text-color has-background no-border-radius">' . __( 'Contact us', 'twentyseventeen' ) . '</a></div>
+ <div class="wp-block-button is-style-fill"><a class="wp-block-button__link has-white-color has-black-background-color has-text-color has-background no-border-radius">' . esc_html__( 'Contact us', 'twentyseventeen' ) . '</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div></div>
<!-- /wp:cover -->',
diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php
index c6e6099c26..47f291fcb3 100644
--- a/src/wp-includes/class-wpdb.php
+++ b/src/wp-includes/class-wpdb.php
@@ -2866,8 +2866,12 @@ class wpdb {
* @return array {
* Array of values and formats keyed by their field names.
*
- * @type mixed $value The value to be formatted.
- * @type string $format The format to be mapped to the value.
+ * @type array ...$0 {
+ * Value and format for this field.
+ *
+ * @type mixed $value The value to be formatted.
+ * @type string $format The format to be mapped to the value.
+ * }
* }
*/
protected function process_field_formats( $data, $format ) {
diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php
index 9190cf6eff..cd41d4b200 100644
--- a/src/wp-includes/comment-template.php
+++ b/src/wp-includes/comment-template.php
@@ -2095,8 +2095,8 @@ function comment_id_fields( $post = null ) {
*
* Only affects users with JavaScript disabled.
*
- * @internal The $comment global must be present to allow template tags access to the current
- * comment. See https://core.trac.wordpress.org/changeset/36512.
+ * {@internal The $comment global must be present to allow template tags access to the current
+ * comment. See https://core.trac.wordpress.org/changeset/36512.}
*
* @since 2.7.0
* @since 6.2.0 Added the `$post` parameter.
diff --git a/src/wp-includes/css/wp-embed-template.css b/src/wp-includes/css/wp-embed-template.css
index b5a482b737..7b86fdd3d3 100644
--- a/src/wp-includes/css/wp-embed-template.css
+++ b/src/wp-includes/css/wp-embed-template.css
@@ -39,15 +39,15 @@ body {
}
.dashicons-admin-comments {
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E");
+ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%23646970%27%2F%3E%3C%2Fsvg%3E");
}
.wp-embed-comments a:hover .dashicons-admin-comments {
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E");
+ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%23135e96%27%2F%3E%3C%2Fsvg%3E");
}
.dashicons-share {
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E");
+ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%23646970%27%2F%3E%3C%2Fsvg%3E");
display: none;
}
@@ -56,7 +56,7 @@ body {
}
.wp-embed-share-dialog-open:hover .dashicons-share {
- background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E");
+ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%23135e96%27%2F%3E%3C%2Fsvg%3E");
}
.wp-embed {
@@ -65,7 +65,7 @@ body {
font-weight: 400;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
line-height: 1.5;
- color: #8c8f94;
+ color: #646970;
background: #fff;
border: 1px solid #dcdcde;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
@@ -75,7 +75,7 @@ body {
}
.wp-embed a {
- color: #8c8f94;
+ color: #646970;
text-decoration: none;
}
@@ -115,7 +115,8 @@ p.wp-embed-heading {
}
.wp-embed .wp-embed-more {
- color: #c3c4c7;
+ color: #2271b1;
+ text-decoration: underline;
}
.wp-embed-footer {
@@ -163,7 +164,7 @@ p.wp-embed-heading {
.wp-embed-meta a:hover {
text-decoration: none;
- color: #2271b1;
+ color: #135e96;
}
.wp-embed-comments a {
diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index 744eefeb82..4033571edf 100644
--- a/src/wp-includes/formatting.php
+++ b/src/wp-includes/formatting.php
@@ -2551,6 +2551,11 @@ function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.Namin
/**
* Balances tags of string using a modified stack.
*
+ * {@internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
+ * 1.1 Fixed handling of append/stack pop order of end text
+ * Added Cleaning Hooks
+ * 1.0 First Version}
+ *
* @since 2.0.4
* @since 5.3.0 Improve accuracy and add support for custom element tags.
*
@@ -2559,10 +2564,6 @@ function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.Namin
* @copyright November 4, 2001
* @version 1.1
* @todo Make better - change loop condition to $text in 1.2
- * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
- * 1.1 Fixed handling of append/stack pop order of end text
- * Added Cleaning Hooks
- * 1.0 First Version
*
* @param string $text Text to be balanced.
* @return string Balanced text.
diff --git a/src/wp-includes/ms-load.php b/src/wp-includes/ms-load.php
index 0708bc4dcd..b8d5228d09 100644
--- a/src/wp-includes/ms-load.php
+++ b/src/wp-includes/ms-load.php
@@ -129,9 +129,9 @@ function ms_site_check() {
/**
* Retrieves the closest matching network for a domain and path.
*
- * @since 3.9.0
+ * {@internal In 4.4.0, converted to a wrapper for WP_Network::get_by_path()}
*
- * @internal In 4.4.0, converted to a wrapper for WP_Network::get_by_path()
+ * @since 3.9.0
*
* @param string $domain Domain to check.
* @param string $path Path to check.
@@ -552,12 +552,12 @@ function wpmu_current_site() {
/**
* Retrieves an object containing information about the requested network.
*
+ * {@internal In 4.6.0, converted to use get_network()}
+ *
* @since 3.9.0
* @deprecated 4.7.0 Use get_network()
* @see get_network()
*
- * @internal In 4.6.0, converted to use get_network()
- *
* @param object|int $network The network's database row or ID.
* @return WP_Network|false Object containing network information if found, false if not.
*/
diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php
index bed67a9d96..5b4079b0bd 100644
--- a/src/wp-includes/plugin.php
+++ b/src/wp-includes/plugin.php
@@ -359,7 +359,7 @@ function remove_all_filters( $hook_name, $priority = false ) {
*
* @global string[] $wp_current_filter Stores the list of current filters with the current one last
*
- * @return string Hook name of the current filter.
+ * @return string|false Hook name of the current filter, false if no filter is running.
*/
function current_filter() {
global $wp_current_filter;
@@ -632,7 +632,7 @@ function remove_all_actions( $hook_name, $priority = false ) {
*
* @since 3.9.0
*
- * @return string Hook name of the current action.
+ * @return string|false Hook name of the current action, false if no action is running.
*/
function current_action() {
return current_filter();
diff --git a/src/wp-includes/rest-api/class-wp-rest-response.php b/src/wp-includes/rest-api/class-wp-rest-response.php
index c6ea11be83..0861d190d0 100644
--- a/src/wp-includes/rest-api/class-wp-rest-response.php
+++ b/src/wp-includes/rest-api/class-wp-rest-response.php
@@ -43,7 +43,7 @@ class WP_REST_Response extends WP_HTTP_Response {
/**
* Adds a link to the response.
*
- * @internal The $rel parameter is first, as this looks nicer when sending multiple.
+ * {@internal The $rel parameter is first, as this looks nicer when sending multiple.}
*
* @since 4.4.0
*
@@ -135,7 +135,7 @@ class WP_REST_Response extends WP_HTTP_Response {
/**
* Sets a single link header.
*
- * @internal The $rel parameter is first, as this looks nicer when sending multiple.
+ * {@internal The $rel parameter is first, as this looks nicer when sending multiple.}
*
* @since 4.4.0
*
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
index 4b960d6c6b..0474613b2e 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
@@ -662,11 +662,11 @@ abstract class WP_REST_Controller {
/**
* Sanitizes the slug value.
*
- * @since 4.7.0
- *
- * @internal We can't use sanitize_title() directly, as the second
+ * {@internal We can't use sanitize_title() directly, as the second
* parameter is the fallback title, which would end up being set to the
- * request object.
+ * request object.}
+ *
+ * @since 4.7.0
*
* @see https://github.com/WP-API/WP-API/issues/1585
*
diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
index 3e235b780f..e89855264d 100644
--- a/src/wp-includes/taxonomy.php
+++ b/src/wp-includes/taxonomy.php
@@ -1292,6 +1292,8 @@ function get_term_to_edit( $id, $taxonomy ) {
*
* Prior to 4.5.0, taxonomy was passed as the first parameter of `get_terms()`.
*
+ * {@internal The `$deprecated` parameter is parsed for backward compatibility only.}
+ *
* @since 2.3.0
* @since 4.2.0 Introduced 'name' and 'childless' parameters.
* @since 4.4.0 Introduced the ability to pass 'term_id' as an alias of 'id' for the `orderby` parameter.
@@ -1301,8 +1303,6 @@ function get_term_to_edit( $id, $taxonomy ) {
* Introduced 'meta_key' and 'meta_value' parameters. Introduced the ability to order results by metadata.
* @since 4.8.0 Introduced 'suppress_filter' parameter.
*
- * @internal The `$deprecated` parameter is parsed for backward compatibility only.
- *
* @param array|string $args Optional. Array or string of arguments. See WP_Term_Query::__construct()
* for information on accepted arguments. Default empty array.
* @param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
@@ -1927,11 +1927,11 @@ function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) {
*
* Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true).
*
+ * {@internal The `$deprecated` parameter is parsed for backward compatibility only.}
+ *
* @since 2.3.0
* @since 5.6.0 Changed the function signature so that the `$args` array can be provided as the first parameter.
*
- * @internal The `$deprecated` parameter is parsed for backward compatibility only.
- *
* @param array|string $args Optional. Array or string of arguments. See WP_Term_Query::__construct()
* for information on accepted arguments. Default empty array.
* @param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
diff --git a/tests/e2e/specs/install.test.js b/tests/e2e/specs/install.test.js
index 27bc56575e..cc237b8145 100644
--- a/tests/e2e/specs/install.test.js
+++ b/tests/e2e/specs/install.test.js
@@ -58,7 +58,7 @@ test.describe( 'WordPress installation process', () => {
await page.getByLabel( 'Password', { exact: true } ).fill( '' );
await page.getByLabel( 'Password', { exact: true } ).fill( 'password' );
await page.getByLabel( /Confirm use of weak password/ ).check()
- await page.getByLabel( 'Your Email' ).fill( 'test@test.com' );
+ await page.getByLabel( 'Your Email' ).fill( 'test@example.com' );
await page.getByRole( 'button', { name: 'Install WordPress' } ).click();
diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php
index e95697810d..4d47fb7db0 100644
--- a/tests/phpunit/tests/admin/includesPlugin.php
+++ b/tests/phpunit/tests/admin/includesPlugin.php
@@ -4,7 +4,16 @@
* @group admin
*/
class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
+
+ /**
+ * Admin user ID.
+ *
+ * @var int $admin_id
+ */
+ public static $admin_id;
+
public static function wpSetUpBeforeClass( $factory ) {
+ self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
self::_back_up_mu_plugins();
}
@@ -37,7 +46,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
public function test_menu_page_url() {
$current_user = get_current_user_id();
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
update_option( 'siteurl', 'http://example.com' );
// Add some pages.
@@ -81,7 +90,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
global $submenu;
global $menu;
$current_user = get_current_user_id();
- $admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $admin_user = self::$admin_id;
wp_set_current_user( $admin_user );
set_current_screen( 'dashboard' );
@@ -134,7 +143,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
$menu = array();
$current_user = get_current_user_id();
- $admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $admin_user = self::$admin_id;
wp_set_current_user( $admin_user );
set_current_screen( 'dashboard' );
@@ -283,7 +292,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
$submenu = array();
$menu = array();
$current_user = get_current_user_id();
- $admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $admin_user = self::$admin_id;
wp_set_current_user( $admin_user );
set_current_screen( 'dashboard' );
@@ -316,7 +325,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
$submenu = array();
$menu = array();
$current_user = get_current_user_id();
- $admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $admin_user = self::$admin_id;
wp_set_current_user( $admin_user );
set_current_screen( 'dashboard' );
@@ -344,7 +353,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
$submenu = array();
$menu = array();
$current_user = get_current_user_id();
- $admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $admin_user = self::$admin_id;
wp_set_current_user( $admin_user );
set_current_screen( 'dashboard' );
diff --git a/tests/phpunit/tests/admin/includesTemplate.php b/tests/phpunit/tests/admin/includesTemplate.php
index 66e3befd5f..909aff217a 100644
--- a/tests/phpunit/tests/admin/includesTemplate.php
+++ b/tests/phpunit/tests/admin/includesTemplate.php
@@ -3,6 +3,16 @@
* @group admin
*/
class Tests_Admin_IncludesTemplate extends WP_UnitTestCase {
+ /**
+ * Editor user ID.
+ *
+ * @var int $editor_id
+ */
+ public static $editor_id;
+
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+ }
/**
* @ticket 51137
@@ -64,7 +74,7 @@ class Tests_Admin_IncludesTemplate extends WP_UnitTestCase {
wp_set_object_terms( $post->ID, $term['term_id'], 'wptests_tax_1' );
// Test that get_inline_data() has `post_category` div containing the assigned term.
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
get_inline_data( $post );
$this->expectOutputRegex( '/<div class="post_category" id="wptests_tax_1_' . $post->ID . '">' . $term['term_id'] . '<\/div>/' );
}
@@ -90,7 +100,7 @@ class Tests_Admin_IncludesTemplate extends WP_UnitTestCase {
wp_set_object_terms( $post->ID, $term['term_id'], 'wptests_tax_1' );
// Test that get_inline_data() has `tags_input` div containing the assigned term.
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
get_inline_data( $post );
$this->expectOutputRegex( '/<div class="tags_input" id="wptests_tax_1_' . $post->ID . '">Test<\/div>/' );
}
diff --git a/tests/phpunit/tests/admin/wpPluginsListTable.php b/tests/phpunit/tests/admin/wpPluginsListTable.php
index af44861324..0b10881c46 100644
--- a/tests/phpunit/tests/admin/wpPluginsListTable.php
+++ b/tests/phpunit/tests/admin/wpPluginsListTable.php
@@ -57,7 +57,7 @@ class Tests_Admin_wpPluginsListTable extends WP_UnitTestCase {
'role' => 'administrator',
'user_login' => 'test_wp_plugins_list_table',
'user_pass' => 'password',
- 'user_email' => 'testadmin@test.com',
+ 'user_email' => 'testadmin@example.com',
)
);
self::$original_s = $s;
diff --git a/tests/phpunit/tests/ajax/wpAjaxSendAttachmentToEditor.php b/tests/phpunit/tests/ajax/wpAjaxSendAttachmentToEditor.php
index 29066ff287..351485afd1 100644
--- a/tests/phpunit/tests/ajax/wpAjaxSendAttachmentToEditor.php
+++ b/tests/phpunit/tests/ajax/wpAjaxSendAttachmentToEditor.php
@@ -14,6 +14,28 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
class Tests_Ajax_wpAjaxSendAttachmentToEditor extends WP_Ajax_UnitTestCase {
/**
+ * Shared user ID for the tests.
+ *
+ * @var int
+ */
+ public static $user_id = 0;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id = $factory->user->create(
+ array(
+ 'role' => 'administrator',
+ 'user_login' => 'user_36578_administrator',
+ 'user_email' => 'user_36578_administrator@example.com',
+ )
+ );
+ }
+
+ /**
* @ticket 36578
*
* @covers ::get_image_send_to_editor
@@ -105,13 +127,7 @@ class Tests_Ajax_wpAjaxSendAttachmentToEditor extends WP_Ajax_UnitTestCase {
public function test_wp_ajax_set_attachment_thumbnail_success() {
// Become an administrator.
$post = $_POST;
- $user_id = self::factory()->user->create(
- array(
- 'role' => 'administrator',
- 'user_login' => 'user_36578_administrator',
- 'user_email' => 'user_36578_administrator@example.com',
- )
- );
+ $user_id = self::$user_id;
wp_set_current_user( $user_id );
$_POST = array_merge( $_POST, $post );
@@ -151,13 +167,7 @@ class Tests_Ajax_wpAjaxSendAttachmentToEditor extends WP_Ajax_UnitTestCase {
public function test_wp_ajax_set_attachment_thumbnail_missing_nonce() {
// Become an administrator.
$post = $_POST;
- $user_id = self::factory()->user->create(
- array(
- 'role' => 'administrator',
- 'user_login' => 'user_36578_administrator',
- 'user_email' => 'user_36578_administrator@example.com',
- )
- );
+ $user_id = self::$user_id;
wp_set_current_user( $user_id );
$_POST = array_merge( $_POST, $post );
diff --git a/tests/phpunit/tests/ajax/wpCustomizeNavMenus.php b/tests/phpunit/tests/ajax/wpCustomizeNavMenus.php
index 1dfe5f684d..08353f6e65 100644
--- a/tests/phpunit/tests/ajax/wpCustomizeNavMenus.php
+++ b/tests/phpunit/tests/ajax/wpCustomizeNavMenus.php
@@ -38,6 +38,26 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
*/
public static $terms;
+
+ /**
+ * Admin user ID.
+ *
+ * @var int
+ */
+ public static $admin_user_id = 0;
+
+ /**
+ * User IDs keyed by role.
+ *
+ * @var int[]
+ */
+ public static $user_ids = array();
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory The factory.
+ */
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
// Make some post objects.
self::$posts = $factory->post->create_many( 5 );
@@ -45,6 +65,13 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
// Some terms too.
self::$terms = $factory->term->create_many( 5 );
+
+ // Create an admin user.
+ self::$admin_user_id = $factory->user->create( array( 'role' => 'administrator' ) );
+
+ foreach ( array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) {
+ self::$user_ids[ $role ] = $factory->user->create( array( 'role' => $role ) );
+ }
}
/**
@@ -53,7 +80,7 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_user_id );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
@@ -91,7 +118,7 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
$this->expectExceptionMessage( '-1' );
}
- wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) );
+ wp_set_current_user( self::$user_ids[ $role ] );
$_POST = array(
'action' => 'load-available-menu-items-customizer',
@@ -485,7 +512,7 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
$this->expectExceptionMessage( '-1' );
}
- wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) );
+ wp_set_current_user( self::$user_ids[ $role ] );
$_POST = array(
'action' => 'search-available-menu-items-customizer',
@@ -705,7 +732,7 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
$this->assertSame( 'bad_nonce', $response['data'] );
// Bad nonce.
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
+ wp_set_current_user( self::$user_ids['subscriber'] );
$_POST = wp_slash(
array(
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
@@ -718,7 +745,7 @@ class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
$this->assertSame( 'customize_not_allowed', $response['data'] );
// Missing params.
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_ids['administrator'] );
$_POST = wp_slash(
array(
'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ),
diff --git a/tests/phpunit/tests/auth.php b/tests/phpunit/tests/auth.php
index 3bdcb98b65..405a8526d0 100644
--- a/tests/phpunit/tests/auth.php
+++ b/tests/phpunit/tests/auth.php
@@ -1579,12 +1579,7 @@ class Tests_Auth extends WP_UnitTestCase {
* @covers ::wp_validate_application_password
*/
public function test_application_password_authentication() {
- $user_id = self::factory()->user->create(
- array(
- 'user_login' => 'http_auth_login',
- 'user_pass' => 'http_auth_pass', // Shouldn't be allowed for API login.
- )
- );
+ $user_id = self::$_user->ID;
// Create a new app-only password.
list( $user_app_password, $item ) = WP_Application_Passwords::create_new_application_password( $user_id, array( 'name' => 'phpunit' ) );
@@ -1594,8 +1589,8 @@ class Tests_Auth extends WP_UnitTestCase {
add_filter( 'wp_is_application_passwords_available', '__return_true' );
// Fake an HTTP Auth request with the regular account password first.
- $_SERVER['PHP_AUTH_USER'] = 'http_auth_login';
- $_SERVER['PHP_AUTH_PW'] = 'http_auth_pass';
+ $_SERVER['PHP_AUTH_USER'] = self::USER_LOGIN;
+ $_SERVER['PHP_AUTH_PW'] = self::USER_PASS;
$this->assertNull(
wp_validate_application_password( null ),
diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php
index 2af822f456..be36ba4059 100644
--- a/tests/phpunit/tests/comment.php
+++ b/tests/phpunit/tests/comment.php
@@ -21,7 +21,7 @@ class Tests_Comment extends WP_UnitTestCase {
'role' => 'author',
'user_login' => 'test_wp_user_get',
'user_pass' => 'password',
- 'user_email' => 'test@test.com',
+ 'user_email' => 'author@example.com',
)
);
@@ -95,7 +95,7 @@ class Tests_Comment extends WP_UnitTestCase {
'comment_post_ID' => self::$post_id,
'comment_author' => 'Author',
'comment_author_url' => 'http://example.localhost/',
- 'comment_author_email' => 'test@test.com',
+ 'comment_author_email' => 'author@example.com',
'user_id' => $admin_id_1,
'comment_content' => 'This is a comment',
)
@@ -108,7 +108,7 @@ class Tests_Comment extends WP_UnitTestCase {
'role' => 'administrator',
'user_login' => 'test_wp_admin_get',
'user_pass' => 'password',
- 'user_email' => 'testadmin@test.com',
+ 'user_email' => 'testadmin@example.com',
)
);
@@ -139,7 +139,7 @@ class Tests_Comment extends WP_UnitTestCase {
'comment_post_ID' => self::$post_id,
'comment_author' => 'Author',
'comment_author_url' => 'http://example.localhost/',
- 'comment_author_email' => 'test@test.com',
+ 'comment_author_email' => 'author@example.com',
'user_id' => self::$user_id,
'comment_content' => '<a href="http://example.localhost/something.html">click</a>',
)
@@ -152,7 +152,7 @@ class Tests_Comment extends WP_UnitTestCase {
'role' => 'administrator',
'user_login' => 'test_wp_admin_get',
'user_pass' => 'password',
- 'user_email' => 'testadmin@test.com',
+ 'user_email' => 'testadmin@example.com',
)
);
@@ -1445,10 +1445,10 @@ class Tests_Comment extends WP_UnitTestCase {
// Post authors possibly notified when a comment is approved on their post.
wp_set_comment_status( $comment, 'approve' );
- // Check to see if a notification email was sent to the post author `test@test.com`.
+ // Check to see if a notification email was sent to the post author `author@example.com`.
if ( isset( $GLOBALS['phpmailer']->mock_sent )
&& ! empty( $GLOBALS['phpmailer']->mock_sent )
- && 'test@test.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
+ && 'author@example.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
) {
$email_sent_when_comment_approved = true;
} else {
@@ -1467,10 +1467,10 @@ class Tests_Comment extends WP_UnitTestCase {
);
wp_new_comment( $data );
- // Check to see if a notification email was sent to the post author `test@test.com`.
+ // Check to see if a notification email was sent to the post author `author@example.com`.
if ( isset( $GLOBALS['phpmailer']->mock_sent ) &&
! empty( $GLOBALS['phpmailer']->mock_sent ) &&
- 'test@test.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] ) {
+ 'author@example.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] ) {
$email_sent_when_comment_added = true;
reset_phpmailer_instance();
} else {
@@ -1566,6 +1566,8 @@ class Tests_Comment extends WP_UnitTestCase {
$lengths = wp_get_comment_fields_max_lengths();
+ $this->assertNotEmpty( $lengths );
+
foreach ( $lengths as $field => $length ) {
$this->assertSame( $expected[ $field ], $length );
}
diff --git a/tests/phpunit/tests/comment/commentsTemplate.php b/tests/phpunit/tests/comment/commentsTemplate.php
index 7fa51f79f9..bc260545ad 100644
--- a/tests/phpunit/tests/comment/commentsTemplate.php
+++ b/tests/phpunit/tests/comment/commentsTemplate.php
@@ -566,6 +566,9 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
// Find the comment permalinks.
preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p1, $matches );
+ $this->assertNotEmpty( $matches );
+ $this->assertNotEmpty( $matches[1] );
+
// This is the main post page, so we don't expect any cpage param.
foreach ( $matches[1] as $m ) {
$this->assertStringNotContainsString( 'cpage', $m );
@@ -586,6 +589,9 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
// Find the comment permalinks.
preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p2, $matches );
+ $this->assertNotEmpty( $matches );
+ $this->assertNotEmpty( $matches[1] );
+
// They should all be on page 2.
foreach ( $matches[1] as $m ) {
$this->assertStringContainsString( 'cpage=2', $m );
@@ -659,6 +665,9 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
// Find the comment permalinks.
preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p0, $matches );
+ $this->assertNotEmpty( $matches );
+ $this->assertNotEmpty( $matches[1] );
+
foreach ( $matches[1] as $m ) {
$this->assertStringContainsString( 'cpage=3', $m );
}
@@ -678,6 +687,9 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
// Find the comment permalinks.
preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p2, $matches );
+ $this->assertNotEmpty( $matches );
+ $this->assertNotEmpty( $matches[1] );
+
// They should all be on page 2.
foreach ( $matches[1] as $m ) {
$this->assertStringContainsString( 'cpage=2', $m );
@@ -699,6 +711,9 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
// Find the comment permalinks.
preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p1, $matches );
+ $this->assertNotEmpty( $matches );
+ $this->assertNotEmpty( $matches[1] );
+
// They should all be on page 2.
foreach ( $matches[1] as $m ) {
$this->assertStringContainsString( 'cpage=1', $m );
diff --git a/tests/phpunit/tests/comment/metaCache.php b/tests/phpunit/tests/comment/metaCache.php
index 75695ccfa9..92337d9571 100644
--- a/tests/phpunit/tests/comment/metaCache.php
+++ b/tests/phpunit/tests/comment/metaCache.php
@@ -195,23 +195,23 @@ class Tests_Comment_MetaCache extends WP_UnitTestCase {
$this->go_to( get_permalink( $p ) );
- if ( have_posts() ) {
- while ( have_posts() ) {
- the_post();
-
- // Load comments with `comments_template()`.
- $cform = get_echo( 'comments_template' );
-
- // First request will hit the database.
- $num_queries = get_num_queries();
- get_comment_meta( $comment_ids[0], 'sauce' );
- $this->assertSame( 1, get_num_queries() - $num_queries );
-
- // Second and third requests should be in cache.
- get_comment_meta( $comment_ids[1], 'sauce' );
- get_comment_meta( $comment_ids[2], 'sauce' );
- $this->assertSame( 1, get_num_queries() - $num_queries );
- }
+ $this->assertTrue( have_posts() );
+
+ while ( have_posts() ) {
+ the_post();
+
+ // Load comments with `comments_template()`.
+ $cform = get_echo( 'comments_template' );
+
+ // First request will hit the database.
+ $num_queries = get_num_queries();
+ get_comment_meta( $comment_ids[0], 'sauce' );
+ $this->assertSame( 1, get_num_queries() - $num_queries );
+
+ // Second and third requests should be in cache.
+ get_comment_meta( $comment_ids[1], 'sauce' );
+ get_comment_meta( $comment_ids[2], 'sauce' );
+ $this->assertSame( 1, get_num_queries() - $num_queries );
}
}
diff --git a/tests/phpunit/tests/comment/wpHandleCommentSubmission.php b/tests/phpunit/tests/comment/wpHandleCommentSubmission.php
index 49d54e3da5..3f2ba84194 100644
--- a/tests/phpunit/tests/comment/wpHandleCommentSubmission.php
+++ b/tests/phpunit/tests/comment/wpHandleCommentSubmission.php
@@ -9,6 +9,7 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
protected static $post;
protected static $author_id;
+ protected static $author_id2;
protected static $editor_id;
protected $preprocess_comment_data = array();
@@ -22,6 +23,13 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
)
);
+ self::$author_id2 = $factory->user->create(
+ array(
+ 'role' => 'author',
+ 'user_url' => 'http://user.example.org',
+ )
+ );
+
self::$editor_id = $factory->user->create(
array(
'role' => 'editor',
@@ -223,11 +231,7 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
public function test_submitting_valid_comment_as_logged_in_user_succeeds() {
- $user = self::factory()->user->create_and_get(
- array(
- 'user_url' => 'http://user.example.org',
- )
- );
+ $user = get_user_by( 'id', self::$author_id2 );
wp_set_current_user( $user->ID );
@@ -314,11 +318,7 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
$error = 'comment_id_not_found';
- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
+ $user = get_user_by( 'id', self::$author_id2 );
wp_set_current_user( $user->ID );
@@ -343,11 +343,7 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
$error = 'comment_id_not_found';
- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
+ $user = get_user_by( 'id', self::$author_id2 );
wp_set_current_user( $user->ID );
@@ -834,12 +830,8 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
/**
* @ticket 36901
*/
- public function test_comments_flood_user_is_admin() {
- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'administrator',
- )
- );
+ public function test_comments_flood_user_can_moderate_comments() {
+ $user = get_user_by( 'id', self::$editor_id );
wp_set_current_user( $user->ID );
$data = array(
@@ -853,8 +845,9 @@ class Tests_Comment_wpHandleCommentSubmission extends WP_UnitTestCase {
$data['comment'] = 'Wow! I am quick!';
$second_comment = wp_handle_comment_submission( $data );
- $this->assertNotWPError( $second_comment );
- $this->assertSame( (string) self::$post->ID, $second_comment->comment_post_ID );
+ $this->assertTrue( current_user_can( 'moderate_comments' ), 'Test user should have the moderate_comments capability' );
+ $this->assertNotWPError( $second_comment, 'Second comment should not trigger comment flooding error.' );
+ $this->assertSame( (string) self::$post->ID, $second_comment->comment_post_ID, 'Second comment should be made against initial post.' );
}
/**
diff --git a/tests/phpunit/tests/customize/control.php b/tests/phpunit/tests/customize/control.php
index d472eacad9..ea3311e15c 100644
--- a/tests/phpunit/tests/customize/control.php
+++ b/tests/phpunit/tests/customize/control.php
@@ -18,11 +18,27 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
public $wp_customize;
/**
+ * Shared user ID for the tests.
+
+ * @var int
+ */
+ public static $user_id = 0;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory Factory.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
+ /**
* Set up.
*/
public function set_up() {
parent::set_up();
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_id );
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
$this->wp_customize = $GLOBALS['wp_customize'];
diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php
index 015b6308af..65cc3f717f 100644
--- a/tests/phpunit/tests/customize/custom-css-setting.php
+++ b/tests/phpunit/tests/customize/custom-css-setting.php
@@ -23,24 +23,40 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
public $setting;
/**
- * Set up the test case.
+ * The user ID to use for the tests.
*
- * @see WP_UnitTestCase_Base::set_up()
+ * @var int
*/
- public function set_up() {
- parent::set_up();
- require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
+ public static $user_id = 0;
- $user_id = self::factory()->user->create(
+ /**
+ * Set up the test case.
+ *
+ * @see WP_UnitTestCase::set_up()
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ // Create a user to use for the tests.
+ self::$user_id = $factory->user->create(
array(
'role' => 'administrator',
)
);
+
if ( is_multisite() ) {
- grant_super_admin( $user_id );
+ grant_super_admin( self::$user_id );
}
+ }
+
+ /**
+ * Set up the test case.
+ *
+ * @see WP_UnitTestCase_Base::set_up()
+ */
+ public function set_up() {
+ parent::set_up();
+ require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
- wp_set_current_user( $user_id );
+ wp_set_current_user( self::$user_id );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php
index 0f8ddb2d9b..21bdd85eeb 100644
--- a/tests/phpunit/tests/customize/manager.php
+++ b/tests/phpunit/tests/customize/manager.php
@@ -27,6 +27,13 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
protected static $admin_user_id;
/**
+ * Second admin user ID.
+ *
+ * @var int
+ */
+ protected static $other_admin_user_id;
+
+ /**
* Subscriber user ID.
*
* @var int
@@ -46,8 +53,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
* @param WP_UnitTest_Factory $factory Factory.
*/
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$subscriber_user_id = $factory->user->create( array( 'role' => 'subscriber' ) );
- self::$admin_user_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$subscriber_user_id = $factory->user->create( array( 'role' => 'subscriber' ) );
+ self::$admin_user_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$other_admin_user_id = $factory->user->create( array( 'role' => 'administrator' ) );
}
/**
@@ -153,7 +161,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
*/
public function test_constructor_deferred_changeset_uuid() {
wp_set_current_user( self::$admin_user_id );
- $other_admin_user_id = self::factory()->user->create( array( 'role' => 'admin' ) );
+ $other_admin_user_id = self::$other_admin_user_id;
$data = array(
'blogname' => array(
@@ -1254,7 +1262,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
*/
public function test_save_changeset_post_without_kses_corrupting_json() {
global $wp_customize;
- $lesser_admin_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $lesser_admin_user_id = self::$other_admin_user_id;
$uuid = wp_generate_uuid4();
$wp_customize = new WP_Customize_Manager(
@@ -1499,7 +1507,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
add_theme_support( 'custom-background' );
wp_set_current_user( self::$admin_user_id );
- $other_admin_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $other_admin_user_id = self::$other_admin_user_id;
$uuid = wp_generate_uuid4();
$wp_customize = $this->create_test_manager( $uuid );
@@ -1714,7 +1722,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
add_theme_support( 'custom-background' );
wp_set_current_user( self::$admin_user_id );
- $other_admin_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $other_admin_user_id = self::$other_admin_user_id;
$uuid = wp_generate_uuid4();
$wp_customize = $this->create_test_manager( $uuid );
@@ -1877,7 +1885,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$r = $wp_customize->save_changeset_post(
array(
'autosave' => true,
- 'user_id' => self::factory()->user->create( array( 'role' => 'administrator' ) ),
+ 'user_id' => self::$other_admin_user_id,
)
);
$this->assertSame( 'illegal_autosave_with_non_current_user', $r->get_error_code() );
@@ -3009,7 +3017,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
* @see WP_Customize_Manager::set_return_url()
*/
public function test_return_url() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) );
+ wp_set_current_user( self::$subscriber_user_id );
$this->assertSame( home_url( '/' ), $this->manager->get_return_url() );
wp_set_current_user( self::$admin_user_id );
diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php
index 22d4bc7de7..eb5aa46e89 100644
--- a/tests/phpunit/tests/customize/nav-menu-item-setting.php
+++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php
@@ -14,6 +14,22 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
public $wp_customize;
/**
+ * ID of the administrator user.
+ *
+ * @var int
+ */
+ public static $administrator_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
+ /**
* Set up a test case.
*
* @see WP_UnitTestCase_Base::set_up()
@@ -21,7 +37,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php
index 6d50c96ee0..1348c86395 100644
--- a/tests/phpunit/tests/customize/nav-menu-setting.php
+++ b/tests/phpunit/tests/customize/nav-menu-setting.php
@@ -15,6 +15,22 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
public $wp_customize;
/**
+ * ID of the administrator user.
+ *
+ * @var int
+ */
+ public static $administrator_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
+ /**
* Set up a test case.
*
* @see WP_UnitTestCase_Base::set_up()
@@ -22,7 +38,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php
index e731774693..e25418242a 100644
--- a/tests/phpunit/tests/customize/nav-menus.php
+++ b/tests/phpunit/tests/customize/nav-menus.php
@@ -15,6 +15,22 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
public $wp_customize;
/**
+ * ID of the administrator user.
+ *
+ * @var int
+ */
+ public static $administrator_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
+ /**
* Set up a test case.
*
* @see WP_UnitTestCase_Base::set_up()
@@ -22,7 +38,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
@@ -766,25 +782,27 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$this->assertStringContainsString( $expected, $template );
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
- if ( $post_types ) {
- foreach ( $post_types as $type ) {
- $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
- $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $type->labels->name ) . '#', $template );
- $this->assertStringContainsString( 'data-type="post_type"', $template );
- $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
- $this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template );
- }
+
+ $this->assertNotEmpty( $post_types );
+
+ foreach ( $post_types as $type ) {
+ $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
+ $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $type->labels->name ) . '#', $template );
+ $this->assertStringContainsString( 'data-type="post_type"', $template );
+ $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
+ $this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template );
}
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
- if ( $taxonomies ) {
- foreach ( $taxonomies as $tax ) {
- $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
- $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $tax->labels->name ) . '#', $template );
- $this->assertStringContainsString( 'data-type="taxonomy"', $template );
- $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
- $this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template );
- }
+
+ $this->assertNotEmpty( $taxonomies );
+
+ foreach ( $taxonomies as $tax ) {
+ $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
+ $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $tax->labels->name ) . '#', $template );
+ $this->assertStringContainsString( 'data-type="taxonomy"', $template );
+ $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
+ $this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template );
}
$this->assertStringContainsString( 'available-menu-items-custom_type', $template );
@@ -852,7 +870,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
$contributor_user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
$author_user_id = self::factory()->user->create( array( 'role' => 'author' ) );
- $administrator_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $administrator_user_id = self::$administrator_id;
$contributor_post_id = self::factory()->post->create(
array(
diff --git a/tests/phpunit/tests/customize/panel.php b/tests/phpunit/tests/customize/panel.php
index 40f198675a..bd191e65d7 100644
--- a/tests/phpunit/tests/customize/panel.php
+++ b/tests/phpunit/tests/customize/panel.php
@@ -8,6 +8,22 @@
class Tests_WP_Customize_Panel extends WP_UnitTestCase {
/**
+ * ID of the administrator user.
+ *
+ * @var int
+ */
+ public static $administrator_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
+ /**
* @var WP_Customize_Manager
*/
protected $manager;
@@ -131,8 +147,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::check_capabilities()
*/
public function test_check_capabilities() {
- $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
- wp_set_current_user( $user_id );
+ wp_set_current_user( self::$administrator_id );
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
$this->assertTrue( $panel->check_capabilities() );
@@ -157,7 +172,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::maybe_render()
*/
public function test_maybe_render() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
$panel = new WP_Customize_Panel( $this->manager, 'bar' );
$customize_render_panel_count = did_action( 'customize_render_panel' );
add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) );
@@ -182,7 +197,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::print_template()
*/
public function test_print_templates_standard() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
$panel = new WP_Customize_Panel( $this->manager, 'baz' );
ob_start();
@@ -200,7 +215,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
* @see WP_Customize_Panel::print_template()
*/
public function test_print_templates_custom() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
$panel = new Custom_Panel_Test( $this->manager, 'baz' );
ob_start();
diff --git a/tests/phpunit/tests/customize/selective-refresh-ajax.php b/tests/phpunit/tests/customize/selective-refresh-ajax.php
index 39d3d45a70..8d9305962b 100644
--- a/tests/phpunit/tests/customize/selective-refresh-ajax.php
+++ b/tests/phpunit/tests/customize/selective-refresh-ajax.php
@@ -29,6 +29,22 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
public $selective_refresh;
/**
+ * Shared user ID for the tests.
+ *
+ * @var int
+ */
+ public static $user_id = 0;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory Factory.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
+ /**
* Set up the test fixture.
*/
public function set_up() {
@@ -79,7 +95,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
$this->assertSame( 'expected_customize_preview', $output['data'] );
// Check expected_customize_preview.
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_id );
$_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->wp_customize->theme()->get_stylesheet() );
ob_start();
try {
@@ -121,7 +137,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
* Set the current user to be an admin, add the preview nonce, and set the query var.
*/
private function setup_valid_render_partials_request_environment() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_id );
$_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->wp_customize->theme()->get_stylesheet() );
$_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1';
$this->do_customize_boot_actions();
@@ -171,7 +187,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
*/
public function test_handle_render_partials_request_for_non_rendering_partial() {
$this->setup_valid_render_partials_request_environment();
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_id );
$this->wp_customize->add_setting( 'home' );
$this->wp_customize->selective_refresh->add_partial( 'foo', array( 'settings' => array( 'home' ) ) );
$context_data = array();
@@ -208,7 +224,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
*/
public function test_handle_rendering_disallowed_partial() {
$this->setup_valid_render_partials_request_environment();
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_id );
$this->wp_customize->add_setting(
'secret_message',
array(
@@ -244,7 +260,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
*/
public function test_handle_rendering_partial_with_missing_settings() {
$this->setup_valid_render_partials_request_environment();
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$user_id );
$this->wp_customize->selective_refresh->add_partial( 'bar', array( 'settings' => 'bar' ) );
$context_data = array();
diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php
index 62861a2726..8150a2f03d 100644
--- a/tests/phpunit/tests/customize/setting.php
+++ b/tests/phpunit/tests/customize/setting.php
@@ -17,6 +17,22 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
*/
public $undefined;
+ /**
+ * Shared admin user ID for the tests.
+ *
+ * @var int
+ */
+ public static $admin_id = 0;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory Factory.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
@@ -137,7 +153,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @see WP_Customize_Setting::value()
*/
public function test_preview_standard_types_non_multidimensional() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
// Try non-multidimensional settings.
@@ -216,7 +232,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @see WP_Customize_Setting::value()
*/
public function test_preview_standard_types_multidimensional() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
foreach ( $this->standard_type_configs as $type => $type_options ) {
@@ -362,7 +378,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @see WP_Customize_Setting::preview()
*/
public function test_preview_custom_type() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$type = 'custom_type';
$post_data_overrides = array(
"unset_{$type}_with_post_value" => "unset_{$type}_without_post_value\\o/",
@@ -513,7 +529,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->assertTrue( 0 === did_action( 'customize_save_foo' ) );
// Satisfy all requirements for save to happen.
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$this->assertNotFalse( $setting->save() );
$this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
$this->assertTrue( 1 === did_action( 'customize_save_foo' ) );
@@ -551,7 +567,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @ticket 31428
*/
public function test_is_current_blog_previewed() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$type = 'option';
$name = 'blogname';
$post_value = __FUNCTION__;
@@ -573,7 +589,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @group ms-required
*/
public function test_previewing_with_switch_to_blog() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$type = 'option';
$name = 'blogdescription';
$post_value = __FUNCTION__;
@@ -596,7 +612,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
*/
public function test_option_autoloading() {
global $wpdb;
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
$name = 'autoloaded1';
$setting = new WP_Customize_Setting(
@@ -743,7 +759,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @ticket 37294
*/
public function test_multidimensional_value_when_previewed() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$admin_id );
WP_Customize_Setting::reset_aggregated_multidimensionals();
$initial_value = 456;
diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php
index 77b1419440..bf298e1fff 100644
--- a/tests/phpunit/tests/customize/widgets.php
+++ b/tests/phpunit/tests/customize/widgets.php
@@ -20,6 +20,22 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
*/
protected $backup_registered_sidebars;
+ /**
+ * ID of the administrator user.
+ *
+ * @var int
+ */
+ public static $administrator_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ }
+
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
@@ -27,8 +43,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
add_theme_support( 'customize-selective-refresh-widgets' );
add_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) );
- $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
- wp_set_current_user( $user_id );
+ wp_set_current_user( self::$administrator_id );
update_option(
'widget_search',
diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php
index 26074e74b8..8b3fdb2f10 100644
--- a/tests/phpunit/tests/db/charset.php
+++ b/tests/phpunit/tests/db/charset.php
@@ -829,6 +829,8 @@ class Tests_DB_Charset extends WP_UnitTestCase {
self::$_wpdb->query( $drop );
self::$_wpdb->query( $create );
+ $this->assertNotEmpty( $expected_charset );
+
foreach ( $expected_charset as $column => $charset ) {
if ( self::$utf8_is_utf8mb3 && 'utf8' === $charset ) {
$charset = 'utf8mb3';
@@ -854,6 +856,8 @@ class Tests_DB_Charset extends WP_UnitTestCase {
self::$_wpdb->query( $create );
+ $this->assertNotEmpty( $columns );
+
$columns = array_keys( $columns );
foreach ( $columns as $column => $charset ) {
$this->assertFalse( self::$_wpdb->get_col_charset( $table, $column ) );
@@ -877,6 +881,8 @@ class Tests_DB_Charset extends WP_UnitTestCase {
self::$_wpdb->query( $create );
+ $this->assertNotEmpty( $columns );
+
$columns = array_keys( $columns );
foreach ( $columns as $column => $charset ) {
$this->assertFalse( self::$_wpdb->get_col_charset( $table, $column ) );
@@ -1070,6 +1076,8 @@ class Tests_DB_Charset extends WP_UnitTestCase {
)
);
+ $this->assertNotEmpty( $always_true );
+
foreach ( $always_true as $true_query ) {
$return = self::$_wpdb->check_safe_collation( $true_query );
$this->assertTrue(
diff --git a/tests/phpunit/tests/feed/atom.php b/tests/phpunit/tests/feed/atom.php
index dae234f51c..99d4e837af 100644
--- a/tests/phpunit/tests/feed/atom.php
+++ b/tests/phpunit/tests/feed/atom.php
@@ -279,6 +279,8 @@ class Tests_Feed_Atom extends WP_UnitTestCase {
$entries = xml_find( $xml, 'feed', 'entry' );
$entries = array_slice( $entries, 0, 1 );
+ $this->assertNotEmpty( $entries );
+
foreach ( $entries as $key => $entry ) {
$links = xml_find( $entries[ $key ]['child'], 'link' );
$i = 0;
diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php
index 4eea99965c..c4f8807d7b 100644
--- a/tests/phpunit/tests/feed/rss2.php
+++ b/tests/phpunit/tests/feed/rss2.php
@@ -289,6 +289,8 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase {
// Get all the rss -> channel -> item elements.
$items = xml_find( $xml, 'rss', 'channel', 'item' );
+ $this->assertNotEmpty( $items );
+
// Check each of the items against the known post data.
foreach ( $items as $key => $item ) {
// Get post for comparison.
diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php
index c99f1baffd..9a29e4e676 100644
--- a/tests/phpunit/tests/file.php
+++ b/tests/phpunit/tests/file.php
@@ -40,6 +40,8 @@ class Tests_File extends WP_UnitTestCase {
'AuthorURI' => 'http://binarybonsai.com/',
);
+ $this->assertNotEmpty( $actual );
+
foreach ( $actual as $header => $value ) {
$this->assertSame( $expected[ $header ], $value, $header );
}
@@ -64,6 +66,8 @@ class Tests_File extends WP_UnitTestCase {
'Author' => 'A Very Old Mac',
);
+ $this->assertNotEmpty( $actual );
+
foreach ( $actual as $header => $value ) {
$this->assertSame( $expected[ $header ], $value, $header );
}
@@ -84,6 +88,8 @@ class Tests_File extends WP_UnitTestCase {
'TemplateName' => 'Something',
);
+ $this->assertNotEmpty( $actual );
+
foreach ( $actual as $header => $value ) {
$this->assertSame( $expected[ $header ], $value, $header );
}
diff --git a/tests/phpunit/tests/formatting/escUrl.php b/tests/phpunit/tests/formatting/escUrl.php
index 769ecacfdc..6fdd582617 100644
--- a/tests/phpunit/tests/formatting/escUrl.php
+++ b/tests/phpunit/tests/formatting/escUrl.php
@@ -124,7 +124,11 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
)
);
- foreach ( wp_allowed_protocols() as $scheme ) {
+ $protocols = wp_allowed_protocols();
+
+ $this->assertNotEmpty( $protocols );
+
+ foreach ( $protocols as $scheme ) {
$this->assertSame( "{$scheme}://example.com", esc_url( "{$scheme}://example.com" ), $scheme );
$this->assertSame(
"{$scheme}://example.com",
diff --git a/tests/phpunit/tests/formatting/sanitizePost.php b/tests/phpunit/tests/formatting/sanitizePost.php
index 60ef8927aa..0366cf77c7 100644
--- a/tests/phpunit/tests/formatting/sanitizePost.php
+++ b/tests/phpunit/tests/formatting/sanitizePost.php
@@ -29,6 +29,9 @@ class Tests_Formatting_SanitizePost extends WP_UnitTestCase {
case 'string':
$this->assertIsString( $post->$field, "field $field" );
break;
+ default:
+ $this->fail( "Type $type is not handled by this test." );
+ break;
}
}
}
diff --git a/tests/phpunit/tests/formatting/wpSpecialchars.php b/tests/phpunit/tests/formatting/wpSpecialchars.php
index 890fb99c94..edbf29336c 100644
--- a/tests/phpunit/tests/formatting/wpSpecialchars.php
+++ b/tests/phpunit/tests/formatting/wpSpecialchars.php
@@ -17,6 +17,8 @@ class Tests_Formatting_wpSpecialchars extends WP_UnitTestCase {
public function test_allowed_entity_names() {
global $allowedentitynames;
+ $this->assertNotEmpty( $allowedentitynames );
+
// Allowed entities should be unchanged.
foreach ( $allowedentitynames as $ent ) {
if ( 'apos' === $ent ) {
diff --git a/tests/phpunit/tests/formatting/wpTrimExcerpt.php b/tests/phpunit/tests/formatting/wpTrimExcerpt.php
index 0f9c6e9cb7..688ba7731f 100644
--- a/tests/phpunit/tests/formatting/wpTrimExcerpt.php
+++ b/tests/phpunit/tests/formatting/wpTrimExcerpt.php
@@ -29,11 +29,12 @@ class Tests_Formatting_wpTrimExcerpt extends WP_UnitTestCase {
'post__in' => array( $post2 ),
)
);
- if ( $q->have_posts() ) {
- while ( $q->have_posts() ) {
- $q->the_post();
- $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
- }
+
+ $this->assertTrue( $q->have_posts() );
+
+ while ( $q->have_posts() ) {
+ $q->the_post();
+ $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
}
}
@@ -60,11 +61,12 @@ class Tests_Formatting_wpTrimExcerpt extends WP_UnitTestCase {
'post__in' => array( $post2 ),
)
);
- if ( $q->have_posts() ) {
- while ( $q->have_posts() ) {
- $q->the_post();
- $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
- }
+
+ $this->assertTrue( $q->have_posts() );
+
+ while ( $q->have_posts() ) {
+ $q->the_post();
+ $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
}
}
diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
index d2775393a6..2c458d968c 100644
--- a/tests/phpunit/tests/functions.php
+++ b/tests/phpunit/tests/functions.php
@@ -1145,6 +1145,8 @@ class Tests_Functions extends WP_UnitTestCase {
public function test_wp_ext2type() {
$extensions = wp_get_ext_types();
+ $this->assertNotEmpty( $extensions );
+
foreach ( $extensions as $type => $extension_list ) {
foreach ( $extension_list as $extension ) {
$this->assertSame( $type, wp_ext2type( $extension ) );
diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php
index 5aaf93be4e..d3b35a2c46 100644
--- a/tests/phpunit/tests/general/template.php
+++ b/tests/phpunit/tests/general/template.php
@@ -32,7 +32,29 @@ class Tests_General_Template extends WP_UnitTestCase {
*/
public static $home_page_id;
+ /**
+ * ID of the administrator user.
+ *
+ * @var int
+ */
+ public static $administrator_id;
+
+ /**
+ * ID of the author user.
+ *
+ * @var int
+ */
+ public static $author_id;
+
+ /**
+ * Set up the shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$author_id = $factory->user->create( array( 'role' => 'author' ) );
+
/*
* Declare theme support for custom logo.
*
@@ -212,7 +234,7 @@ class Tests_General_Template extends WP_UnitTestCase {
*/
public function test_customize_preview_wp_site_icon_empty() {
global $wp_customize;
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$wp_customize = new WP_Customize_Manager();
@@ -230,7 +252,7 @@ class Tests_General_Template extends WP_UnitTestCase {
*/
public function test_customize_preview_wp_site_icon_dirty() {
global $wp_customize;
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
+ wp_set_current_user( self::$administrator_id );
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$wp_customize = new WP_Customize_Manager();
@@ -763,16 +785,8 @@ class Tests_General_Template extends WP_UnitTestCase {
* @covers ::get_the_archive_title
*/
public function test_get_the_archive_title_is_correct_for_author_queries() {
- $user_with_posts = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
- $user_with_no_posts = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
+ $user_with_posts = get_user_by( 'id', self::$administrator_id );
+ $user_with_no_posts = get_user_by( 'id', self::$author_id );
self::factory()->post->create(
array(
diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php
index 16d447fd4c..256a3866ec 100644
--- a/tests/phpunit/tests/kses.php
+++ b/tests/phpunit/tests/kses.php
@@ -489,6 +489,8 @@ EOF;
$tags = wp_kses_allowed_html( 'post' );
+ $this->assertNotEmpty( $tags );
+
foreach ( $tags as $tag ) {
$this->assertTrue( $tag['class'] );
$this->assertTrue( $tag['dir'] );
diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php
index 7926a804da..2f7992c340 100644
--- a/tests/phpunit/tests/l10n.php
+++ b/tests/phpunit/tests/l10n.php
@@ -16,6 +16,17 @@ class Tests_L10n extends WP_UnitTestCase {
private $long_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
/**
+ * Editor user ID.
+ *
+ * @var int $editor_id
+ */
+ public static $editor_id;
+
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+ }
+
+ /**
* @ticket 35961
*
* @covers ::_n_noop
@@ -464,7 +475,7 @@ class Tests_L10n extends WP_UnitTestCase {
* and return a string instead of null, which would otherwise cause a PHP 8.1
* "passing null to non-nullable" deprecation notice.
*/
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
$args = array(
'post_content' => $this->long_text,
@@ -503,7 +514,7 @@ class Tests_L10n extends WP_UnitTestCase {
* and return a string instead of null, which would otherwise cause a PHP 8.1
* "passing null to non-nullable" deprecation notice.
*/
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
$args = array(
'post_content' => $this->long_text,
@@ -542,7 +553,7 @@ class Tests_L10n extends WP_UnitTestCase {
* and return a string instead of null, which would otherwise cause a PHP 8.1
* "passing null to non-nullable" deprecation notice.
*/
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
$args = array(
'post_content' => str_repeat( 'あ', 200 ),
diff --git a/tests/phpunit/tests/l10n/getUserLocale.php b/tests/phpunit/tests/l10n/getUserLocale.php
index 76492b3b70..e4eaf7a260 100644
--- a/tests/phpunit/tests/l10n/getUserLocale.php
+++ b/tests/phpunit/tests/l10n/getUserLocale.php
@@ -9,34 +9,61 @@
class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
protected $user_id;
- public function set_up() {
- parent::set_up();
+ /**
+ * ID of the administrator user with de_DE local.
+ *
+ * @var int
+ */
+ public static $administrator_de_de;
+
+ /**
+ * ID of the user with es_ES local.
+ *
+ * @var int
+ */
+ public static $user_es_es;
- $this->user_id = self::factory()->user->create(
+ /**
+ * Set up the shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$administrator_de_de = $factory->user->create(
array(
'role' => 'administrator',
'locale' => 'de_DE',
)
);
- wp_set_current_user( $this->user_id );
+ self::$user_es_es = self::factory()->user->create(
+ array(
+ 'locale' => 'es_ES',
+ )
+ );
+ }
+
+ public function set_up() {
+ parent::set_up();
+
+ wp_set_current_user( self::$administrator_de_de );
}
public function test_user_locale_property() {
set_current_screen( 'dashboard' );
$this->assertSame( 'de_DE', get_user_locale() );
- $this->assertSame( get_user_by( 'id', $this->user_id )->locale, get_user_locale() );
+ $this->assertSame( get_user_by( 'id', self::$administrator_de_de )->locale, get_user_locale() );
}
public function test_update_user_locale() {
set_current_screen( 'dashboard' );
- update_user_meta( $this->user_id, 'locale', 'fr_FR' );
+ update_user_meta( self::$administrator_de_de, 'locale', 'fr_FR' );
$this->assertSame( 'fr_FR', get_user_locale() );
}
public function test_returns_site_locale_if_empty() {
set_current_screen( 'dashboard' );
- update_user_meta( $this->user_id, 'locale', '' );
+ update_user_meta( self::$administrator_de_de, 'locale', '' );
$this->assertSame( get_locale(), get_user_locale() );
}
@@ -78,11 +105,7 @@ class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
}
public function test_user_id_argument_with_id() {
- $user_id = self::factory()->user->create(
- array(
- 'locale' => 'es_ES',
- )
- );
+ $user_id = self::$user_es_es;
$user_locale1 = get_user_locale( $user_id );
@@ -95,11 +118,7 @@ class Tests_L10n_GetUserLocale extends WP_UnitTestCase {
}
public function test_user_id_argument_with_wp_user_object() {
- $user_id = self::factory()->user->create(
- array(
- 'locale' => 'es_ES',
- )
- );
+ $user_id = self::$user_es_es;
$user = get_user_by( 'id', $user_id );
diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php
index d8aac58d2a..cb6b1f1345 100644
--- a/tests/phpunit/tests/media.php
+++ b/tests/phpunit/tests/media.php
@@ -1847,6 +1847,8 @@ EOF;
// Calculate a srcset array.
$sizes = explode( ', ', wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) );
+ $this->assertNotEmpty( $sizes );
+
// Test to confirm all sources in the array include the same edit hash.
foreach ( $sizes as $size ) {
$this->assertStringContainsString( $hash, $size );
@@ -3780,6 +3782,8 @@ EOF;
$query = $this->get_new_wp_query_for_published_post();
+ $this->assertTrue( have_posts() );
+
while ( have_posts() ) {
the_post();
@@ -3837,6 +3841,8 @@ EOF;
// Use the filter to alter the threshold for not lazy-loading to the first five elements.
$this->force_omit_loading_attr_threshold( 5 );
+ $this->assertTrue( have_posts() );
+
while ( have_posts() ) {
the_post();
diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php
index 857414190a..6431a15861 100644
--- a/tests/phpunit/tests/meta.php
+++ b/tests/phpunit/tests/meta.php
@@ -9,16 +9,15 @@ class Tests_Meta extends WP_UnitTestCase {
/**
* @var \WP_User
*/
- private $author;
+ private static $author;
- private $meta_id;
- private $delete_meta_id;
+ private static $meta_id;
+ private static $delete_meta_id;
- public function set_up() {
- parent::set_up();
- $this->author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
- $this->meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value' );
- $this->delete_meta_id = add_metadata( 'user', $this->author->ID, 'delete_meta_key', 'delete_meta_value' );
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$author = new WP_User( $factory->user->create( array( 'role' => 'author' ) ) );
+ self::$meta_id = add_metadata( 'user', self::$author->ID, 'meta_key', 'meta_value' );
+ self::$delete_meta_id = add_metadata( 'user', self::$author->ID, 'delete_meta_key', 'delete_meta_value' );
}
public function meta_sanitize_cb( $meta_value, $meta_key, $meta_type ) {
@@ -37,51 +36,51 @@ class Tests_Meta extends WP_UnitTestCase {
public function test_delete_metadata_by_mid() {
// Let's try and delete a non-existing ID, non existing meta.
$this->assertFalse( delete_metadata_by_mid( 'user', 0 ) );
- $this->assertFalse( delete_metadata_by_mid( 'non_existing_meta', $this->delete_meta_id ) );
+ $this->assertFalse( delete_metadata_by_mid( 'non_existing_meta', self::$delete_meta_id ) );
// Now let's delete the real meta data.
- $this->assertTrue( delete_metadata_by_mid( 'user', $this->delete_meta_id ) );
+ $this->assertTrue( delete_metadata_by_mid( 'user', self::$delete_meta_id ) );
// And make sure it's been deleted.
- $this->assertFalse( get_metadata_by_mid( 'user', $this->delete_meta_id ) );
+ $this->assertFalse( get_metadata_by_mid( 'user', self::$delete_meta_id ) );
// Make sure the caches are cleared.
- $this->assertFalse( (bool) get_user_meta( $this->author->ID, 'delete_meta_key' ) );
+ $this->assertFalse( (bool) get_user_meta( self::$author->ID, 'delete_meta_key' ) );
}
public function test_update_metadata_by_mid() {
// Setup.
- $meta = get_metadata_by_mid( 'user', $this->meta_id );
+ $meta = get_metadata_by_mid( 'user', self::$meta_id );
// Update the meta value.
- $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_new_value' ) );
- $meta = get_metadata_by_mid( 'user', $this->meta_id );
+ $this->assertTrue( update_metadata_by_mid( 'user', self::$meta_id, 'meta_new_value' ) );
+ $meta = get_metadata_by_mid( 'user', self::$meta_id );
$this->assertSame( 'meta_new_value', $meta->meta_value );
// Update the meta value.
- $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_new_value', 'meta_new_key' ) );
- $meta = get_metadata_by_mid( 'user', $this->meta_id );
+ $this->assertTrue( update_metadata_by_mid( 'user', self::$meta_id, 'meta_new_value', 'meta_new_key' ) );
+ $meta = get_metadata_by_mid( 'user', self::$meta_id );
$this->assertSame( 'meta_new_key', $meta->meta_key );
// Update the key and value.
- $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_value', 'meta_key' ) );
- $meta = get_metadata_by_mid( 'user', $this->meta_id );
+ $this->assertTrue( update_metadata_by_mid( 'user', self::$meta_id, 'meta_value', 'meta_key' ) );
+ $meta = get_metadata_by_mid( 'user', self::$meta_id );
$this->assertSame( 'meta_key', $meta->meta_key );
$this->assertSame( 'meta_value', $meta->meta_value );
// Update the value that has to be serialized.
- $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, array( 'first', 'second' ) ) );
- $meta = get_metadata_by_mid( 'user', $this->meta_id );
+ $this->assertTrue( update_metadata_by_mid( 'user', self::$meta_id, array( 'first', 'second' ) ) );
+ $meta = get_metadata_by_mid( 'user', self::$meta_id );
$this->assertSame( array( 'first', 'second' ), $meta->meta_value );
// Let's try some invalid meta data.
$this->assertFalse( update_metadata_by_mid( 'user', 0, 'meta_value' ) );
- $this->assertFalse( update_metadata_by_mid( 'user', $this->meta_id, 'meta_value', array( 'invalid', 'key' ) ) );
+ $this->assertFalse( update_metadata_by_mid( 'user', self::$meta_id, 'meta_value', array( 'invalid', 'key' ) ) );
// Let's see if caches get cleared after updates.
- $meta = get_metadata_by_mid( 'user', $this->meta_id );
+ $meta = get_metadata_by_mid( 'user', self::$meta_id );
$first = get_user_meta( $meta->user_id, $meta->meta_key );
- $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'other_meta_value' ) );
+ $this->assertTrue( update_metadata_by_mid( 'user', self::$meta_id, 'other_meta_value' ) );
$second = get_user_meta( $meta->user_id, $meta->meta_key );
$this->assertFalse( $first === $second );
}
@@ -107,14 +106,16 @@ class Tests_Meta extends WP_UnitTestCase {
$found = $this->updated_mids;
$this->updated_mids = array();
+ $this->assertNotEmpty( $found );
+
foreach ( $found as $action => $mids ) {
$this->assertCount( 2, $mids );
}
}
public function test_metadata_exists() {
- $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'foobarbaz' ) );
- $this->assertTrue( metadata_exists( 'user', $this->author->ID, 'meta_key' ) );
+ $this->assertFalse( metadata_exists( 'user', self::$author->ID, 'foobarbaz' ) );
+ $this->assertTrue( metadata_exists( 'user', self::$author->ID, 'meta_key' ) );
$this->assertFalse( metadata_exists( 'user', 1234567890, 'foobarbaz' ) );
$this->assertFalse( metadata_exists( 'user', 1234567890, 'meta_key' ) );
}
@@ -125,7 +126,7 @@ class Tests_Meta extends WP_UnitTestCase {
public function test_metadata_exists_with_filter() {
// Let's see if it returns the correct value when adding a filter.
add_filter( 'get_user_metadata', '__return_zero' );
- $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); // Existing meta key.
+ $this->assertFalse( metadata_exists( 'user', self::$author->ID, 'meta_key' ) ); // Existing meta key.
$this->assertFalse( metadata_exists( 'user', 1234567890, 'meta_key' ) );
remove_filter( 'get_user_metadata', '__return_zero' );
}
@@ -148,7 +149,7 @@ class Tests_Meta extends WP_UnitTestCase {
$this->assertCount( 1, $u );
// User found is not locally defined author (it's the admin).
- $this->assertNotEquals( $this->author->user_login, $u[0]->user_login );
+ $this->assertNotEquals( self::$author->user_login, $u[0]->user_login );
// Test EXISTS and NOT EXISTS together, no users should be found.
$this->assertCount(
@@ -183,7 +184,7 @@ class Tests_Meta extends WP_UnitTestCase {
)
);
- delete_metadata( 'user', $this->author->ID, 'meta_key' );
+ delete_metadata( 'user', self::$author->ID, 'meta_key' );
$this->assertCount(
2,
@@ -206,28 +207,28 @@ class Tests_Meta extends WP_UnitTestCase {
$expected = 'Testsingleslash';
$value2 = 'Test\\\\doubleslash';
$expected2 = 'Test\\doubleslash';
- $this->assertFalse( metadata_exists( 'user', $this->author->ID, $key ) );
- $this->assertFalse( delete_metadata( 'user', $this->author->ID, $key ) );
- $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertIsInt( add_metadata( 'user', $this->author->ID, $key, $value ) );
- $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) );
- $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertIsInt( update_metadata( 'user', $this->author->ID, $key, $value ) );
- $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertTrue( update_metadata( 'user', $this->author->ID, $key, 'blah' ) );
- $this->assertSame( 'blah', get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) );
- $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertFalse( metadata_exists( 'user', $this->author->ID, $key ) );
+ $this->assertFalse( metadata_exists( 'user', self::$author->ID, $key ) );
+ $this->assertFalse( delete_metadata( 'user', self::$author->ID, $key ) );
+ $this->assertSame( '', get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertIsInt( add_metadata( 'user', self::$author->ID, $key, $value ) );
+ $this->assertSame( $expected, get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertTrue( delete_metadata( 'user', self::$author->ID, $key ) );
+ $this->assertSame( '', get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertIsInt( update_metadata( 'user', self::$author->ID, $key, $value ) );
+ $this->assertSame( $expected, get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertTrue( update_metadata( 'user', self::$author->ID, $key, 'blah' ) );
+ $this->assertSame( 'blah', get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertTrue( delete_metadata( 'user', self::$author->ID, $key ) );
+ $this->assertSame( '', get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertFalse( metadata_exists( 'user', self::$author->ID, $key ) );
// Test overslashing.
- $this->assertIsInt( add_metadata( 'user', $this->author->ID, $key, $value2 ) );
- $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) );
- $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) );
- $this->assertIsInt( update_metadata( 'user', $this->author->ID, $key, $value2 ) );
- $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) );
+ $this->assertIsInt( add_metadata( 'user', self::$author->ID, $key, $value2 ) );
+ $this->assertSame( $expected2, get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertTrue( delete_metadata( 'user', self::$author->ID, $key ) );
+ $this->assertSame( '', get_metadata( 'user', self::$author->ID, $key, true ) );
+ $this->assertIsInt( update_metadata( 'user', self::$author->ID, $key, $value2 ) );
+ $this->assertSame( $expected2, get_metadata( 'user', self::$author->ID, $key, true ) );
}
/**
@@ -344,7 +345,7 @@ class Tests_Meta extends WP_UnitTestCase {
* @ticket 37746
*/
public function test_negative_meta_id() {
- $negative_mid = $this->meta_id * -1;
+ $negative_mid = self::$meta_id * -1;
$this->assertLessThan( 0, $negative_mid );
$this->assertFalse( get_metadata_by_mid( 'user', $negative_mid ) );
@@ -356,7 +357,7 @@ class Tests_Meta extends WP_UnitTestCase {
* @ticket 37746
*/
public function test_floating_meta_id() {
- $floating_mid = $this->meta_id + 0.1337;
+ $floating_mid = self::$meta_id + 0.1337;
$this->assertTrue( floor( $floating_mid ) !== $floating_mid );
$this->assertFalse( get_metadata_by_mid( 'user', $floating_mid ) );
@@ -368,7 +369,7 @@ class Tests_Meta extends WP_UnitTestCase {
* @ticket 37746
*/
public function test_string_point_zero_meta_id() {
- $meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value_2' );
+ $meta_id = add_metadata( 'user', self::$author->ID, 'meta_key', 'meta_value_2' );
$string_mid = "{$meta_id}.0";
@@ -385,8 +386,8 @@ class Tests_Meta extends WP_UnitTestCase {
public function test_get_metadata_with_empty_key_array_value() {
$data = array( 1, 2 );
$value = serialize( $data );
- add_metadata( 'user', $this->author->ID, 'foo', $data );
- $found = get_metadata( 'user', $this->author->ID );
+ add_metadata( 'user', self::$author->ID, 'foo', $data );
+ $found = get_metadata( 'user', self::$author->ID );
$this->assertSame( array( $value ), $found['foo'] );
}
@@ -398,8 +399,8 @@ class Tests_Meta extends WP_UnitTestCase {
$data = new stdClass();
$data->foo = 'bar';
$value = serialize( $data );
- add_metadata( 'user', $this->author->ID, 'foo', $data );
- $found = get_metadata( 'user', $this->author->ID );
+ add_metadata( 'user', self::$author->ID, 'foo', $data );
+ $found = get_metadata( 'user', self::$author->ID );
$this->assertSame( array( $value ), $found['foo'] );
}
@@ -413,8 +414,8 @@ class Tests_Meta extends WP_UnitTestCase {
array( 3, 4 ),
);
$value = serialize( $data );
- add_metadata( 'user', $this->author->ID, 'foo', $data );
- $found = get_metadata( 'user', $this->author->ID );
+ add_metadata( 'user', self::$author->ID, 'foo', $data );
+ $found = get_metadata( 'user', self::$author->ID );
$this->assertSame( array( $value ), $found['foo'] );
}
diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php
index 9011b789bb..aa0275c4c8 100644
--- a/tests/phpunit/tests/oembed/controller.php
+++ b/tests/phpunit/tests/oembed/controller.php
@@ -304,11 +304,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
public function test_request_json() {
- $user = self::factory()->user->create_and_get(
- array(
- 'display_name' => 'John Doe',
- )
- );
+ $user = get_user_by( 'id', self::$subscriber );
$post = self::factory()->post->create_and_get(
array(
'post_author' => $user->ID,
@@ -391,11 +387,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
public function test_request_xml() {
- $user = self::factory()->user->create_and_get(
- array(
- 'display_name' => 'John Doe',
- )
- );
+ $user = get_user_by( 'id', self::$subscriber );
$post = self::factory()->post->create_and_get(
array(
'post_author' => $user->ID,
@@ -461,11 +453,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
}
public function test_rest_pre_serve_request() {
- $user = self::factory()->user->create_and_get(
- array(
- 'display_name' => 'John Doe',
- )
- );
+ $user = get_user_by( 'id', self::$subscriber );
$post = self::factory()->post->create_and_get(
array(
'post_author' => $user->ID,
@@ -677,11 +665,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase {
public function test_proxy_with_internal_url() {
wp_set_current_user( self::$editor );
- $user = self::factory()->user->create_and_get(
- array(
- 'display_name' => 'John Doe',
- )
- );
+ $user = get_user_by( 'id', self::$subscriber );
$post = self::factory()->post->create_and_get(
array(
'post_author' => $user->ID,
diff --git a/tests/phpunit/tests/oembed/wpOembed.php b/tests/phpunit/tests/oembed/wpOembed.php
index 051a7efe3d..76d733dbce 100644
--- a/tests/phpunit/tests/oembed/wpOembed.php
+++ b/tests/phpunit/tests/oembed/wpOembed.php
@@ -11,6 +11,22 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
public $pre_oembed_result_filtered = false;
+ /**
+ * ID of the user.
+ *
+ * @var int
+ */
+ public static $user_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id = $factory->user->create();
+ }
+
public function set_up() {
parent::set_up();
@@ -96,7 +112,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
* @group ms-required
*/
public function test_wp_filter_pre_oembed_result_multisite_sub_samesub() {
- $user_id = self::factory()->user->create();
+ $user_id = self::$user_id;
$blog_id = self::factory()->blog->create(
array(
@@ -125,7 +141,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
* @group ms-required
*/
public function test_wp_filter_pre_oembed_result_multisite_sub_othersub() {
- $user_id = self::factory()->user->create();
+ $user_id = self::$user_id;
$blog_id = self::factory()->blog->create(
array(
@@ -164,7 +180,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
public function test_wp_filter_pre_oembed_result_multisite_sub_main() {
$post_id = self::factory()->post->create();
$permalink = get_permalink( $post_id );
- $user_id = self::factory()->user->create();
+ $user_id = self::$user_id;
$blog_id = self::factory()->blog->create(
array(
'user_id' => $user_id,
@@ -189,7 +205,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
* @group ms-required
*/
public function test_wp_filter_pre_oembed_result_multisite_preserves_switched_state() {
- $user_id = self::factory()->user->create();
+ $user_id = self::$user_id;
$blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) );
switch_to_blog( $blog_id );
@@ -220,7 +236,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
public function test_wp_filter_pre_oembed_result_multisite_restores_state_if_no_post_is_found() {
$current_blog_id = get_current_blog_id();
- $user_id = self::factory()->user->create();
+ $user_id = self::$user_id;
$blog_id = self::factory()->blog->create(
array(
'user_id' => $user_id,
diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php
index 6e0207add2..36c337939e 100644
--- a/tests/phpunit/tests/post.php
+++ b/tests/phpunit/tests/post.php
@@ -269,6 +269,9 @@ class Tests_Post extends WP_UnitTestCase {
$terms = get_terms( $tax );
$term = reset( $terms );
+ $this->assertNotEmpty( $matches );
+ $this->assertNotEmpty( $matches[1] );
+
foreach ( $matches[1] as $url ) {
$this->assertStringContainsString( 'tag_ID=' . $term->term_id, $url );
$this->assertStringContainsString( 'post_type=new_post_type', $url );
diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php
index 76735bae86..dad85ddc69 100644
--- a/tests/phpunit/tests/post/getPages.php
+++ b/tests/phpunit/tests/post/getPages.php
@@ -6,6 +6,42 @@
* @covers ::get_pages
*/
class Tests_Post_GetPages extends WP_UnitTestCase {
+
+ /**
+ * ID of the first author.
+ *
+ * @var int
+ */
+ public static $author_id_1;
+
+ /**
+ * ID of the second author.
+ *
+ * @var int
+ */
+ public static $author_id_2;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$author_id_1 = $factory->user->create(
+ array(
+ 'user_login' => 'author1',
+ 'role' => 'author',
+ )
+ );
+
+ self::$author_id_2 = $factory->user->create(
+ array(
+ 'user_login' => 'author2',
+ 'role' => 'author',
+ )
+ );
+ }
+
/**
* @ticket 23167
*/
@@ -963,12 +999,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase {
* @ticket 12821
*/
public function test_get_pages_author() {
- $author_1 = self::factory()->user->create(
- array(
- 'user_login' => 'author1',
- 'role' => 'author',
- )
- );
+ $author_1 = self::$author_id_1;
$posts = self::factory()->post->create_many(
2,
array(
@@ -989,12 +1020,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase {
* @ticket 12821
*/
public function test_get_pages_multiple_authors() {
- $author_1 = self::factory()->user->create(
- array(
- 'user_login' => 'author1',
- 'role' => 'author',
- )
- );
+ $author_1 = self::$author_id_1;
$post_1 = self::factory()->post->create(
array(
'post_title' => 'Page 1',
@@ -1004,12 +1030,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase {
)
);
- $author_2 = self::factory()->user->create(
- array(
- 'user_login' => 'author2',
- 'role' => 'author',
- )
- );
+ $author_2 = self::$author_id_2;
$post_2 = self::factory()->post->create(
array(
'post_title' => 'Page 2',
@@ -1031,12 +1052,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase {
* @ticket 12821
*/
public function test_get_pages_multiple_authors_by_user_login() {
- $author_1 = self::factory()->user->create(
- array(
- 'user_login' => 'author1',
- 'role' => 'author',
- )
- );
+ $author_1 = self::$author_id_1;
$post_1 = self::factory()->post->create(
array(
'post_title' => 'Page 1',
@@ -1046,12 +1062,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase {
)
);
- $author_2 = self::factory()->user->create(
- array(
- 'user_login' => 'author2',
- 'role' => 'author',
- )
- );
+ $author_2 = self::$author_id_2;
$post_2 = self::factory()->post->create(
array(
'post_title' => 'Page 2',
diff --git a/tests/phpunit/tests/post/getPostsByAuthorSql.php b/tests/phpunit/tests/post/getPostsByAuthorSql.php
index fc6f1e8526..e2657a3fdf 100644
--- a/tests/phpunit/tests/post/getPostsByAuthorSql.php
+++ b/tests/phpunit/tests/post/getPostsByAuthorSql.php
@@ -5,6 +5,30 @@
*/
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
+ /**
+ * ID of the first user.
+ *
+ * @var int
+ */
+ public static $user_id_1;
+
+ /**
+ * ID of the second user.
+ *
+ * @var int
+ */
+ public static $user_id_2;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id_1 = $factory->user->create();
+ self::$user_id_2 = $factory->user->create();
+ }
+
public function test_post_type_post() {
$maybe_string = get_posts_by_author_sql( 'post' );
$this->assertStringContainsString( "post_type = 'post'", $maybe_string );
@@ -59,7 +83,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user() {
$current_user = get_current_user_id();
- $u = self::factory()->user->create();
+ $u = self::$user_id_1;
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, $u, true );
@@ -70,7 +94,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_should_default_to_false() {
$current_user = get_current_user_id();
- $u = self::factory()->user->create();
+ $u = self::$user_id_1;
wp_set_current_user( $u );
$this->assertSame( get_posts_by_author_sql( 'post', true, $u, false ), get_posts_by_author_sql( 'post', true, $u ) );
@@ -80,7 +104,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author() {
$current_user = get_current_user_id();
- $u = self::factory()->user->create();
+ $u = self::$user_id_1;
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, $u, false );
@@ -91,8 +115,8 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author() {
$current_user = get_current_user_id();
- $u1 = self::factory()->user->create();
- $u2 = self::factory()->user->create();
+ $u1 = self::$user_id_1;
+ $u2 = self::$user_id_2;
wp_set_current_user( $u1 );
$maybe_string = get_posts_by_author_sql( 'post', true, $u2, false );
@@ -103,7 +127,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided() {
$current_user = get_current_user_id();
- $u = self::factory()->user->create();
+ $u = self::$user_id_1;
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, $u, false );
diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php
index a4e45aefcf..699c10d29b 100644
--- a/tests/phpunit/tests/post/revisions.php
+++ b/tests/phpunit/tests/post/revisions.php
@@ -230,6 +230,8 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
$this->assertCount( 1, $revisions );
$this->assertTrue( user_can( self::$editor_user_id, 'read_post', $post_id ) );
+ $this->assertNotEmpty( $revisions );
+
foreach ( $revisions as $revision ) {
$this->assertTrue( user_can( self::$editor_user_id, 'read_post', $revision->ID ) );
}
diff --git a/tests/phpunit/tests/post/wpPostType.php b/tests/phpunit/tests/post/wpPostType.php
index 0eb9f1e203..23ec325a65 100644
--- a/tests/phpunit/tests/post/wpPostType.php
+++ b/tests/phpunit/tests/post/wpPostType.php
@@ -7,6 +7,8 @@ class Tests_Post_WP_Post_Type extends WP_UnitTestCase {
public function test_instances() {
global $wp_post_types;
+ $this->assertNotEmpty( $wp_post_types );
+
foreach ( $wp_post_types as $post_type ) {
$this->assertInstanceOf( 'WP_Post_Type', $post_type );
}
diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php
index 37dd51a063..40d23816d1 100644
--- a/tests/phpunit/tests/query.php
+++ b/tests/phpunit/tests/query.php
@@ -17,6 +17,9 @@ class Tests_Query extends WP_UnitTestCase {
$nested_post_id = self::factory()->post->create();
$first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) );
+
+ $this->assertTrue( $first_query->have_posts() );
+
while ( $first_query->have_posts() ) {
$first_query->the_post();
$second_query = new WP_Query( array( 'post__in' => array( $nested_post_id ) ) );
diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php
index 05278ffd7a..4b47317889 100644
--- a/tests/phpunit/tests/query/conditionals.php
+++ b/tests/phpunit/tests/query/conditionals.php
@@ -14,6 +14,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
protected $page_ids;
protected $post_ids;
+ /**
+ * ID of the user-a.
+ *
+ * @var int
+ */
+ public static $user_a_id;
+
+ /**
+ * Set up the shared fixture.
+ *
+ * @param WP_UnitTest_Factory $factory Factory instance.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_a_id = $factory->user->create( array( 'user_login' => 'user-a' ) );
+ }
+
public function set_up() {
parent::set_up();
@@ -588,7 +604,6 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
// 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
public function test_author_feed() {
- self::factory()->user->create( array( 'user_login' => 'user-a' ) );
// Check the long form.
$types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
foreach ( $types as $type ) {
@@ -607,7 +622,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
public function test_author_paged() {
update_option( 'posts_per_page', 2 );
- $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
+ $user_id = self::$user_a_id;
self::factory()->post->create_many( 3, array( 'post_author' => $user_id ) );
$this->go_to( '/author/user-a/page/2/' );
$this->assertQueryTrue( 'is_archive', 'is_author', 'is_paged' );
@@ -615,14 +630,13 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
public function test_author() {
- $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
+ $user_id = self::$user_a_id;
self::factory()->post->create( array( 'post_author' => $user_id ) );
$this->go_to( '/author/user-a/' );
$this->assertQueryTrue( 'is_archive', 'is_author' );
}
public function test_author_with_no_posts() {
- $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
$this->go_to( '/author/user-a/' );
$this->assertQueryTrue( 'is_archive', 'is_author' );
}
@@ -1122,7 +1136,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 24674
*/
public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() {
- $u1 = self::factory()->user->create();
+ $u1 = self::$user_a_id;
$u2_name = $u1 . '_user';
$u2 = self::factory()->user->create(
@@ -1279,7 +1293,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
global $wpdb;
// We need a non-post that shares an ID with a post assigned a template.
- $user_id = self::factory()->user->create();
+ $user_id = self::$user_a_id;
if ( ! get_post( $user_id ) ) {
$post_id = self::factory()->post->create( array( 'post_type' => 'post' ) );
$wpdb->update( $wpdb->posts, array( 'ID' => $user_id ), array( 'ID' => $post_id ), array( '%d' ) );
@@ -1352,12 +1366,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 35902
*/
public function test_is_author_should_not_match_numeric_id_to_nickname_beginning_with_id() {
- $u1 = self::factory()->user->create(
- array(
- 'nickname' => 'Foo',
- 'user_nicename' => 'foo',
- )
- );
+ $u1 = self::$user_a_id;
$u2 = self::factory()->user->create(
array(
'nickname' => "$u1 Foo",
@@ -1375,12 +1384,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
* @ticket 35902
*/
public function test_is_author_should_not_match_numeric_id_to_user_nicename_beginning_with_id() {
- $u1 = self::factory()->user->create(
- array(
- 'nickname' => 'Foo',
- 'user_nicename' => 'foo',
- )
- );
+ $u1 = self::$user_a_id;
$u2 = self::factory()->user->create(
array(
'nickname' => 'Foo',
diff --git a/tests/phpunit/tests/query/postStatus.php b/tests/phpunit/tests/query/postStatus.php
index 238551b524..95e7968951 100644
--- a/tests/phpunit/tests/query/postStatus.php
+++ b/tests/phpunit/tests/query/postStatus.php
@@ -240,7 +240,11 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
)
);
- foreach ( get_post_stati( array( 'public' => true ) ) as $status ) {
+ $stati = get_post_stati( array( 'public' => true ) );
+
+ $this->assertNotEmpty( $stati );
+
+ foreach ( $stati as $status ) {
$this->assertStringContainsString( "post_status = '$status'", $q->request );
}
}
diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php
index 985ae06f7a..ef6b3479d8 100644
--- a/tests/phpunit/tests/query/setupPostdata.php
+++ b/tests/phpunit/tests/query/setupPostdata.php
@@ -121,6 +121,9 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
'posts_per_page' => 1,
)
);
+
+ $this->assertTrue( $q->have_posts() );
+
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
@@ -221,6 +224,9 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
'post__in' => array( $post2 ),
)
);
+
+ $this->assertTrue( $q->have_posts() );
+
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
@@ -281,6 +287,9 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
'posts_per_page' => 1,
)
);
+
+ $this->assertTrue( $q->have_posts() );
+
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
@@ -367,6 +376,9 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
'posts_per_page' => 1,
)
);
+
+ $this->assertTrue( $q->have_posts() );
+
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php
index 647d5df03d..0bfe4e778d 100644
--- a/tests/phpunit/tests/rest-api/rest-comments-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php
@@ -3442,9 +3442,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
$this->assertSame( $comment->comment_author_IP, $data['author_ip'] );
$this->assertSame( $comment->comment_agent, $data['author_user_agent'] );
$this->assertSame( $comment->comment_content, $data['content']['raw'] );
- }
-
- if ( 'edit' !== $context ) {
+ } else {
$this->assertArrayNotHasKey( 'author_email', $data );
$this->assertArrayNotHasKey( 'author_ip', $data );
$this->assertArrayNotHasKey( 'author_user_agent', $data );
diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
index 6462bb9241..bd0b9a3af4 100644
--- a/tests/phpunit/tests/rest-api/rest-posts-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php
@@ -876,6 +876,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$this->assertSame( 200, $response->get_status() );
$all_data = $response->get_data();
+
+ $this->assertNotEmpty( $all_data );
+
foreach ( $all_data as $post ) {
$this->assertNotEquals( $draft_id, $post['id'] );
}
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index dc991eb672..9cd80005f5 100644
--- a/tests/phpunit/tests/rest-api/rest-server.php
+++ b/tests/phpunit/tests/rest-api/rest-server.php
@@ -1871,6 +1871,8 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
public function test_get_routes_respects_namespace_parameter() {
$routes = rest_get_server()->get_routes( 'oembed/1.0' );
+ $this->assertNotEmpty( $routes );
+
foreach ( $routes as $route => $handlers ) {
$this->assertStringStartsWith( '/oembed/1.0', $route );
}
diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php
index 2f4a2f4982..db34f88752 100644
--- a/tests/phpunit/tests/rest-api/rest-users-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-users-controller.php
@@ -308,6 +308,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$rest_post_types = array_values( get_post_types( array( 'show_in_rest' => true ), 'names' ) );
+ $this->assertNotEmpty( $users );
+
foreach ( $users as $user ) {
$this->assertNotEmpty( count_user_posts( $user['id'], $rest_post_types ) );
@@ -3359,9 +3361,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertSame( $user->user_login, $data['username'] );
$this->assertSame( $user->roles, $data['roles'] );
$this->assertSame( get_user_locale( $user ), $data['locale'] );
- }
-
- if ( 'edit' !== $context ) {
+ } else {
$this->assertArrayNotHasKey( 'roles', $data );
$this->assertArrayNotHasKey( 'capabilities', $data );
$this->assertArrayNotHasKey( 'registered_date', $data );
diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php
index 2c5b04d02e..269da2b05e 100644
--- a/tests/phpunit/tests/shortcode.php
+++ b/tests/phpunit/tests/shortcode.php
@@ -693,10 +693,11 @@ EOF;
private function sub_registration( $input, $expected ) {
add_shortcode( $input, '' );
$actual = shortcode_exists( $input );
- $this->assertSame( $expected, $actual );
if ( $actual ) {
remove_shortcode( $input );
}
+
+ $this->assertSame( $expected, $actual );
}
public function data_registration_bad() {
diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php
index 2a4ee3b560..13528c3015 100644
--- a/tests/phpunit/tests/taxonomy.php
+++ b/tests/phpunit/tests/taxonomy.php
@@ -4,6 +4,18 @@
* @group taxonomy
*/
class Tests_Taxonomy extends WP_UnitTestCase {
+
+ /**
+ * Editor user ID.
+ *
+ * @var int $editor_id
+ */
+ public static $editor_id;
+
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+ }
+
public function test_get_post_taxonomies() {
$this->assertSame( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) );
}
@@ -28,7 +40,11 @@ class Tests_Taxonomy extends WP_UnitTestCase {
}
public function test_get_post_taxonomy() {
- foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) {
+ $taxonomies = get_object_taxonomies( 'post' );
+
+ $this->assertNotEmpty( $taxonomies );
+
+ foreach ( $taxonomies as $taxonomy ) {
$tax = get_taxonomy( $taxonomy );
// Should return an object with the correct taxonomy object type.
$this->assertIsObject( $tax );
@@ -110,7 +126,11 @@ class Tests_Taxonomy extends WP_UnitTestCase {
}
public function test_get_link_taxonomy() {
- foreach ( get_object_taxonomies( 'link' ) as $taxonomy ) {
+ $taxonomies = get_object_taxonomies( 'link' );
+
+ $this->assertNotEmpty( $taxonomies );
+
+ foreach ( $taxonomies as $taxonomy ) {
$tax = get_taxonomy( $taxonomy );
// Should return an object with the correct taxonomy object type.
$this->assertIsObject( $tax );
@@ -1002,7 +1022,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
)
);
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
$updated_post_id = edit_post(
array(
'post_ID' => $post->ID,
@@ -1028,7 +1048,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
*/
public function test_default_term_for_custom_taxonomy() {
- wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
+ wp_set_current_user( self::$editor_id );
$tax = 'custom-tax';
diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php
index 99a73f7823..76eff31adf 100644
--- a/tests/phpunit/tests/term/cache.php
+++ b/tests/phpunit/tests/term/cache.php
@@ -222,6 +222,8 @@ class Tests_Term_Cache extends WP_UnitTestCase {
update_term_cache( $terms );
+ $this->assertNotEmpty( $terms );
+
foreach ( $terms as $term ) {
$this->assertSame( $p, $term->object_id );
}
diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php
index 248d190917..a1eed9d335 100644
--- a/tests/phpunit/tests/term/meta.php
+++ b/tests/phpunit/tests/term/meta.php
@@ -132,26 +132,26 @@ class Tests_Term_Meta extends WP_UnitTestCase {
$this->go_to( get_permalink( $p ) );
remove_action( 'pre_get_posts', array( $this, 'set_cache_results' ) );
- if ( have_posts() ) {
- while ( have_posts() ) {
- the_post();
-
- // First request will hit the database.
- $num_queries = get_num_queries();
- $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
- ++$num_queries;
- $this->assertSame( $num_queries, get_num_queries() );
-
- // Second and third requests should be in cache.
- $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
- $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) );
- $this->assertSame( $num_queries, get_num_queries() );
-
- // Querying a term not primed should result in a hit.
- ++$num_queries;
- $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) );
- $this->assertSame( $num_queries, get_num_queries() );
- }
+ $this->assertTrue( have_posts() );
+
+ while ( have_posts() ) {
+ the_post();
+
+ // First request will hit the database.
+ $num_queries = get_num_queries();
+ $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
+ ++$num_queries;
+ $this->assertSame( $num_queries, get_num_queries() );
+
+ // Second and third requests should be in cache.
+ $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
+ $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) );
+ $this->assertSame( $num_queries, get_num_queries() );
+
+ // Querying a term not primed should result in a hit.
+ ++$num_queries;
+ $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) );
+ $this->assertSame( $num_queries, get_num_queries() );
}
}
@@ -201,20 +201,20 @@ class Tests_Term_Meta extends WP_UnitTestCase {
)
);
- if ( $q->have_posts() ) {
- while ( $q->have_posts() ) {
- $q->the_post();
+ $this->assertTrue( $q->have_posts() );
- // Requests will hit the database.
- $num_queries = get_num_queries();
- $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
- ++$num_queries;
- $this->assertSame( $num_queries, get_num_queries() );
+ while ( $q->have_posts() ) {
+ $q->the_post();
- $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
- ++$num_queries;
- $this->assertSame( $num_queries, get_num_queries() );
- }
+ // Requests will hit the database.
+ $num_queries = get_num_queries();
+ $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
+ ++$num_queries;
+ $this->assertSame( $num_queries, get_num_queries() );
+
+ $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
+ ++$num_queries;
+ $this->assertSame( $num_queries, get_num_queries() );
}
}
diff --git a/tests/phpunit/tests/term/wpGenerateTagCloud.php b/tests/phpunit/tests/term/wpGenerateTagCloud.php
index 62de4a0c26..4b7a27fb47 100644
--- a/tests/phpunit/tests/term/wpGenerateTagCloud.php
+++ b/tests/phpunit/tests/term/wpGenerateTagCloud.php
@@ -156,6 +156,8 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase {
)
);
+ $this->assertNotEmpty( $tags );
+
foreach ( $tags as $tag ) {
$this->assertStringContainsString( '>' . $tag->name . '<', $found );
}
@@ -187,6 +189,8 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase {
$this->assertMatchesRegularExpression( "|^<ul class='wp-tag-cloud' role='list'>|", $found );
$this->assertMatchesRegularExpression( "|</ul>\n|", $found );
+ $this->assertNotEmpty( $tags );
+
foreach ( $tags as $tag ) {
$this->assertStringContainsString( '>' . $tag->name . '<', $found );
}
diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php
index 948ba1e1c3..128e4a19a8 100644
--- a/tests/phpunit/tests/term/wpGetObjectTerms.php
+++ b/tests/phpunit/tests/term/wpGetObjectTerms.php
@@ -110,6 +110,9 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase {
add_filter( 'wp_get_object_terms', array( $this, 'filter_get_object_terms' ) );
$terms = wp_get_object_terms( $post_id, $this->taxonomy );
remove_filter( 'wp_get_object_terms', array( $this, 'filter_get_object_terms' ) );
+
+ $this->assertNotEmpty( $terms );
+
foreach ( $terms as $term ) {
$this->assertIsObject( $term );
}
@@ -845,6 +848,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase {
)
);
+ $this->assertNotEmpty( $found );
+
foreach ( $found as $f ) {
$this->assertSame( $p, $f->object_id );
}
diff --git a/tests/phpunit/tests/term/wpTaxonomy.php b/tests/phpunit/tests/term/wpTaxonomy.php
index 4106e60f3b..845497ad06 100644
--- a/tests/phpunit/tests/term/wpTaxonomy.php
+++ b/tests/phpunit/tests/term/wpTaxonomy.php
@@ -7,6 +7,8 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase {
public function test_instances() {
global $wp_taxonomies;
+ $this->assertNotEmpty( $wp_taxonomies );
+
foreach ( $wp_taxonomies as $taxonomy ) {
$this->assertInstanceOf( 'WP_Taxonomy', $taxonomy );
}
diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php
index 40a8534c43..64a226d004 100644
--- a/tests/phpunit/tests/theme.php
+++ b/tests/phpunit/tests/theme.php
@@ -89,6 +89,9 @@ class Tests_Theme extends WP_UnitTestCase {
*/
public function test_get_theme() {
$themes = get_themes();
+
+ $this->assertNotEmpty( $themes );
+
foreach ( array_keys( $themes ) as $name ) {
$theme = get_theme( $name );
// WP_Theme implements ArrayAccess. Even ArrayObject returns false for is_array().
@@ -100,6 +103,9 @@ class Tests_Theme extends WP_UnitTestCase {
public function test_wp_get_theme() {
$themes = wp_get_themes();
+
+ $this->assertNotEmpty( $themes );
+
foreach ( $themes as $theme ) {
$this->assertInstanceOf( 'WP_Theme', $theme );
$this->assertFalse( $theme->errors() );
@@ -115,6 +121,9 @@ class Tests_Theme extends WP_UnitTestCase {
*/
public function test_get_themes_contents() {
$themes = get_themes();
+
+ $this->assertNotEmpty( $themes );
+
// Generic tests that should hold true for any theme.
foreach ( $themes as $k => $theme ) {
// Don't run these checks for custom themes.
@@ -361,6 +370,8 @@ class Tests_Theme extends WP_UnitTestCase {
public function test_switch_theme() {
$themes = get_themes();
+ $this->assertNotEmpty( $themes );
+
// Switch to each theme in sequence.
// Do it twice to make sure we switch to the first theme, even if it's our starting theme.
// Do it a third time to ensure switch_theme() works with one argument.
diff --git a/tests/phpunit/tests/url.php b/tests/phpunit/tests/url.php
index 4768e25b77..37ceb69cba 100644
--- a/tests/phpunit/tests/url.php
+++ b/tests/phpunit/tests/url.php
@@ -7,6 +7,17 @@
*/
class Tests_URL extends WP_UnitTestCase {
+ /**
+ * Author user ID.
+ *
+ * @var int $author_id
+ */
+ public static $author_id;
+
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$author_id = $factory->user->create( array( 'role' => 'author' ) );
+ }
+
public function set_up() {
parent::set_up();
$GLOBALS['pagenow'] = '';
@@ -386,7 +397,7 @@ class Tests_URL extends WP_UnitTestCase {
* @covers ::get_adjacent_post
*/
public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() {
- $u = self::factory()->user->create( array( 'role' => 'author' ) );
+ $u = self::$author_id;
$old_uid = get_current_user_id();
wp_set_current_user( $u );
@@ -425,7 +436,7 @@ class Tests_URL extends WP_UnitTestCase {
* @covers ::get_adjacent_post
*/
public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() {
- $u1 = self::factory()->user->create( array( 'role' => 'author' ) );
+ $u1 = self::$author_id;
$u2 = self::factory()->user->create( array( 'role' => 'administrator' ) );
$old_uid = get_current_user_id();
wp_set_current_user( $u2 );
@@ -465,7 +476,7 @@ class Tests_URL extends WP_UnitTestCase {
* @covers ::get_adjacent_post
*/
public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() {
- $u1 = self::factory()->user->create( array( 'role' => 'author' ) );
+ $u1 = self::$author_id;
$u2 = self::factory()->user->create( array( 'role' => 'author' ) );
$old_uid = get_current_user_id();
wp_set_current_user( $u2 );
diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php
index 9e1faa2dca..df9f74b7e8 100644
--- a/tests/phpunit/tests/user.php
+++ b/tests/phpunit/tests/user.php
@@ -49,7 +49,7 @@ class Tests_User extends WP_UnitTestCase {
self::$user_ids[] = self::$admin_id;
self::$editor_id = $factory->user->create(
array(
- 'user_email' => 'test@test.com',
+ 'user_email' => 'test@example.com',
'role' => 'editor',
)
);
@@ -820,7 +820,7 @@ class Tests_User extends WP_UnitTestCase {
*/
public function test_validate_username_string() {
$this->assertTrue( validate_username( 'johndoe' ) );
- $this->assertTrue( validate_username( 'test@test.com' ) );
+ $this->assertTrue( validate_username( 'test@example.com' ) );
}
/**
@@ -1035,7 +1035,7 @@ class Tests_User extends WP_UnitTestCase {
$u = wp_insert_user(
array(
'user_login' => 'test',
- 'user_email' => 'test@example.com',
+ 'user_email' => 'urltest@example.com',
'user_pass' => 'password',
'user_url' => $user_url,
)
@@ -1083,7 +1083,7 @@ class Tests_User extends WP_UnitTestCase {
* @ticket 35750
*/
public function test_wp_update_user_should_delete_userslugs_cache() {
- $u = self::factory()->user->create();
+ $u = self::$sub_id;
$user = get_userdata( $u );
wp_update_user(
@@ -1256,7 +1256,7 @@ class Tests_User extends WP_UnitTestCase {
// Alter the case of the email address (which stays the same).
$userdata = array(
'ID' => self::$editor_id,
- 'user_email' => 'test@TEST.com',
+ 'user_email' => 'test@EXAMPLE.com',
);
$update = wp_update_user( $userdata );
@@ -1270,7 +1270,7 @@ class Tests_User extends WP_UnitTestCase {
// Change the email address.
$userdata = array(
'ID' => self::$editor_id,
- 'user_email' => 'test2@test.com',
+ 'user_email' => 'test2@example.com',
);
$update = wp_update_user( $userdata );
@@ -1279,7 +1279,7 @@ class Tests_User extends WP_UnitTestCase {
// Verify that the email address has been updated.
$user = get_userdata( self::$editor_id );
- $this->assertSame( $user->user_email, 'test2@test.com' );
+ $this->assertSame( $user->user_email, 'test2@example.com' );
}
/**
@@ -1939,11 +1939,7 @@ class Tests_User extends WP_UnitTestCase {
$_GET = array();
$_REQUEST = array();
- $administrator = self::factory()->user->create(
- array(
- 'role' => 'administrator',
- )
- );
+ $administrator = self::$admin_id;
wp_set_current_user( $administrator );
@@ -1957,11 +1953,7 @@ class Tests_User extends WP_UnitTestCase {
$this->assertSame( array( 'administrator' ), get_userdata( $administrator )->roles );
// Promote an editor to an administrator.
- $editor = self::factory()->user->create(
- array(
- 'role' => 'editor',
- )
- );
+ $editor = self::$editor_id;
$_POST['role'] = 'administrator';
$_POST['email'] = 'administrator@administrator.test';
@@ -1978,7 +1970,7 @@ class Tests_User extends WP_UnitTestCase {
* @ticket 43547
*/
public function test_wp_user_personal_data_exporter_no_user() {
- $actual = wp_user_personal_data_exporter( 'not-a-user-email@test.com' );
+ $actual = wp_user_personal_data_exporter( 'not-a-user-email@example.com' );
$expected = array(
'data' => array(),
diff --git a/tests/phpunit/tests/xmlrpc/wp/getComments.php b/tests/phpunit/tests/xmlrpc/wp/getComments.php
index edeb6254f0..606f9e0e85 100644
--- a/tests/phpunit/tests/xmlrpc/wp/getComments.php
+++ b/tests/phpunit/tests/xmlrpc/wp/getComments.php
@@ -28,6 +28,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
$results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array() ) );
$this->assertNotIXRError( $results );
+ $this->assertNotEmpty( $results );
foreach ( $results as $result ) {
$comment = get_comment( $result['comment_id'], ARRAY_A );
@@ -52,6 +53,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
)
);
$this->assertNotIXRError( $results );
+ $this->assertNotEmpty( $results );
foreach ( $results as $result ) {
$this->assertEquals( $this->post_id, $result['post_id'] );
diff --git a/tests/phpunit/tests/xmlrpc/wp/getPageList.php b/tests/phpunit/tests/xmlrpc/wp/getPageList.php
index 15d14b748f..abf936c799 100644
--- a/tests/phpunit/tests/xmlrpc/wp/getPageList.php
+++ b/tests/phpunit/tests/xmlrpc/wp/getPageList.php
@@ -41,6 +41,7 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase {
$results = $this->myxmlrpcserver->wp_getPageList( array( 1, 'editor', 'editor' ) );
$this->assertNotIXRError( $results );
+ $this->assertNotEmpty( $results );
foreach ( $results as $result ) {
$page = get_post( $result->page_id );
diff --git a/tests/phpunit/tests/xmlrpc/wp/getPages.php b/tests/phpunit/tests/xmlrpc/wp/getPages.php
index eb99caf5c1..9e120c87cc 100644
--- a/tests/phpunit/tests/xmlrpc/wp/getPages.php
+++ b/tests/phpunit/tests/xmlrpc/wp/getPages.php
@@ -47,6 +47,7 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase {
public function test_capable_user() {
$results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) );
$this->assertNotIXRError( $results );
+ $this->assertNotEmpty( $results );
foreach ( $results as $result ) {
$page = get_post( $result['page_id'] );
diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php
index 814f0c1018..1369aaaae2 100644
--- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php
+++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php
@@ -100,6 +100,8 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
);
$results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter2 ) );
$this->assertNotIXRError( $results2 );
+ $this->assertNotEmpty( $results2 );
+
$last_comment_count = 100;
foreach ( $results2 as $post ) {
$comment_count = (int) get_comments_number( $post['post_id'] );
diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php
index 3487c320da..d538a4efd2 100644
--- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php
+++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php
@@ -46,6 +46,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase {
$results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) );
$this->assertNotIXRError( $results );
+ $this->assertNotEmpty( $results );
foreach ( $results as $term ) {
$this->assertIsInt( $term['count'] );
diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php
index 0cf340c0d6..2c8c4ec245 100644
--- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php
+++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php
@@ -117,6 +117,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase {
);
$results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
$this->assertNotIXRError( $results );
+ $this->assertNotEmpty( $results );
$last_email = '';
foreach ( $results as $user ) {
diff --git a/tools/local-env/scripts/install.js b/tools/local-env/scripts/install.js
index f205047a5a..ad75da48c4 100644
--- a/tools/local-env/scripts/install.js
+++ b/tools/local-env/scripts/install.js
@@ -42,7 +42,7 @@ wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
.then( () => {
wp_cli( 'db reset --yes' );
const installCommand = process.env.LOCAL_MULTISITE === 'true' ? 'multisite-install' : 'install';
- wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password --admin_email=test@test.com --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
+ wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password --admin_email=test@example.com --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
} );
/**