<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[60148] trunk/tests/phpunit/tests: Tests: Use the `ms-required` group where appropriate.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/60148">60148</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/60148","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-04-09 13:29:39 +0000 (Wed, 09 Apr 2025)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Tests: Use the `ms-required` group where appropriate.
This replaces the `if ( is_multisite() )` conditional wrapping entire test classes with the `ms-required` group for more consistency across the test suite.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/40520">[40520]</a>.
See <a href="https://core.trac.wordpress.org/ticket/63167">#63167</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsmultisiteavoidBlogPagePermalinkCollisionphp">trunk/tests/phpunit/tests/multisite/avoidBlogPagePermalinkCollision.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitebootstrapphp">trunk/tests/phpunit/tests/multisite/bootstrap.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitecleanDirsizeCachephp">trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteforceSslContentphp">trunk/tests/phpunit/tests/multisite/forceSslContent.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitegetBlogDetailsphp">trunk/tests/phpunit/tests/multisite/getBlogDetails.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitegetIdFromBlognamephp">trunk/tests/phpunit/tests/multisite/getIdFromBlogname.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitegetMainSiteIdphp">trunk/tests/phpunit/tests/multisite/getMainSiteId.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitegetSitephp">trunk/tests/phpunit/tests/multisite/getSite.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitegetSpaceAllowedphp">trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitegetSpaceUsedphp">trunk/tests/phpunit/tests/multisite/getSpaceUsed.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteisEmailAddressUnsafephp">trunk/tests/phpunit/tests/multisite/isEmailAddressUnsafe.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteisUploadSpaceAvailablephp">trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitemsFilesRewritingphp">trunk/tests/phpunit/tests/multisite/msFilesRewriting.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitenetworkphp">trunk/tests/phpunit/tests/multisite/network.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesitephp">trunk/tests/phpunit/tests/multisite/site.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesiteDetailsphp">trunk/tests/phpunit/tests/multisite/siteDetails.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesiteMetaphp">trunk/tests/phpunit/tests/multisite/siteMeta.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteupdateBlogDetailsphp">trunk/tests/phpunit/tests/multisite/updateBlogDetails.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteupdateBlogStatusphp">trunk/tests/phpunit/tests/multisite/updateBlogStatus.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteupdatePostsCountphp">trunk/tests/phpunit/tests/multisite/updatePostsCount.php</a></li>
<li><a href="#trunktestsphpunittestsmultisiteuploadIsUserOverQuotaphp">trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpCountSitesphp">trunk/tests/phpunit/tests/multisite/wpCountSites.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpGetSitesphp">trunk/tests/phpunit/tests/multisite/wpGetSites.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpInstallDefaultsphp">trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpMsSitesListTablephp">trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpMsThemesListTablephp">trunk/tests/phpunit/tests/multisite/wpMsThemesListTable.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpMsUsersListTablephp">trunk/tests/phpunit/tests/multisite/wpMsUsersListTable.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpNetworkQueryphp">trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpSiteQueryphp">trunk/tests/phpunit/tests/multisite/wpSiteQuery.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpmuLogNewRegistrationsphp">trunk/tests/phpunit/tests/multisite/wpmuLogNewRegistrations.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpmuValidateBlogSignupphp">trunk/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpmuValidateUserSignupphp">trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php</a></li>
<li><a href="#trunktestsphpunittestsoptionmultisitephp">trunk/tests/phpunit/tests/option/multisite.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemeGetAllowedFiltersphp">trunk/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php</a></li>
<li><a href="#trunktestsphpunittestsusergetActiveBlogForUserphp">trunk/tests/phpunit/tests/user/getActiveBlogForUser.php</a></li>
<li><a href="#trunktestsphpunittestsusermultisitephp">trunk/tests/phpunit/tests/user/multisite.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsmultisiteavoidBlogPagePermalinkCollisionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/avoidBlogPagePermalinkCollision.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/avoidBlogPagePermalinkCollision.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/avoidBlogPagePermalinkCollision.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,69 +1,67 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to `avoid_blog_page_permalink_collision()` in multisite.
+ *
+ * @group ms-required
+ * @group multisite
+ * @group post
+ */
+class Tests_Multisite_AvoidBlogPagePermalinkCollision extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $site_id;
+ protected static $root_page;
+ protected static $child_page;
+ protected static $post_and_blog_path = 'permalink-collision';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Tests specific to `avoid_blog_page_permalink_collision()` in multisite.
- *
- * @group multisite
- * @group post
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Create a blog and the pages we need to test the collision.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_AvoidBlogPagePermalinkCollision extends WP_UnitTestCase {
- protected static $site_id;
- protected static $root_page;
- protected static $child_page;
- protected static $post_and_blog_path = 'permalink-collision';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$site_id = self::factory()->blog->create(
+ array(
+ 'path' => '/' . self::$post_and_blog_path,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Create a blog and the pages we need to test the collision.
- */
- public static function wpSetUpBeforeClass( $factory ) {
- self::$site_id = self::factory()->blog->create(
- array(
- 'path' => '/' . self::$post_and_blog_path,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$root_page = self::factory()->post->create_and_get(
+ array(
+ 'post_type' => 'page',
+ 'post_title' => 'Bar',
+ 'post_name' => self::$post_and_blog_path,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$root_page = self::factory()->post->create_and_get(
- array(
- 'post_type' => 'page',
- 'post_title' => 'Bar',
- 'post_name' => self::$post_and_blog_path,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$child_page = self::factory()->post->create_and_get(
+ array(
+ 'post_parent' => self::$root_page->ID,
+ 'post_type' => 'page',
+ 'post_title' => 'Bar',
+ 'post_name' => self::$post_and_blog_path,
+ )
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$child_page = self::factory()->post->create_and_get(
- array(
- 'post_parent' => self::$root_page->ID,
- 'post_type' => 'page',
- 'post_title' => 'Bar',
- 'post_name' => self::$post_and_blog_path,
- )
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Delete blog and pages we created.
+ */
+ public static function wpTearDownAfterClass() {
+ wp_delete_site( self::$site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Delete blog and pages we created.
- */
- public static function wpTearDownAfterClass() {
- wp_delete_site( self::$site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_post( self::$root_page->ID );
+ wp_delete_post( self::$child_page->ID );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_post( self::$root_page->ID );
- wp_delete_post( self::$child_page->ID );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_avoid_blog_page_permalink_collision_renames_post_name() {
+ $this->assertNotSame( self::$post_and_blog_path, self::$root_page->post_name );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_avoid_blog_page_permalink_collision_renames_post_name() {
- $this->assertNotSame( self::$post_and_blog_path, self::$root_page->post_name );
- }
-
- /**
- * Ensure `avoid_blog_page_permalink_collision()` doesn't rename child pages' post_name.
- *
- * @ticket 51147
- */
- public function test_avoid_blog_page_permalink_collision_doesnt_rename_child_pages() {
- $this->assertSame( self::$post_and_blog_path, self::$child_page->post_name );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Ensure `avoid_blog_page_permalink_collision()` doesn't rename child pages' post_name.
+ *
+ * @ticket 51147
+ */
+ public function test_avoid_blog_page_permalink_collision_doesnt_rename_child_pages() {
+ $this->assertSame( self::$post_and_blog_path, self::$child_page->post_name );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitebootstrapphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/bootstrap.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/bootstrap.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/bootstrap.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,344 +1,347 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to the bootstrap process of Multisite.
+ *
+ * @group ms-bootstrap
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to the bootstrap process of Multisite.
- *
- * @group ms-bootstrap
- * @group multisite
- */
- class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
- protected static $network_ids;
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $network_ids;
+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$network_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- ),
- 'wordpress.org/one/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/one/',
- ),
- 'wordpress.org/one/b/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/one/b/',
- ),
- 'wordpress.net/' => array(
- 'domain' => 'wordpress.net',
- 'path' => '/',
- ),
- 'www.wordpress.net/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/',
- ),
- 'www.wordpress.net/two/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/two/',
- ),
- 'wordpress.net/three/' => array(
- 'domain' => 'wordpress.net',
- 'path' => '/three/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$network_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ ),
+ 'wordpress.org/one/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/one/',
+ ),
+ 'wordpress.org/one/b/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/one/b/',
+ ),
+ 'wordpress.net/' => array(
+ 'domain' => 'wordpress.net',
+ 'path' => '/',
+ ),
+ 'www.wordpress.net/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/',
+ ),
+ 'www.wordpress.net/two/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/two/',
+ ),
+ 'wordpress.net/three/' => array(
+ 'domain' => 'wordpress.net',
+ 'path' => '/three/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
+ }
+ unset( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$site_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'wordpress.org/foo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'wordpress.org/foo/bar/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/bar/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- ),
- 'make.wordpress.org/foo/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- ),
- 'www.w.org/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/',
- ),
- 'www.w.org/foo/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/',
- ),
- 'www.w.org/foo/bar/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/bar/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$site_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'wordpress.org/foo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'wordpress.org/foo/bar/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/bar/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ ),
+ 'make.wordpress.org/foo/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ ),
+ 'www.w.org/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/',
+ ),
+ 'www.w.org/foo/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/',
+ ),
+ 'www.w.org/foo/bar/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/bar/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
-
- foreach ( self::$network_ids as $id ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
- }
-
- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 27003
- * @dataProvider data_get_network_by_path
- *
- * @param string $expected_key The array key associated with expected data for the test.
- * @param string $domain The requested domain.
- * @param string $path The requested path.
- * @param string $message The message to pass for failed tests.
- */
- public function test_get_network_by_path( $expected_key, $domain, $path, $message ) {
- $network = get_network_by_path( $domain, $path );
- $this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as $id ) {
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_get_network_by_path() {
- return array(
- array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ),
- array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A missing path on a top level domain should find the correct network.' ),
- array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A missing path should find the correct network.' ),
- array( 'wordpress.org/one/', 'www.wordpress.org', '/one/', 'Should find the path despite the www.' ),
- array( 'wordpress.org/one/', 'wordpress.org', '/one/page/', 'A request with two path segments should find the correct network.' ),
- array( 'wordpress.org/one/b/', 'wordpress.org', '/one/b/', 'A request with two valid path segments should find the correct network.' ),
- array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should not find path because domains do not match.' ),
- array( 'wordpress.net/three/', 'wordpress.net', '/three/', 'A network can have a path.' ),
- array( 'www.wordpress.net/two/', 'www.wordpress.net', '/two/', 'A www network with a path can coexist with a non-www network.' ),
- array( 'wordpress.net/', 'site1.wordpress.net', '/notapath/', 'An invalid subdomain should find the top level network domain.' ),
- array( 'wordpress.net/', 'site1.wordpress.net', '/three/', 'An invalid subdomain and path should find the top level network domain.' ),
- array( 'wordpress.net/', 'x.y.wordpress.net', '/', 'An invalid two level subdomain should find the top level network domain.' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 37217
- * @dataProvider data_get_network_by_path_with_zero_path_segments
- *
- * @param string $expected_key The array key associated with expected data for the test.
- * @param string $domain The requested domain.
- * @param string $path The requested path.
- * @param string $message The message to pass for failed tests.
- */
- public function test_get_network_by_path_with_zero_path_segments( $expected_key, $domain, $path, $message ) {
- add_filter( 'network_by_path_segments_count', '__return_zero' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 27003
+ * @dataProvider data_get_network_by_path
+ *
+ * @param string $expected_key The array key associated with expected data for the test.
+ * @param string $domain The requested domain.
+ * @param string $path The requested path.
+ * @param string $message The message to pass for failed tests.
+ */
+ public function test_get_network_by_path( $expected_key, $domain, $path, $message ) {
+ $network = get_network_by_path( $domain, $path );
+ $this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network = get_network_by_path( $domain, $path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_get_network_by_path() {
+ return array(
+ array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ),
+ array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A missing path on a top level domain should find the correct network.' ),
+ array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A missing path should find the correct network.' ),
+ array( 'wordpress.org/one/', 'www.wordpress.org', '/one/', 'Should find the path despite the www.' ),
+ array( 'wordpress.org/one/', 'wordpress.org', '/one/page/', 'A request with two path segments should find the correct network.' ),
+ array( 'wordpress.org/one/b/', 'wordpress.org', '/one/b/', 'A request with two valid path segments should find the correct network.' ),
+ array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should not find path because domains do not match.' ),
+ array( 'wordpress.net/three/', 'wordpress.net', '/three/', 'A network can have a path.' ),
+ array( 'www.wordpress.net/two/', 'www.wordpress.net', '/two/', 'A www network with a path can coexist with a non-www network.' ),
+ array( 'wordpress.net/', 'site1.wordpress.net', '/notapath/', 'An invalid subdomain should find the top level network domain.' ),
+ array( 'wordpress.net/', 'site1.wordpress.net', '/three/', 'An invalid subdomain and path should find the top level network domain.' ),
+ array( 'wordpress.net/', 'x.y.wordpress.net', '/', 'An invalid two level subdomain should find the top level network domain.' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'network_by_path_segments_count', '__return_zero' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37217
+ * @dataProvider data_get_network_by_path_with_zero_path_segments
+ *
+ * @param string $expected_key The array key associated with expected data for the test.
+ * @param string $domain The requested domain.
+ * @param string $path The requested path.
+ * @param string $message The message to pass for failed tests.
+ */
+ public function test_get_network_by_path_with_zero_path_segments( $expected_key, $domain, $path, $message ) {
+ add_filter( 'network_by_path_segments_count', '__return_zero' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network = get_network_by_path( $domain, $path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_get_network_by_path_with_zero_path_segments() {
- return array(
- array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ),
- array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A network matching a top level domain should be found regardless of path.' ),
- array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A network matching a domain should be found regardless of path.' ),
- array( 'wordpress.org/', 'www.wordpress.org', '/one/', 'Should find the network despite the www and regardless of path.' ),
- array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should find the network with the corresponding top level domain regardless of path.' ),
- array( 'www.wordpress.net/', 'www.wordpress.net', '/two/', 'A www network can coexist with a non-www network.' ),
- array( 'make.wordpress.org/', 'make.wordpress.org', '/notapath/', 'A subdomain network should be found regardless of path.' ),
- array( 'wordpress.net/', 'x.y.wordpress.net', '/', 'An invalid two level subdomain should find the top level network domain.' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'network_by_path_segments_count', '__return_zero' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Even if a matching network is available, it should not match if the the filtered
- * value for network path segments is fewer than the number of paths passed.
- */
- public function test_get_network_by_path_with_forced_single_path_segment_returns_single_path_network() {
- add_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) );
- $network = get_network_by_path( 'wordpress.org', '/one/b/' );
- remove_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( self::$network_ids['wordpress.org/one/'], $network->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_get_network_by_path_with_zero_path_segments() {
+ return array(
+ array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ),
+ array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A network matching a top level domain should be found regardless of path.' ),
+ array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A network matching a domain should be found regardless of path.' ),
+ array( 'wordpress.org/', 'www.wordpress.org', '/one/', 'Should find the network despite the www and regardless of path.' ),
+ array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should find the network with the corresponding top level domain regardless of path.' ),
+ array( 'www.wordpress.net/', 'www.wordpress.net', '/two/', 'A www network can coexist with a non-www network.' ),
+ array( 'make.wordpress.org/', 'make.wordpress.org', '/notapath/', 'A subdomain network should be found regardless of path.' ),
+ array( 'wordpress.net/', 'x.y.wordpress.net', '/', 'An invalid two level subdomain should find the top level network domain.' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_network_path_segments() {
- return 1;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Even if a matching network is available, it should not match if the the filtered
+ * value for network path segments is fewer than the number of paths passed.
+ */
+ public function test_get_network_by_path_with_forced_single_path_segment_returns_single_path_network() {
+ add_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) );
+ $network = get_network_by_path( 'wordpress.org', '/one/b/' );
+ remove_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 27003
- * @ticket 27927
- * @dataProvider data_get_site_by_path
- *
- * @param string $expected_key The array key associated with expected data for the test.
- * @param string $domain The requested domain.
- * @param string $path The requested path.
- * @param int $segments Optional. Number of segments to use in `get_site_by_path()`.
- */
- public function test_get_site_by_path( $expected_key, $domain, $path, $segments = null ) {
- $site = get_site_by_path( $domain, $path, $segments );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$network_ids['wordpress.org/one/'], $network->id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $expected_key ) {
- $this->assertEquals( self::$site_ids[ $expected_key ], $site->blog_id );
- } else {
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_network_path_segments() {
+ return 1;
+ }
+
+ /**
+ * @ticket 27003
+ * @ticket 27927
+ * @dataProvider data_get_site_by_path
+ *
+ * @param string $expected_key The array key associated with expected data for the test.
+ * @param string $domain The requested domain.
+ * @param string $path The requested path.
+ * @param int $segments Optional. Number of segments to use in `get_site_by_path()`.
+ */
+ public function test_get_site_by_path( $expected_key, $domain, $path, $segments = null ) {
+ $site = get_site_by_path( $domain, $path, $segments );
+
+ if ( $expected_key ) {
+ $this->assertEquals( self::$site_ids[ $expected_key ], $site->blog_id );
+ } else {
+ $this->assertFalse( $site );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_get_site_by_path() {
- return array(
- array( 'wordpress.org/', 'wordpress.org', '/notapath/' ),
- array( 'wordpress.org/', 'www.wordpress.org', '/notapath/' ),
- array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/' ),
- array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/' ),
- array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/', 3 ),
- array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/', 3 ),
- array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/', 2 ),
- array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/', 2 ),
- array( 'wordpress.org/foo/', 'wordpress.org', '/foo/bar/baz/', 1 ),
- array( 'wordpress.org/foo/', 'www.wordpress.org', '/foo/bar/baz/', 1 ),
- array( 'wordpress.org/', 'wordpress.org', '/', 0 ),
- array( 'wordpress.org/', 'www.wordpress.org', '/', 0 ),
- array( 'make.wordpress.org/foo/', 'make.wordpress.org', '/foo/bar/baz/quz/', 4 ),
- array( 'make.wordpress.org/foo/', 'www.make.wordpress.org', '/foo/bar/baz/quz/', 4 ),
- array( 'www.w.org/', 'www.w.org', '/', 0 ),
- array( 'www.w.org/', 'www.w.org', '/notapath' ),
- array( 'www.w.org/foo/bar/', 'www.w.org', '/foo/bar/baz/' ),
- array( 'www.w.org/foo/', 'www.w.org', '/foo/bar/baz/', 1 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_get_site_by_path() {
+ return array(
+ array( 'wordpress.org/', 'wordpress.org', '/notapath/' ),
+ array( 'wordpress.org/', 'www.wordpress.org', '/notapath/' ),
+ array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/' ),
+ array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/' ),
+ array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/', 3 ),
+ array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/', 3 ),
+ array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/', 2 ),
+ array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/', 2 ),
+ array( 'wordpress.org/foo/', 'wordpress.org', '/foo/bar/baz/', 1 ),
+ array( 'wordpress.org/foo/', 'www.wordpress.org', '/foo/bar/baz/', 1 ),
+ array( 'wordpress.org/', 'wordpress.org', '/', 0 ),
+ array( 'wordpress.org/', 'www.wordpress.org', '/', 0 ),
+ array( 'make.wordpress.org/foo/', 'make.wordpress.org', '/foo/bar/baz/quz/', 4 ),
+ array( 'make.wordpress.org/foo/', 'www.make.wordpress.org', '/foo/bar/baz/quz/', 4 ),
+ array( 'www.w.org/', 'www.w.org', '/', 0 ),
+ array( 'www.w.org/', 'www.w.org', '/notapath' ),
+ array( 'www.w.org/foo/bar/', 'www.w.org', '/foo/bar/baz/' ),
+ array( 'www.w.org/foo/', 'www.w.org', '/foo/bar/baz/', 1 ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // A site installed with www will not be found by the root domain.
- array( false, 'w.org', '/' ),
- array( false, 'w.org', '/notapath/' ),
- array( false, 'w.org', '/foo/bar/baz/' ),
- array( false, 'w.org', '/foo/bar/baz/', 1 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // A site installed with www will not be found by the root domain.
+ array( false, 'w.org', '/' ),
+ array( false, 'w.org', '/notapath/' ),
+ array( false, 'w.org', '/foo/bar/baz/' ),
+ array( false, 'w.org', '/foo/bar/baz/', 1 ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // A site will not be found by its root domain when an invalid subdomain is requested.
- array( false, 'invalid.wordpress.org', '/' ),
- array( false, 'invalid.wordpress.org', '/foo/bar/' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // A site will not be found by its root domain when an invalid subdomain is requested.
+ array( false, 'invalid.wordpress.org', '/' ),
+ array( false, 'invalid.wordpress.org', '/foo/bar/' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 27884
- * @dataProvider data_multisite_bootstrap
- *
- * @param string $site_key The array key associated with the expected site for the test.
- * @param string $network_key The array key associated with the expected network for the test.
- * @param string $domain The requested domain.
- * @param string $path The requested path.
- */
- public function test_multisite_bootstrap( $site_key, $network_key, $domain, $path ) {
- global $current_blog;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 27884
+ * @dataProvider data_multisite_bootstrap
+ *
+ * @param string $site_key The array key associated with the expected site for the test.
+ * @param string $network_key The array key associated with the expected network for the test.
+ * @param string $domain The requested domain.
+ * @param string $path The requested path.
+ */
+ public function test_multisite_bootstrap( $site_key, $network_key, $domain, $path ) {
+ global $current_blog;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- 'network_id' => self::$network_ids[ $network_key ],
- 'site_id' => self::$site_ids[ $site_key ],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ 'network_id' => self::$network_ids[ $network_key ],
+ 'site_id' => self::$site_ids[ $site_key ],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ms_load_current_site_and_network( $domain, $path );
- $actual = array(
- 'network_id' => $current_blog->site_id,
- 'site_id' => $current_blog->blog_id,
- );
- ms_load_current_site_and_network( WP_TESTS_DOMAIN, '/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ms_load_current_site_and_network( $domain, $path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualSetsWithIndex( $expected, $actual );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $actual = array(
+ 'network_id' => $current_blog->site_id,
+ 'site_id' => $current_blog->blog_id,
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_multisite_bootstrap() {
- return array(
- array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/' ),
- array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/2014/04/23/hello-world/' ),
- array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/sample-page/' ),
- array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/?p=1' ),
- array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/wp-admin/' ),
- array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/' ),
- array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/FOO/' ),
- array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/2014/04/23/hello-world/' ),
- array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/sample-page/' ),
- array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/?p=1' ),
- array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/wp-admin/' ),
- array( 'make.wordpress.org/', 'make.wordpress.org/', 'make.wordpress.org', '/' ),
- array( 'make.wordpress.org/foo/', 'make.wordpress.org/', 'make.wordpress.org', '/foo/' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ms_load_current_site_and_network( WP_TESTS_DOMAIN, '/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 27884
- */
- public function test_multisite_bootstrap_additional_path_segments() {
- global $current_blog;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualSetsWithIndex( $expected, $actual );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'site_id' => self::$site_ids['wordpress.org/foo/bar/'],
- );
- add_filter( 'site_by_path_segments_count', array( $this, 'filter_path_segments_to_two' ) );
- ms_load_current_site_and_network( 'wordpress.org', '/foo/bar/' );
- $actual = array(
- 'network_id' => $current_blog->site_id,
- 'site_id' => $current_blog->blog_id,
- );
- remove_filter( 'site_by_path_segments_count', array( $this, 'filter_path_segments_to_two' ) );
- ms_load_current_site_and_network( WP_TESTS_DOMAIN, '/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_multisite_bootstrap() {
+ return array(
+ array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/' ),
+ array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/2014/04/23/hello-world/' ),
+ array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/sample-page/' ),
+ array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/?p=1' ),
+ array( 'wordpress.org/', 'wordpress.org/', 'wordpress.org', '/wp-admin/' ),
+ array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/' ),
+ array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/FOO/' ),
+ array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/2014/04/23/hello-world/' ),
+ array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/sample-page/' ),
+ array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/?p=1' ),
+ array( 'wordpress.org/foo/', 'wordpress.org/', 'wordpress.org', '/foo/wp-admin/' ),
+ array( 'make.wordpress.org/', 'make.wordpress.org/', 'make.wordpress.org', '/' ),
+ array( 'make.wordpress.org/foo/', 'make.wordpress.org/', 'make.wordpress.org', '/foo/' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualSetsWithIndex( $expected, $actual );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 27884
+ */
+ public function test_multisite_bootstrap_additional_path_segments() {
+ global $current_blog;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 37053
- */
- public function test_get_site_by_path_returns_wp_site() {
- add_filter( 'pre_get_site_by_path', array( $this, 'filter_pre_get_site_by_path' ), 10, 3 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'site_id' => self::$site_ids['wordpress.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site_by_path( 'example.com', '/foo/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'site_by_path_segments_count', array( $this, 'filter_path_segments_to_two' ) );
+ ms_load_current_site_and_network( 'wordpress.org', '/foo/bar/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'pre_get_site_by_path', array( $this, 'filter_pre_get_site_by_path' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $actual = array(
+ 'network_id' => $current_blog->site_id,
+ 'site_id' => $current_blog->blog_id,
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertInstanceOf( 'WP_Site', $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'site_by_path_segments_count', array( $this, 'filter_path_segments_to_two' ) );
+ ms_load_current_site_and_network( WP_TESTS_DOMAIN, '/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_path_segments_to_two() {
- return 2;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualSetsWithIndex( $expected, $actual );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_pre_get_site_by_path( $site, $domain, $path ) {
- $site = new stdClass();
- $site->blog_id = 100;
- $site->domain = $domain;
- $site->path = $path;
- $site->site_id = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37053
+ */
+ public function test_get_site_by_path_returns_wp_site() {
+ add_filter( 'pre_get_site_by_path', array( $this, 'filter_pre_get_site_by_path' ), 10, 3 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $site;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_site_by_path( 'example.com', '/foo/' );
+
+ remove_filter( 'pre_get_site_by_path', array( $this, 'filter_pre_get_site_by_path' ), 10 );
+
+ $this->assertInstanceOf( 'WP_Site', $site );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_path_segments_to_two() {
+ return 2;
+ }
+
+ public function filter_pre_get_site_by_path( $site, $domain, $path ) {
+ $site = new stdClass();
+ $site->blog_id = 100;
+ $site->domain = $domain;
+ $site->path = $path;
+ $site->site_id = 1;
+
+ return $site;
+ }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitecleanDirsizeCachephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,319 +1,316 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to the directory size caching in multisite.
+ *
+ * @ticket 19879
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_CleanDirsizeCache extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Tests specific to the directory size caching in multisite.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Test whether dirsize_cache values are used correctly with a more complex dirsize cache mock.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 19879
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group multisite
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_CleanDirsizeCache extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_dirsize_cache_in_recurse_dirsize_mock() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test whether dirsize_cache values are used correctly with a more complex dirsize cache mock.
- *
- * @ticket 19879
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Our comparison of space relies on an initial value of 0. If a previous test has failed
+ * or if the `src` directory already contains a directory with site content, then the initial
+ * expectation will be polluted. We create sites until an empty one is available.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_dirsize_cache_in_recurse_dirsize_mock() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Our comparison of space relies on an initial value of 0. If a previous test has failed
- * or if the `src` directory already contains a directory with site content, then the initial
- * expectation will be polluted. We create sites until an empty one is available.
- */
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear the dirsize cache.
+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Clear the dirsize cache.
- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the dirsize cache to our mock.
+ set_transient( 'dirsize_cache', $this->get_mock_dirsize_cache_for_site( $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the dirsize cache to our mock.
- set_transient( 'dirsize_cache', $this->get_mock_dirsize_cache_for_site( $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload_dir = wp_upload_dir();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload_dir = wp_upload_dir();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check recurse_dirsize() against the mock. The cache should match.
+ $this->assertSame( 21, recurse_dirsize( $upload_dir['basedir'] . '/2/1' ) );
+ $this->assertSame( 22, recurse_dirsize( $upload_dir['basedir'] . '/2/2' ) );
+ $this->assertSame( 2, recurse_dirsize( $upload_dir['basedir'] . '/2' ) );
+ $this->assertSame( 11, recurse_dirsize( $upload_dir['basedir'] . '/1/1' ) );
+ $this->assertSame( 12, recurse_dirsize( $upload_dir['basedir'] . '/1/2' ) );
+ $this->assertSame( 13, recurse_dirsize( $upload_dir['basedir'] . '/1/3' ) );
+ $this->assertSame( 1, recurse_dirsize( $upload_dir['basedir'] . '/1' ) );
+ $this->assertSame( 42, recurse_dirsize( $upload_dir['basedir'] . '/custom_directory' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check recurse_dirsize() against the mock. The cache should match.
- $this->assertSame( 21, recurse_dirsize( $upload_dir['basedir'] . '/2/1' ) );
- $this->assertSame( 22, recurse_dirsize( $upload_dir['basedir'] . '/2/2' ) );
- $this->assertSame( 2, recurse_dirsize( $upload_dir['basedir'] . '/2' ) );
- $this->assertSame( 11, recurse_dirsize( $upload_dir['basedir'] . '/1/1' ) );
- $this->assertSame( 12, recurse_dirsize( $upload_dir['basedir'] . '/1/2' ) );
- $this->assertSame( 13, recurse_dirsize( $upload_dir['basedir'] . '/1/3' ) );
- $this->assertSame( 1, recurse_dirsize( $upload_dir['basedir'] . '/1' ) );
- $this->assertSame( 42, recurse_dirsize( $upload_dir['basedir'] . '/custom_directory' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // No cache match, upload directory should be empty and return 0.
+ $this->assertSame( 0, recurse_dirsize( $upload_dir['basedir'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // No cache match, upload directory should be empty and return 0.
- $this->assertSame( 0, recurse_dirsize( $upload_dir['basedir'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // No cache match on non existing directory should return false.
+ $this->assertFalse( recurse_dirsize( $upload_dir['basedir'] . '/does_not_exist' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // No cache match on non existing directory should return false.
- $this->assertFalse( recurse_dirsize( $upload_dir['basedir'] . '/does_not_exist' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Cleanup.
+ $this->remove_added_uploads();
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Cleanup.
- $this->remove_added_uploads();
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test whether the dirsize_cache invalidation works given a file path as input.
+ *
+ * @ticket 19879
+ */
+ public function test_clean_dirsize_cache_file_input_mock() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test whether the dirsize_cache invalidation works given a file path as input.
- *
- * @ticket 19879
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Our comparison of space relies on an initial value of 0. If a previous test has failed
+ * or if the `src` directory already contains a directory with site content, then the initial
+ * expectation will be polluted. We create sites until an empty one is available.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_clean_dirsize_cache_file_input_mock() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Our comparison of space relies on an initial value of 0. If a previous test has failed
- * or if the `src` directory already contains a directory with site content, then the initial
- * expectation will be polluted. We create sites until an empty one is available.
- */
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload_dir = wp_upload_dir();
+ $cache_key_prefix = untrailingslashit( $upload_dir['basedir'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload_dir = wp_upload_dir();
- $cache_key_prefix = untrailingslashit( $upload_dir['basedir'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear the dirsize cache.
+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Clear the dirsize cache.
- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the dirsize cache to our mock.
+ set_transient( 'dirsize_cache', $this->get_mock_dirsize_cache_for_site( $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the dirsize cache to our mock.
- set_transient( 'dirsize_cache', $this->get_mock_dirsize_cache_for_site( $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
+ $this->assertArrayHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
+ $this->assertArrayHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
- $this->assertArrayHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
- $this->assertArrayHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Invalidation should also respect the directory tree up.
+ // Should work fine with path to directory OR file.
+ clean_dirsize_cache( $upload_dir['basedir'] . '/2/1/file.dummy' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Invalidation should also respect the directory tree up.
- // Should work fine with path to directory OR file.
- clean_dirsize_cache( $upload_dir['basedir'] . '/2/1/file.dummy' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayNotHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
+ $this->assertArrayNotHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertArrayNotHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
- $this->assertArrayNotHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Other cache paths should not be invalidated.
+ $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Other cache paths should not be invalidated.
- $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Cleanup.
+ $this->remove_added_uploads();
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Cleanup.
- $this->remove_added_uploads();
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test whether the dirsize_cache invalidation works given a directory path as input.
+ *
+ * @ticket 19879
+ */
+ public function test_clean_dirsize_cache_folder_input_mock() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test whether the dirsize_cache invalidation works given a directory path as input.
- *
- * @ticket 19879
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Our comparison of space relies on an initial value of 0. If a previous test has failed
+ * or if the `src` directory already contains a directory with site content, then the initial
+ * expectation will be polluted. We create sites until an empty one is available.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_clean_dirsize_cache_folder_input_mock() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Our comparison of space relies on an initial value of 0. If a previous test has failed
- * or if the `src` directory already contains a directory with site content, then the initial
- * expectation will be polluted. We create sites until an empty one is available.
- */
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload_dir = wp_upload_dir();
+ $cache_key_prefix = untrailingslashit( $upload_dir['basedir'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload_dir = wp_upload_dir();
- $cache_key_prefix = untrailingslashit( $upload_dir['basedir'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear the dirsize cache.
+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Clear the dirsize cache.
- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the dirsize cache to our mock.
+ set_transient( 'dirsize_cache', $this->get_mock_dirsize_cache_for_site( $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the dirsize cache to our mock.
- set_transient( 'dirsize_cache', $this->get_mock_dirsize_cache_for_site( $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
+ $this->assertArrayHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
+ $this->assertArrayHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
- $this->assertArrayHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
- $this->assertArrayHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Invalidation should also respect the directory tree up.
+ // Should work fine with path to directory OR file.
+ clean_dirsize_cache( $upload_dir['basedir'] . '/2/1' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Invalidation should also respect the directory tree up.
- // Should work fine with path to directory OR file.
- clean_dirsize_cache( $upload_dir['basedir'] . '/2/1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayNotHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
+ $this->assertArrayNotHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertArrayNotHasKey( $cache_key_prefix . '/2/1', get_transient( 'dirsize_cache' ) );
- $this->assertArrayNotHasKey( $cache_key_prefix . '/2', get_transient( 'dirsize_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Other cache paths should not be invalidated.
+ $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Other cache paths should not be invalidated.
- $this->assertArrayHasKey( $cache_key_prefix . '/1/1', get_transient( 'dirsize_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Cleanup.
+ $this->remove_added_uploads();
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Cleanup.
- $this->remove_added_uploads();
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test whether dirsize_cache values are used correctly with a simple real upload.
+ *
+ * @ticket 19879
+ */
+ public function test_get_dirsize_cache_in_recurse_dirsize_upload() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test whether dirsize_cache values are used correctly with a simple real upload.
- *
- * @ticket 19879
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Our comparison of space relies on an initial value of 0. If a previous test has failed
+ * or if the `src` directory already contains a directory with site content, then the initial
+ * expectation will be polluted. We create sites until an empty one is available.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_dirsize_cache_in_recurse_dirsize_upload() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Our comparison of space relies on an initial value of 0. If a previous test has failed
- * or if the `src` directory already contains a directory with site content, then the initial
- * expectation will be polluted. We create sites until an empty one is available.
- */
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear the dirsize cache.
+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Clear the dirsize cache.
- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload_dir = wp_upload_dir();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload_dir = wp_upload_dir();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 0, recurse_dirsize( $upload_dir['path'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, recurse_dirsize( $upload_dir['path'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Upload a file to the new site using wp_upload_bits().
+ $filename = __FUNCTION__ . '.jpg';
+ $contents = __FUNCTION__ . '_contents';
+ $file = wp_upload_bits( $filename, null, $contents );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Upload a file to the new site using wp_upload_bits().
- $filename = __FUNCTION__ . '.jpg';
- $contents = __FUNCTION__ . '_contents';
- $file = wp_upload_bits( $filename, null, $contents );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $calc_size = recurse_dirsize( $upload_dir['path'] );
+ $size = filesize( $file['file'] );
+ $this->assertSame( $size, $calc_size );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $calc_size = recurse_dirsize( $upload_dir['path'] );
- $size = filesize( $file['file'] );
- $this->assertSame( $size, $calc_size );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // `dirsize_cache` should now be filled after upload and recurse_dirsize() call.
+ $cache_path = untrailingslashit( $upload_dir['path'] );
+ $this->assertIsArray( get_transient( 'dirsize_cache' ) );
+ $this->assertSame( $size, get_transient( 'dirsize_cache' )[ $cache_path ] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // `dirsize_cache` should now be filled after upload and recurse_dirsize() call.
- $cache_path = untrailingslashit( $upload_dir['path'] );
- $this->assertIsArray( get_transient( 'dirsize_cache' ) );
- $this->assertSame( $size, get_transient( 'dirsize_cache' )[ $cache_path ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Cleanup.
+ $this->remove_added_uploads();
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Cleanup.
- $this->remove_added_uploads();
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test whether the filter to calculate space for an existing directory works as expected.
+ *
+ * @ticket 19879
+ */
+ public function test_pre_recurse_dirsize_filter() {
+ add_filter( 'pre_recurse_dirsize', array( $this, 'filter_pre_recurse_dirsize' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test whether the filter to calculate space for an existing directory works as expected.
- *
- * @ticket 19879
- */
- public function test_pre_recurse_dirsize_filter() {
- add_filter( 'pre_recurse_dirsize', array( $this, 'filter_pre_recurse_dirsize' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload_dir = wp_upload_dir();
+ $this->assertSame( 1042, recurse_dirsize( $upload_dir['path'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload_dir = wp_upload_dir();
- $this->assertSame( 1042, recurse_dirsize( $upload_dir['path'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'pre_recurse_dirsize', array( $this, 'filter_pre_recurse_dirsize' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'pre_recurse_dirsize', array( $this, 'filter_pre_recurse_dirsize' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_pre_recurse_dirsize() {
+ return 1042;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_pre_recurse_dirsize() {
- return 1042;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function get_mock_dirsize_cache_for_site( $site_id ) {
+ $prefix = wp_upload_dir()['basedir'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private function get_mock_dirsize_cache_for_site( $site_id ) {
- $prefix = wp_upload_dir()['basedir'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return array(
+ "$prefix/2/2" => 22,
+ "$prefix/2/1" => 21,
+ "$prefix/2" => 2,
+ "$prefix/1/3" => 13,
+ "$prefix/1/2" => 12,
+ "$prefix/1/1" => 11,
+ "$prefix/1" => 1,
+ "$prefix/custom_directory" => 42,
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array(
- "$prefix/2/2" => 22,
- "$prefix/2/1" => 21,
- "$prefix/2" => 2,
- "$prefix/1/3" => 13,
- "$prefix/1/2" => 12,
- "$prefix/1/1" => 11,
- "$prefix/1" => 1,
- "$prefix/custom_directory" => 42,
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Test that 5.6+ gracefully handles the old 5.5 transient structure.
+ *
+ * @ticket 51913
+ */
+ public function test_5_5_transient_structure_compat() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Test that 5.6+ gracefully handles the old 5.5 transient structure.
- *
- * @ticket 51913
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Our comparison of space relies on an initial value of 0. If a previous test has failed
+ * or if the `src` directory already contains a directory with site content, then the initial
+ * expectation will be polluted. We create sites until an empty one is available.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_5_5_transient_structure_compat() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Our comparison of space relies on an initial value of 0. If a previous test has failed
- * or if the `src` directory already contains a directory with site content, then the initial
- * expectation will be polluted. We create sites until an empty one is available.
- */
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear the dirsize cache.
+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Clear the dirsize cache.
- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the dirsize cache to our mock.
+ set_transient( 'dirsize_cache', $this->get_mock_5_5_dirsize_cache( $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the dirsize cache to our mock.
- set_transient( 'dirsize_cache', $this->get_mock_5_5_dirsize_cache( $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload_dir = wp_upload_dir();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload_dir = wp_upload_dir();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * The cached size should be ignored, because it's in the old format. The function
+ * will try to fetch a live value, but in this case the folder doesn't actually
+ * exist on disk, so the function should fail.
+ */
+ $this->assertFalse( recurse_dirsize( $upload_dir['basedir'] . '/2/1' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * The cached size should be ignored, because it's in the old format. The function
- * will try to fetch a live value, but in this case the folder doesn't actually
- * exist on disk, so the function should fail.
- */
- $this->assertFalse( recurse_dirsize( $upload_dir['basedir'] . '/2/1' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Now that it's confirmed that old cached values aren't being returned, create the
+ * folder on disk, so that the the rest of the function can be tested.
+ */
+ wp_mkdir_p( $upload_dir['basedir'] . '/2/1' );
+ $filename = $upload_dir['basedir'] . '/2/1/this-needs-to-exist.txt';
+ file_put_contents( $filename, 'this file is 21 bytes' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Now that it's confirmed that old cached values aren't being returned, create the
- * folder on disk, so that the the rest of the function can be tested.
- */
- wp_mkdir_p( $upload_dir['basedir'] . '/2/1' );
- $filename = $upload_dir['basedir'] . '/2/1/this-needs-to-exist.txt';
- file_put_contents( $filename, 'this file is 21 bytes' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clear the dirsize cache.
+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Clear the dirsize cache.
- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the dirsize cache to our mock.
+ set_transient( 'dirsize_cache', $this->get_mock_5_5_dirsize_cache( $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the dirsize cache to our mock.
- set_transient( 'dirsize_cache', $this->get_mock_5_5_dirsize_cache( $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Now that the folder exists, the old cached value should be overwritten
+ * with the size, using the current format.
+ */
+ $this->assertSame( 21, recurse_dirsize( $upload_dir['basedir'] . '/2/1' ) );
+ $this->assertSame( 21, get_transient( 'dirsize_cache' )[ $upload_dir['basedir'] . '/2/1' ] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Now that the folder exists, the old cached value should be overwritten
- * with the size, using the current format.
- */
- $this->assertSame( 21, recurse_dirsize( $upload_dir['basedir'] . '/2/1' ) );
- $this->assertSame( 21, get_transient( 'dirsize_cache' )[ $upload_dir['basedir'] . '/2/1' ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // No cache match on non existing directory should return false.
+ $this->assertFalse( recurse_dirsize( $upload_dir['basedir'] . '/does_not_exist' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // No cache match on non existing directory should return false.
- $this->assertFalse( recurse_dirsize( $upload_dir['basedir'] . '/does_not_exist' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Cleanup.
+ $this->remove_added_uploads();
+ rmdir( $upload_dir['basedir'] . '/2/1' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Cleanup.
- $this->remove_added_uploads();
- rmdir( $upload_dir['basedir'] . '/2/1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function get_mock_5_5_dirsize_cache( $site_id ) {
+ $prefix = untrailingslashit( wp_upload_dir()['basedir'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private function get_mock_5_5_dirsize_cache( $site_id ) {
- $prefix = untrailingslashit( wp_upload_dir()['basedir'] );
-
- return array(
- "$prefix/2/2" => array( 'size' => 22 ),
- "$prefix/2/1" => array( 'size' => 21 ),
- "$prefix/2" => array( 'size' => 2 ),
- "$prefix/1/3" => array( 'size' => 13 ),
- "$prefix/1/2" => array( 'size' => 12 ),
- "$prefix/1/1" => array( 'size' => 11 ),
- "$prefix/1" => array( 'size' => 1 ),
- "$prefix/custom_directory" => array( 'size' => 42 ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return array(
+ "$prefix/2/2" => array( 'size' => 22 ),
+ "$prefix/2/1" => array( 'size' => 21 ),
+ "$prefix/2" => array( 'size' => 2 ),
+ "$prefix/1/3" => array( 'size' => 13 ),
+ "$prefix/1/2" => array( 'size' => 12 ),
+ "$prefix/1/1" => array( 'size' => 11 ),
+ "$prefix/1" => array( 'size' => 1 ),
+ "$prefix/custom_directory" => array( 'size' => 42 ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteforceSslContentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/forceSslContent.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/forceSslContent.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/forceSslContent.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,8 +5,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.9.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @group functions
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group ms-required
</ins><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-required
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::force_ssl_content
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitegetBlogDetailsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/getBlogDetails.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/getBlogDetails.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/getBlogDetails.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,235 +1,233 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @ticket 29845
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_GetBlogDetails extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29845
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_GetBlogDetails extends WP_UnitTestCase {
- protected static $network_ids;
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $network_ids;
+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$site_ids = array(
- WP_TESTS_DOMAIN . '/foo/' => array(
- 'domain' => WP_TESTS_DOMAIN,
- 'path' => '/foo/',
- ),
- 'foo.' . WP_TESTS_DOMAIN . '/' => array(
- 'domain' => 'foo.' . WP_TESTS_DOMAIN,
- 'path' => '/',
- ),
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$site_ids = array(
+ WP_TESTS_DOMAIN . '/foo/' => array(
+ 'domain' => WP_TESTS_DOMAIN,
+ 'path' => '/foo/',
+ ),
+ 'foo.' . WP_TESTS_DOMAIN . '/' => array(
+ 'domain' => 'foo.' . WP_TESTS_DOMAIN,
+ 'path' => '/',
+ ),
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
-
- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_no_arguments_returns_current_site() {
- $site = get_blog_details();
- $this->assertEquals( get_current_blog_id(), $site->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_site_name_string_subdirectory() {
- if ( is_subdomain_install() ) {
- $this->markTestSkipped( 'This test is only valid in a subdirectory configuration.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_no_arguments_returns_current_site() {
+ $site = get_blog_details();
+ $this->assertEquals( get_current_blog_id(), $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_blog_details( 'foo' );
- $this->assertEquals( self::$site_ids[ WP_TESTS_DOMAIN . '/foo/' ], $site->blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_site_name_string_subdirectory() {
+ if ( is_subdomain_install() ) {
+ $this->markTestSkipped( 'This test is only valid in a subdirectory configuration.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_site_name_string_subdomain() {
- if ( ! is_subdomain_install() ) {
- $this->markTestSkipped( 'This test is only valid in a subdomain configuration.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_blog_details( 'foo' );
+ $this->assertEquals( self::$site_ids[ WP_TESTS_DOMAIN . '/foo/' ], $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_blog_details( 'foo' );
- $this->assertEquals( self::$site_ids[ 'foo.' . WP_TESTS_DOMAIN . '/' ], $site->blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_site_name_string_subdomain() {
+ if ( ! is_subdomain_install() ) {
+ $this->markTestSkipped( 'This test is only valid in a subdomain configuration.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_invalid_site_name_string() {
- $site = get_blog_details( 'invalid' );
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_blog_details( 'foo' );
+ $this->assertEquals( self::$site_ids[ 'foo.' . WP_TESTS_DOMAIN . '/' ], $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_site_id_int() {
- $site = get_blog_details( self::$site_ids['wordpress.org/'] );
- $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_invalid_site_name_string() {
+ $site = get_blog_details( 'invalid' );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_invalid_site_id_int() {
- $site = get_blog_details( 99999 );
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_site_id_int() {
+ $site = get_blog_details( self::$site_ids['wordpress.org/'] );
+ $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_blog_id_in_fields() {
- $site = get_blog_details( array( 'blog_id' => self::$site_ids['wordpress.org/'] ) );
- $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_invalid_site_id_int() {
+ $site = get_blog_details( 99999 );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_invalid_blog_id_in_fields() {
- $site = get_blog_details( array( 'blog_id' => 88888 ) );
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_blog_id_in_fields() {
+ $site = get_blog_details( array( 'blog_id' => self::$site_ids['wordpress.org/'] ) );
+ $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_domain_and_path_in_fields() {
- $site = get_blog_details(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- )
- );
- $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_invalid_blog_id_in_fields() {
+ $site = get_blog_details( array( 'blog_id' => 88888 ) );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_domain_and_invalid_path_in_fields() {
- $site = get_blog_details(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/zxy/',
- )
- );
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_domain_and_path_in_fields() {
+ $site = get_blog_details(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ )
+ );
+ $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_path_and_invalid_domain_in_fields() {
- $site = get_blog_details(
- array(
- 'domain' => 'invalid.org',
- 'path' => '/foo/',
- )
- );
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_domain_and_invalid_path_in_fields() {
+ $site = get_blog_details(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/zxy/',
+ )
+ );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_only_domain_in_fields_subdomain() {
- if ( ! is_subdomain_install() ) {
- $this->markTestSkipped( 'This test is only valid in a subdomain configuration.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_path_and_invalid_domain_in_fields() {
+ $site = get_blog_details(
+ array(
+ 'domain' => 'invalid.org',
+ 'path' => '/foo/',
+ )
+ );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_blog_details( array( 'domain' => 'wordpress.org' ) );
- $this->assertSame( self::$site_ids['wordpress.org/'], $site->blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_only_domain_in_fields_subdomain() {
+ if ( ! is_subdomain_install() ) {
+ $this->markTestSkipped( 'This test is only valid in a subdomain configuration.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_only_domain_in_fields_subdirectory() {
- if ( is_subdomain_install() ) {
- $this->markTestSkipped( 'This test is only valid in a subdirectory configuration.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_blog_details( array( 'domain' => 'wordpress.org' ) );
+ $this->assertSame( self::$site_ids['wordpress.org/'], $site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_blog_details( array( 'domain' => 'wordpress.org' ) );
- $this->assertFalse( $site );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_only_domain_in_fields_subdirectory() {
+ if ( is_subdomain_install() ) {
+ $this->markTestSkipped( 'This test is only valid in a subdirectory configuration.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_blog_details_with_only_path_in_fields() {
- $site = get_blog_details( array( 'path' => '/foo/' ) );
- $this->assertFalse( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_blog_details( array( 'domain' => 'wordpress.org' ) );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 50391
- */
- public function test_get_blog_details_does_not_switch_to_current_blog() {
- $count = did_action( 'switch_blog' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_blog_details_with_only_path_in_fields() {
+ $site = get_blog_details( array( 'path' => '/foo/' ) );
+ $this->assertFalse( $site );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_blog_details();
- $this->assertSame( $count, did_action( 'switch_blog' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 50391
+ */
+ public function test_get_blog_details_does_not_switch_to_current_blog() {
+ $count = did_action( 'switch_blog' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_get_all
- *
- * @ticket 40228
- */
- public function test_get_blog_details_get_object_vars( $get_all ) {
- $site = get_blog_details(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- $get_all
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_blog_details();
+ $this->assertSame( $count, did_action( 'switch_blog' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = array_keys( get_object_vars( $site ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_get_all
+ *
+ * @ticket 40228
+ */
+ public function test_get_blog_details_get_object_vars( $get_all ) {
+ $site = get_blog_details(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ $get_all
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $this->get_fields( $get_all ), $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = array_keys( get_object_vars( $site ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_get_all
- *
- * @ticket 40228
- */
- public function test_get_blog_details_iterate_over_result( $get_all ) {
- $site = get_blog_details(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- $get_all
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $this->get_fields( $get_all ), $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = array();
- foreach ( $site as $key => $value ) {
- $result[] = $key;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_get_all
+ *
+ * @ticket 40228
+ */
+ public function test_get_blog_details_iterate_over_result( $get_all ) {
+ $site = get_blog_details(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ $get_all
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $this->get_fields( $get_all ), $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = array();
+ foreach ( $site as $key => $value ) {
+ $result[] = $key;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_get_all() {
- return array(
- array( false ),
- array( true ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $this->get_fields( $get_all ), $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function get_fields( $all = false ) {
- $fields = array(
- 'blog_id',
- 'domain',
- 'path',
- 'site_id',
- 'registered',
- 'last_updated',
- 'public',
- 'archived',
- 'mature',
- 'spam',
- 'deleted',
- 'lang_id',
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_get_all() {
+ return array(
+ array( false ),
+ array( true ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $all ) {
- $fields = array_merge(
- $fields,
- array(
- 'blogname',
- 'siteurl',
- 'post_count',
- 'home',
- )
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function get_fields( $all = false ) {
+ $fields = array(
+ 'blog_id',
+ 'domain',
+ 'path',
+ 'site_id',
+ 'registered',
+ 'last_updated',
+ 'public',
+ 'archived',
+ 'mature',
+ 'spam',
+ 'deleted',
+ 'lang_id',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $fields;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $all ) {
+ $fields = array_merge(
+ $fields,
+ array(
+ 'blogname',
+ 'siteurl',
+ 'post_count',
+ 'home',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ return $fields;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitegetIdFromBlognamephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/getIdFromBlogname.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/getIdFromBlogname.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/getIdFromBlogname.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,141 +1,140 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
- /**
- * Test get_id_from_blogname() in multisite.
- *
- * @group blogname
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_GetIdFromBlogname extends WP_UnitTestCase {
- protected static $network_ids;
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Test get_id_from_blogname() in multisite.
+ *
+ * @group blogname
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_GetIdFromBlogname extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$network_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'www.wordpress.net/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $network_ids;
+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$network_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'www.wordpress.net/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$site_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'foo.wordpress.org/' => array(
- 'domain' => 'foo.wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'wordpress.org/foo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'www.wordpress.net/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/',
- 'network_id' => self::$network_ids['www.wordpress.net/'],
- ),
- 'foo.wordpress.net/' => array(
- 'domain' => 'foo.wordpress.net',
- 'path' => '/',
- 'network_id' => self::$network_ids['www.wordpress.net/'],
- ),
- 'www.wordpress.net/foo/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['www.wordpress.net/'],
- ),
- );
-
- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$site_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'foo.wordpress.org/' => array(
+ 'domain' => 'foo.wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'wordpress.org/foo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'www.wordpress.net/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['www.wordpress.net/'],
+ ),
+ 'foo.wordpress.net/' => array(
+ 'domain' => 'foo.wordpress.net',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['www.wordpress.net/'],
+ ),
+ 'www.wordpress.net/foo/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['www.wordpress.net/'],
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
+ }
+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as $id ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 34450
- */
- public function test_get_id_from_blogname_no_www() {
- global $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as $id ) {
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_network = $current_site;
- $current_site = get_network( self::$network_ids['wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_subdomain_install() ) {
- $expected = self::$site_ids['foo.wordpress.org/'];
- } else {
- $expected = self::$site_ids['wordpress.org/foo/'];
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 34450
+ */
+ public function test_get_id_from_blogname_no_www() {
+ global $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_id_from_blogname( 'foo' );
- $current_site = $original_network;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_network = $current_site;
+ $current_site = get_network( self::$network_ids['wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_subdomain_install() ) {
+ $expected = self::$site_ids['foo.wordpress.org/'];
+ } else {
+ $expected = self::$site_ids['wordpress.org/foo/'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 34450
- */
- public function test_get_id_from_blogname_www() {
- global $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_id_from_blogname( 'foo' );
+ $current_site = $original_network;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_network = $current_site;
- $current_site = get_network( self::$network_ids['www.wordpress.net/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_subdomain_install() ) {
- $expected = self::$site_ids['foo.wordpress.net/'];
- } else {
- $expected = self::$site_ids['www.wordpress.net/foo/'];
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 34450
+ */
+ public function test_get_id_from_blogname_www() {
+ global $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_id_from_blogname( 'foo' );
- $current_site = $original_network;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_network = $current_site;
+ $current_site = get_network( self::$network_ids['www.wordpress.net/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_subdomain_install() ) {
+ $expected = self::$site_ids['foo.wordpress.net/'];
+ } else {
+ $expected = self::$site_ids['www.wordpress.net/foo/'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_id_from_blogname_invalid_slug() {
- global $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_id_from_blogname( 'foo' );
+ $current_site = $original_network;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_network = $current_site;
- $current_site = get_network( self::$network_ids['wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_id_from_blogname( 'bar' );
- $current_site = $original_network;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_id_from_blogname_invalid_slug() {
+ global $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_network = $current_site;
+ $current_site = get_network( self::$network_ids['wordpress.org/'] );
+
+ $result = get_id_from_blogname( 'bar' );
+ $current_site = $original_network;
+
+ $this->assertNull( $result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitegetMainSiteIdphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/getMainSiteId.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/getMainSiteId.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/getMainSiteId.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,190 +1,188 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests for the get_main_site_id() function.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_GetMainSiteId extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests for the get_main_site_id() function.
- *
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_GetMainSiteId extends WP_UnitTestCase {
- protected static $network_ids;
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $network_ids;
+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$network_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'wp.org/' => array(
- 'domain' => 'wp.org',
- 'path' => '/',
- ), // A network with no sites.
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$network_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'wp.org/' => array(
+ 'domain' => 'wp.org',
+ 'path' => '/',
+ ), // A network with no sites.
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
+ }
+ unset( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$site_ids = array(
- 'www.w.org/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/',
- ),
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'wordpress.org/foo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$site_ids = array(
+ 'www.w.org/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/',
+ ),
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'wordpress.org/foo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as $id ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
- }
-
- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as $id ) {
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_on_main_site_returns_self() {
- $this->assertSame( get_current_blog_id(), get_main_site_id() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_returns_main_site_in_switched_context() {
- $main_site_id = get_current_blog_id();
- $other_site_id = self::$site_ids['www.w.org/'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_on_main_site_returns_self() {
+ $this->assertSame( get_current_blog_id(), get_main_site_id() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $other_site_id );
- $result = get_main_site_id();
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_returns_main_site_in_switched_context() {
+ $main_site_id = get_current_blog_id();
+ $other_site_id = self::$site_ids['www.w.org/'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $main_site_id, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $other_site_id );
+ $result = get_main_site_id();
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 55802
- */
- public function test_get_main_site_id_with_different_network_cache_id() {
- $this->assertSame( self::$site_ids['wordpress.org/'], get_main_site_id( self::$network_ids['wordpress.org/'] ), 'Main blog id needs to match blog id of wordpress.org/' );
- $this->assertSame( self::$site_ids['wordpress.org/'], (int) get_network_option( self::$network_ids['wordpress.org/'], 'main_site' ), 'Network option needs to match blog id of wordpress.org/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $main_site_id, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, get_main_site_id( self::$network_ids['wp.org/'] ), 'Main blog id should not be found' );
- $this->assertSame( 0, (int) get_network_option( self::$network_ids['wp.org/'], 'main_site' ), 'Network option should not be found' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55802
+ */
+ public function test_get_main_site_id_with_different_network_cache_id() {
+ $this->assertSame( self::$site_ids['wordpress.org/'], get_main_site_id( self::$network_ids['wordpress.org/'] ), 'Main blog id needs to match blog id of wordpress.org/' );
+ $this->assertSame( self::$site_ids['wordpress.org/'], (int) get_network_option( self::$network_ids['wordpress.org/'], 'main_site' ), 'Network option needs to match blog id of wordpress.org/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_with_different_network_returns_correct_id() {
- $this->assertSame( self::$site_ids['wordpress.org/'], get_main_site_id( self::$network_ids['wordpress.org/'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 0, get_main_site_id( self::$network_ids['wp.org/'] ), 'Main blog id should not be found' );
+ $this->assertSame( 0, (int) get_network_option( self::$network_ids['wp.org/'], 'main_site' ), 'Network option should not be found' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_on_network_without_site_returns_0() {
- $this->assertSame( 0, get_main_site_id( self::$network_ids['wp.org/'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_with_different_network_returns_correct_id() {
+ $this->assertSame( self::$site_ids['wordpress.org/'], get_main_site_id( self::$network_ids['wordpress.org/'] ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_on_invalid_network_returns_0() {
- $this->assertSame( 0, get_main_site_id( 333 ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_on_network_without_site_returns_0() {
+ $this->assertSame( 0, get_main_site_id( self::$network_ids['wp.org/'] ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_filtered() {
- add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id' ) );
- $result = get_main_site_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_on_invalid_network_returns_0() {
+ $this->assertSame( 0, get_main_site_id( 333 ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 333, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_filtered() {
+ add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id' ) );
+ $result = get_main_site_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_get_main_site_id() {
- return 333;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 333, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_get_main_site_id_filtered_depending_on_network() {
- add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id_depending_on_network' ), 10, 2 );
- $result = get_main_site_id( self::$network_ids['wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_get_main_site_id() {
+ return 333;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 333, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_get_main_site_id_filtered_depending_on_network() {
+ add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id_depending_on_network' ), 10, 2 );
+ $result = get_main_site_id( self::$network_ids['wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_get_main_site_id_depending_on_network( $main_site_id, $network ) {
- // Override main site ID for a specific network for the test.
- if ( $network->id === (int) self::$network_ids['wordpress.org/'] ) {
- return 333;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 333, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $main_site_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_get_main_site_id_depending_on_network( $main_site_id, $network ) {
+ // Override main site ID for a specific network for the test.
+ if ( $network->id === (int) self::$network_ids['wordpress.org/'] ) {
+ return 333;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41936
- */
- public function test_get_main_site_id_with_property_value() {
- global $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $main_site_id;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_main_site_id = $current_site->blog_id;
- $current_site->blog_id = '123';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41936
+ */
+ public function test_get_main_site_id_with_property_value() {
+ global $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_main_site_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_main_site_id = $current_site->blog_id;
+ $current_site->blog_id = '123';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $current_site->blog_id = $original_main_site_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_main_site_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 123, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $current_site->blog_id = $original_main_site_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41936
- */
- public function test_get_main_site_id_filtered_with_property_value() {
- global $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 123, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_main_site_id = $current_site->blog_id;
- $current_site->blog_id = '123';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41936
+ */
+ public function test_get_main_site_id_filtered_with_property_value() {
+ global $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id' ) );
- $result = get_main_site_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_main_site_id = $current_site->blog_id;
+ $current_site->blog_id = '123';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $current_site->blog_id = $original_main_site_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id' ) );
+ $result = get_main_site_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 333, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $current_site->blog_id = $original_main_site_id;
+
+ $this->assertSame( 333, $result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitegetSitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/getSite.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/getSite.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/getSite.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,52 +1,51 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
- /**
- * Test get_site() wrapper of WP_Site in multisite.
- *
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_GetSite extends WP_UnitTestCase {
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Test get_site() wrapper of WP_Site in multisite.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_GetSite extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$site_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'wordpress.org/foo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- ),
- 'wordpress.org/foo/bar/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/bar/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$site_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'wordpress.org/foo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ ),
+ 'wordpress.org/foo/bar/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/bar/',
+ ),
+ );
+
+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
-
- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_site_in_switched_state_returns_switched_site() {
- switch_to_blog( self::$site_ids['wordpress.org/foo/'] );
- $site = get_site();
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( self::$site_ids['wordpress.org/foo/'], $site->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_site_in_switched_state_returns_switched_site() {
+ switch_to_blog( self::$site_ids['wordpress.org/foo/'] );
+ $site = get_site();
+ restore_current_blog();
+
+ $this->assertSame( self::$site_ids['wordpress.org/foo/'], $site->id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitegetSpaceAllowedphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,88 +1,85 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to `get_space_allowed()` in multisite.
+ *
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_GetSpaceAllowed extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Tests specific to `get_space_allowed()` in multisite.
- *
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * When no option exists for the site or the network, a fallback of
+ * 100 is expected.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_GetSpaceAllowed extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_space_allowed_default() {
+ delete_option( 'blog_upload_space' );
+ delete_site_option( 'blog_upload_space' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When no option exists for the site or the network, a fallback of
- * 100 is expected.
- */
- public function test_get_space_allowed_default() {
- delete_option( 'blog_upload_space' );
- delete_site_option( 'blog_upload_space' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 100, get_space_allowed() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 100, get_space_allowed() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * If an individual site's option is not available, the default network
+ * level option is used as a fallback.
+ */
+ public function test_get_space_allowed_no_site_option_fallback_to_network_option() {
+ delete_site_option( 'blog_upload_space' );
+ update_site_option( 'blog_upload_space', 200 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * If an individual site's option is not available, the default network
- * level option is used as a fallback.
- */
- public function test_get_space_allowed_no_site_option_fallback_to_network_option() {
- delete_site_option( 'blog_upload_space' );
- update_site_option( 'blog_upload_space', 200 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 200, get_space_allowed() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 200, get_space_allowed() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_blog_upload_space
+ *
+ * @param mixed $site_option Option to assign to the site's `blog_upload_space`.
+ * @param mixed $network_option Option to assign to the network's `blog_upload_space`.
+ * @param int $expected Expected return value.
+ */
+ public function test_get_space_allowed( $site_option, $network_option, $expected ) {
+ update_option( 'blog_upload_space', $site_option );
+ update_site_option( 'blog_upload_space', $network_option );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_blog_upload_space
- *
- * @param mixed $site_option Option to assign to the site's `blog_upload_space`.
- * @param mixed $network_option Option to assign to the network's `blog_upload_space`.
- * @param int $expected Expected return value.
- */
- public function test_get_space_allowed( $site_option, $network_option, $expected ) {
- update_option( 'blog_upload_space', $site_option );
- update_site_option( 'blog_upload_space', $network_option );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, get_space_allowed() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_space_allowed() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_blog_upload_space() {
+ return array(
+ // A valid site option will be preferred over a network option.
+ array( 111, 200, 111 ),
+ array( -1, 200, -1 ),
+ array( 222, 0, 222 ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_blog_upload_space() {
- return array(
- // A valid site option will be preferred over a network option.
- array( 111, 200, 111 ),
- array( -1, 200, -1 ),
- array( 222, 0, 222 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Non-numeric site options should result in a fallback to the network option.
+ array( '', 333, 333 ),
+ array( false, 444, 444 ),
+ array( 'NAN', 555, 555 ),
+ array( false, -10, -10 ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Non-numeric site options should result in a fallback to the network option.
- array( '', 333, 333 ),
- array( false, 444, 444 ),
- array( 'NAN', 555, 555 ),
- array( false, -10, -10 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If neither network or site options are valid, fallback to the default.
+ array( false, false, 100 ),
+ array( 'NAN', 'NAN', 100 ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If neither network or site options are valid, fallback to the default.
- array( false, false, 100 ),
- array( 'NAN', 'NAN', 100 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // These effectively disable uploads.
+ array( 0, 666, 0 ),
+ array( false, 0, 0 ),
+ array( 'NAN', 0, 0 ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // These effectively disable uploads.
- array( 0, 666, 0 ),
- array( false, 0, 0 ),
- array( 'NAN', 0, 0 ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_space_allowed_filtered() {
+ update_option( 'blog_upload_space', 777 );
+ update_site_option( 'blog_upload_space', 888 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_space_allowed_filtered() {
- update_option( 'blog_upload_space', 777 );
- update_site_option( 'blog_upload_space', 888 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'get_space_allowed', array( $this, '_filter_space_allowed' ) );
+ $space_allowed = get_space_allowed();
+ remove_filter( 'get_space_allowed', array( $this, '_filter_space_allowed' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'get_space_allowed', array( $this, '_filter_space_allowed' ) );
- $space_allowed = get_space_allowed();
- remove_filter( 'get_space_allowed', array( $this, '_filter_space_allowed' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 999, $space_allowed );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 999, $space_allowed );
- }
-
- public function _filter_space_allowed() {
- return 999;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_space_allowed() {
+ return 999;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitegetSpaceUsedphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/getSpaceUsed.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/getSpaceUsed.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/getSpaceUsed.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,91 +1,89 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group multisite
+ * @covers ::get_space_used
+ */
+class Tests_Multisite_GetSpaceUsed extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group multisite
- * @covers ::get_space_used
- */
- class Tests_Multisite_GetSpaceUsed extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_space_used_switched_site() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_space_used_switched_site() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Our comparison of space relies on an initial value of 0. If a previous test has failed or if the
+ // src directory already contains a content directory with site content, then the initial expectation
+ // will be polluted. We create sites until an empty one is available.
+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Our comparison of space relies on an initial value of 0. If a previous test has failed or if the
- // src directory already contains a content directory with site content, then the initial expectation
- // will be polluted. We create sites until an empty one is available.
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Upload a file to the new site.
+ $filename = __FUNCTION__ . '.jpg';
+ $contents = __FUNCTION__ . '_contents';
+ $file = wp_upload_bits( $filename, null, $contents );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Upload a file to the new site.
- $filename = __FUNCTION__ . '.jpg';
- $contents = __FUNCTION__ . '_contents';
- $file = wp_upload_bits( $filename, null, $contents );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // get_space_used() is measures in MB, get the size of the new file in MB.
+ $size = filesize( $file['file'] ) / 1024 / 1024;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // get_space_used() is measures in MB, get the size of the new file in MB.
- $size = filesize( $file['file'] ) / 1024 / 1024;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $size, get_space_used() );
+ $upload_dir = wp_upload_dir();
+ $this->remove_added_uploads();
+ $this->delete_folders( $upload_dir['basedir'] );
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $size, get_space_used() );
- $upload_dir = wp_upload_dir();
- $this->remove_added_uploads();
- $this->delete_folders( $upload_dir['basedir'] );
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Directories of sub sites on a network should not count against the same spaced used total for
+ * the main site.
+ */
+ public function test_get_space_used_main_site() {
+ $space_used = get_space_used();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Directories of sub sites on a network should not count against the same spaced used total for
- * the main site.
- */
- public function test_get_space_used_main_site() {
- $space_used = get_space_used();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // We don't rely on an initial value of 0 for space used, but should have a clean space available
+ // so that we can remove any uploaded files and directories without concern of a conflict with
+ // existing content directories in src.
+ while ( 0 !== get_space_used() ) {
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px"> $blog_id = self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $blog_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We don't rely on an initial value of 0 for space used, but should have a clean space available
- // so that we can remove any uploaded files and directories without concern of a conflict with
- // existing content directories in src.
- while ( 0 !== get_space_used() ) {
- restore_current_blog();
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Upload a file to the new site.
+ $filename = __FUNCTION__ . '.jpg';
+ $contents = __FUNCTION__ . '_contents';
+ wp_upload_bits( $filename, null, $contents );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Upload a file to the new site.
- $filename = __FUNCTION__ . '.jpg';
- $contents = __FUNCTION__ . '_contents';
- wp_upload_bits( $filename, null, $contents );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_transient( 'dirsize_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_transient( 'dirsize_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $space_used, get_space_used() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $space_used, get_space_used() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Switch back to the new site to remove the uploaded file.
+ switch_to_blog( $blog_id );
+ $upload_dir = wp_upload_dir();
+ $this->remove_added_uploads();
+ $this->delete_folders( $upload_dir['basedir'] );
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Switch back to the new site to remove the uploaded file.
- switch_to_blog( $blog_id );
- $upload_dir = wp_upload_dir();
- $this->remove_added_uploads();
- $this->delete_folders( $upload_dir['basedir'] );
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_space_used_pre_get_spaced_used_filter() {
+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_space_used_pre_get_spaced_used_filter() {
- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 300, get_space_used() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 300, get_space_used() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used' ) );
- }
-
- public function filter_space_used() {
- return 300;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_space_used() {
+ return 300;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteisEmailAddressUnsafephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/isEmailAddressUnsafe.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/isEmailAddressUnsafe.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/isEmailAddressUnsafe.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,140 +1,138 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_IsEmailAddressUnsafe extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_string_domain_list_should_be_split_on_line_breaks() {
+ update_site_option( 'banned_email_domains', "foo.com\nbar.org\nbaz.gov" );
+ $this->assertTrue( is_email_address_unsafe( 'foo@bar.org' ) );
+ $this->assertFalse( is_email_address_unsafe( 'foo@example.org' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @dataProvider data_unsafe
+ * @ticket 25046
+ * @ticket 21570
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_IsEmailAddressUnsafe extends WP_UnitTestCase {
- public function test_string_domain_list_should_be_split_on_line_breaks() {
- update_site_option( 'banned_email_domains', "foo.com\nbar.org\nbaz.gov" );
- $this->assertTrue( is_email_address_unsafe( 'foo@bar.org' ) );
- $this->assertFalse( is_email_address_unsafe( 'foo@example.org' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_unsafe_emails( $banned, $email ) {
+ update_site_option( 'banned_email_domains', $banned );
+ $this->assertTrue( is_email_address_unsafe( $email ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_unsafe
- * @ticket 25046
- * @ticket 21570
- */
- public function test_unsafe_emails( $banned, $email ) {
- update_site_option( 'banned_email_domains', $banned );
- $this->assertTrue( is_email_address_unsafe( $email ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_safe
+ * @ticket 25046
+ * @ticket 21570
+ */
+ public function test_safe_emails( $banned, $email ) {
+ update_site_option( 'banned_email_domains', $banned );
+ $this->assertFalse( is_email_address_unsafe( $email ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_safe
- * @ticket 25046
- * @ticket 21570
- */
- public function test_safe_emails( $banned, $email ) {
- update_site_option( 'banned_email_domains', $banned );
- $this->assertFalse( is_email_address_unsafe( $email ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_unsafe() {
+ return array(
+ // 25046
+ 'case_insensitive_1' => array(
+ array( 'baR.com' ),
+ 'test@Bar.com',
+ ),
+ 'case_insensitive_2' => array(
+ array( 'baR.com' ),
+ 'tEst@bar.com',
+ ),
+ 'case_insensitive_3' => array(
+ array( 'barfoo.COM' ),
+ 'test@barFoo.com',
+ ),
+ 'case_insensitive_4' => array(
+ array( 'baR.com' ),
+ 'tEst@foo.bar.com',
+ ),
+ 'case_insensitive_5' => array(
+ array( 'BAZ.com' ),
+ 'test@baz.Com',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_unsafe() {
- return array(
- // 25046
- 'case_insensitive_1' => array(
- array( 'baR.com' ),
- 'test@Bar.com',
- ),
- 'case_insensitive_2' => array(
- array( 'baR.com' ),
- 'tEst@bar.com',
- ),
- 'case_insensitive_3' => array(
- array( 'barfoo.COM' ),
- 'test@barFoo.com',
- ),
- 'case_insensitive_4' => array(
- array( 'baR.com' ),
- 'tEst@foo.bar.com',
- ),
- 'case_insensitive_5' => array(
- array( 'BAZ.com' ),
- 'test@baz.Com',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // 21570
+ array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@bar.com',
+ ),
+ 'subdomain_1' => array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@foo.bar.com',
+ ),
+ array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@foo.co',
+ ),
+ 'subdomain_2' => array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@subdomain.foo.co',
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // 21570
- array(
- array( 'bar.com', 'foo.co' ),
- 'test@bar.com',
- ),
- 'subdomain_1' => array(
- array( 'bar.com', 'foo.co' ),
- 'test@foo.bar.com',
- ),
- array(
- array( 'bar.com', 'foo.co' ),
- 'test@foo.co',
- ),
- 'subdomain_2' => array(
- array( 'bar.com', 'foo.co' ),
- 'test@subdomain.foo.co',
- ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_safe() {
+ return array(
+ // 25046
+ array(
+ array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
+ 'test@Foobar.com',
+ ),
+ array(
+ array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
+ 'test@Foo-bar.com',
+ ),
+ array(
+ array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
+ 'tEst@foobar.com',
+ ),
+ array(
+ array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
+ 'test@Subdomain.Foo.com',
+ ),
+ array(
+ array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
+ 'test@feeBAz.com',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_safe() {
- return array(
- // 25046
- array(
- array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
- 'test@Foobar.com',
- ),
- array(
- array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
- 'test@Foo-bar.com',
- ),
- array(
- array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
- 'tEst@foobar.com',
- ),
- array(
- array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
- 'test@Subdomain.Foo.com',
- ),
- array(
- array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ),
- 'test@feeBAz.com',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // 21570
+ array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@foobar.com',
+ ),
+ array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@foo-bar.com',
+ ),
+ array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@foo.com',
+ ),
+ array(
+ array( 'bar.com', 'foo.co' ),
+ 'test@subdomain.foo.com',
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // 21570
- array(
- array( 'bar.com', 'foo.co' ),
- 'test@foobar.com',
- ),
- array(
- array( 'bar.com', 'foo.co' ),
- 'test@foo-bar.com',
- ),
- array(
- array( 'bar.com', 'foo.co' ),
- 'test@foo.com',
- ),
- array(
- array( 'bar.com', 'foo.co' ),
- 'test@subdomain.foo.com',
- ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_email_with_only_top_level_domain_returns_safe() {
+ update_site_option( 'banned_email_domains', 'bar.com' );
+ $safe = is_email_address_unsafe( 'email@localhost' );
+ delete_site_option( 'banned_email_domains' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_email_with_only_top_level_domain_returns_safe() {
- update_site_option( 'banned_email_domains', 'bar.com' );
- $safe = is_email_address_unsafe( 'email@localhost' );
- delete_site_option( 'banned_email_domains' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $safe );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $safe );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_invalid_email_without_domain_returns_safe() {
+ update_site_option( 'banned_email_domains', 'bar.com' );
+ $safe = is_email_address_unsafe( 'invalid-email' );
+ delete_site_option( 'bar.com' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_invalid_email_without_domain_returns_safe() {
- update_site_option( 'banned_email_domains', 'bar.com' );
- $safe = is_email_address_unsafe( 'invalid-email' );
- delete_site_option( 'bar.com' );
-
- $this->assertFalse( $safe );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $safe );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteisUploadSpaceAvailablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,99 +1,96 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to `is_upload_space_available()` in multisite.
+ *
+ * These tests filter `pre_get_space_used` so that we can ignore the local
+ * environment. Tests for `get_space_used()` are handled elsewhere.
+ *
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_IsUploadSpaceAvailable extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function set_up() {
+ parent::set_up();
+ update_site_option( 'upload_space_check_disabled', false );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Tests specific to `is_upload_space_available()` in multisite.
- *
- * These tests filter `pre_get_space_used` so that we can ignore the local
- * environment. Tests for `get_space_used()` are handled elsewhere.
- *
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * A default of 100MB is used when no `blog_upload_space` option
+ * exists at the site or network level.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_IsUploadSpaceAvailable extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_upload_space_available_default() {
+ delete_option( 'blog_upload_space' );
+ delete_site_option( 'blog_upload_space' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function set_up() {
- parent::set_up();
- update_site_option( 'upload_space_check_disabled', false );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
+ $available = is_upload_space_available();
+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * A default of 100MB is used when no `blog_upload_space` option
- * exists at the site or network level.
- */
- public function test_is_upload_space_available_default() {
- delete_option( 'blog_upload_space' );
- delete_site_option( 'blog_upload_space' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $available );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
- $available = is_upload_space_available();
- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_upload_space_available_check_disabled() {
+ update_site_option( 'blog_upload_space', 10 );
+ update_site_option( 'upload_space_check_disabled', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $available );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
+ $available = is_upload_space_available();
+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_upload_space_available_check_disabled() {
- update_site_option( 'blog_upload_space', 10 );
- update_site_option( 'upload_space_check_disabled', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $available );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
- $available = is_upload_space_available();
- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_upload_space_available_space_used_is_less_then_allowed() {
+ update_option( 'blog_upload_space', 350 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $available );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
+ $available = is_upload_space_available();
+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_upload_space_available_space_used_is_less_then_allowed() {
- update_option( 'blog_upload_space', 350 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $available );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
- $available = is_upload_space_available();
- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_upload_space_available_space_used_is_more_than_allowed() {
+ update_option( 'blog_upload_space', 350 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $available );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
+ $available = is_upload_space_available();
+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_upload_space_available_space_used_is_more_than_allowed() {
- update_option( 'blog_upload_space', 350 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $available );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
- $available = is_upload_space_available();
- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_large' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * More comprehensive testing a 0 condition is handled in the tests
+ * for `get_space_allowed()`. We cover one scenario here.
+ */
+ public function test_is_upload_space_available_upload_space_0_defaults_to_100() {
+ update_option( 'blog_upload_space', 0 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $available );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
+ $available = is_upload_space_available();
+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * More comprehensive testing a 0 condition is handled in the tests
- * for `get_space_allowed()`. We cover one scenario here.
- */
- public function test_is_upload_space_available_upload_space_0_defaults_to_100() {
- update_option( 'blog_upload_space', 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $available );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
- $available = is_upload_space_available();
- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_upload_space_available_upload_space_negative() {
+ update_site_option( 'blog_upload_space', -1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $available );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
+ $available = is_upload_space_available();
+ remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_upload_space_available_upload_space_negative() {
- update_site_option( 'blog_upload_space', -1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $available );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
- $available = is_upload_space_available();
- remove_filter( 'pre_get_space_used', array( $this, 'filter_space_used_small' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_space_used_large() {
+ return 10000000;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $available );
- }
-
- public function filter_space_used_large() {
- return 10000000;
- }
-
- public function filter_space_used_small() {
- return 10;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_space_used_small() {
+ return 10;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitemsFilesRewritingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/msFilesRewriting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/msFilesRewriting.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/msFilesRewriting.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,80 +1,77 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to the ms_files_rewriting option in multisite.
+ *
+ * The ms-files group tag must be used for these tests to run as the constants
+ * set in ms_upload_constants() conflict with a non ms-files configuration.
+ *
+ * @group ms-files
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_msFilesRewriting extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to the ms_files_rewriting option in multisite.
- *
- * The ms-files group tag must be used for these tests to run as the constants
- * set in ms_upload_constants() conflict with a non ms-files configuration.
- *
- * @group ms-files
- * @group multisite
- */
- class Tests_Multisite_msFilesRewriting extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function set_up() {
+ parent::set_up();
+ update_site_option( 'ms_files_rewriting', 1 );
+ ms_upload_constants();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function set_up() {
- parent::set_up();
- update_site_option( 'ms_files_rewriting', 1 );
- ms_upload_constants();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_switch_upload_dir() {
+ $this->assertTrue( is_main_site() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_switch_upload_dir() {
- $this->assertTrue( is_main_site() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_current_site();
+ $date = date_format( date_create( 'now' ), 'Y/m' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_current_site();
- $date = date_format( date_create( 'now' ), 'Y/m' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) );
+ $info = wp_upload_dir();
+ $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . $date, $info['url'] );
+ $this->assertSame( ABSPATH . 'wp-content/uploads/' . $date, $info['path'] );
+ $this->assertSame( '/' . $date, $info['subdir'] );
+ $this->assertFalse( $info['error'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
- $blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) );
- $info = wp_upload_dir();
- $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . $date, $info['url'] );
- $this->assertSame( ABSPATH . 'wp-content/uploads/' . $date, $info['path'] );
- $this->assertSame( '/' . $date, $info['subdir'] );
- $this->assertFalse( $info['error'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id2 );
+ $info2 = wp_upload_dir();
+ $this->assertNotEquals( $info, $info2 );
+ $this->assertSame( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . $date, $info2['url'] );
+ $this->assertSame( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . $date, $info2['path'] );
+ $this->assertSame( '/' . $date, $info2['subdir'] );
+ $this->assertFalse( $info2['error'] );
+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id2 );
- $info2 = wp_upload_dir();
- $this->assertNotEquals( $info, $info2 );
- $this->assertSame( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . $date, $info2['url'] );
- $this->assertSame( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . $date, $info2['path'] );
- $this->assertSame( '/' . $date, $info2['subdir'] );
- $this->assertFalse( $info2['error'] );
- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a site is deleted with wpmu_delete_blog(), only the files associated with
+ * that site should be removed. When wpmu_delete_blog() is run a second time, nothing
+ * should change with upload directories.
+ */
+ public function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
+ $filename = __FUNCTION__ . '.jpg';
+ $contents = __FUNCTION__ . '_contents';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a site is deleted with wpmu_delete_blog(), only the files associated with
- * that site should be removed. When wpmu_delete_blog() is run a second time, nothing
- * should change with upload directories.
- */
- public function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
- $filename = __FUNCTION__ . '.jpg';
- $contents = __FUNCTION__ . '_contents';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Upload a file to the main site on the network.
+ $file1 = wp_upload_bits( $filename, null, $contents );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Upload a file to the main site on the network.
- $file1 = wp_upload_bits( $filename, null, $contents );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
+ $file2 = wp_upload_bits( $filename, null, $contents );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
- $file2 = wp_upload_bits( $filename, null, $contents );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The file on the main site should still exist. The file on the deleted site should not.
+ $this->assertFileExists( $file1['file'] );
+ $this->assertFileDoesNotExist( $file2['file'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The file on the main site should still exist. The file on the deleted site should not.
- $this->assertFileExists( $file1['file'] );
- $this->assertFileDoesNotExist( $file2['file'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The file on the main site should still exist. The file on the deleted site should not.
+ $this->assertFileExists( $file1['file'] );
+ $this->assertFileDoesNotExist( $file2['file'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The file on the main site should still exist. The file on the deleted site should not.
- $this->assertFileExists( $file1['file'] );
- $this->assertFileDoesNotExist( $file2['file'] );
-
- unlink( $file1['file'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unlink( $file1['file'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitenetworkphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/network.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/network.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/network.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,694 +1,692 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to networks in multisite.
+ *
+ * @group ms-network
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_Network extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to networks in multisite.
- *
- * @group ms-network
- * @group multisite
- */
- class Tests_Multisite_Network extends WP_UnitTestCase {
- protected $plugin_hook_count = 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $plugin_hook_count = 0;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected static $different_network_id;
- protected static $different_site_ids = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $different_network_id;
+ protected static $different_site_ids = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function tear_down() {
- global $current_site;
- $current_site->id = 1;
- parent::tear_down();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function tear_down() {
+ global $current_site;
+ $current_site->id = 1;
+ parent::tear_down();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$different_network_id = $factory->network->create(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$different_network_id = $factory->network->create(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sites = array(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- 'network_id' => self::$different_network_id,
- ),
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$different_network_id,
- ),
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/bar/',
- 'network_id' => self::$different_network_id,
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sites = array(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$different_network_id,
+ ),
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$different_network_id,
+ ),
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/bar/',
+ 'network_id' => self::$different_network_id,
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $sites as $site ) {
- self::$different_site_ids[] = $factory->blog->create( $site );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $sites as $site ) {
+ self::$different_site_ids[] = $factory->blog->create( $site );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$different_site_ids as $id ) {
- wp_delete_site( $id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$different_site_ids as $id ) {
+ wp_delete_site( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", self::$different_network_id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", self::$different_network_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", self::$different_network_id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", self::$different_network_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_site_counts();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * By default, only one network exists and has a network ID of 1.
- */
- public function test_get_main_network_id_default() {
- $this->assertSame( 1, get_main_network_id() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * By default, only one network exists and has a network ID of 1.
+ */
+ public function test_get_main_network_id_default() {
+ $this->assertSame( 1, get_main_network_id() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * If a second network is created, network ID 1 should still be returned
- * as the main network ID.
- */
- public function test_get_main_network_id_two_networks() {
- self::factory()->network->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * If a second network is created, network ID 1 should still be returned
+ * as the main network ID.
+ */
+ public function test_get_main_network_id_two_networks() {
+ self::factory()->network->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, get_main_network_id() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, get_main_network_id() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the `$current_site` global is populated with another network, the
- * main network should still return as 1.
- */
- public function test_get_main_network_id_after_network_switch() {
- global $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the `$current_site` global is populated with another network, the
+ * main network should still return as 1.
+ */
+ public function test_get_main_network_id_after_network_switch() {
+ global $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = self::factory()->network->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = self::factory()->network->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $current_site->id = (int) $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $current_site->id = (int) $id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, get_main_network_id() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, get_main_network_id() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the first network is removed, the next should return as the main
- * network ID.
- *
- * @todo In the future, we'll have a smarter way of deleting a network. For now,
- * fake the process with UPDATE queries.
- */
- public function test_get_main_network_id_after_network_delete() {
- global $wpdb, $current_site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the first network is removed, the next should return as the main
+ * network ID.
+ *
+ * @todo In the future, we'll have a smarter way of deleting a network. For now,
+ * fake the process with UPDATE queries.
+ */
+ public function test_get_main_network_id_after_network_delete() {
+ global $wpdb, $current_site;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $temp_id = self::$different_network_id + 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $temp_id = self::$different_network_id + 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $current_site->id = (int) self::$different_network_id;
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=%d WHERE id=1", $temp_id ) );
- $main_network_id = get_main_network_id();
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=1 WHERE id=%d", $temp_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $current_site->id = (int) self::$different_network_id;
+ $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=%d WHERE id=1", $temp_id ) );
+ $main_network_id = get_main_network_id();
+ $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=1 WHERE id=%d", $temp_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( self::$different_network_id, $main_network_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$different_network_id, $main_network_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_main_network_id_filtered() {
- add_filter( 'get_main_network_id', array( $this, 'get_main_network_id' ) );
- $this->assertSame( 3, get_main_network_id() );
- remove_filter( 'get_main_network_id', array( $this, 'get_main_network_id' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_main_network_id_filtered() {
+ add_filter( 'get_main_network_id', array( $this, 'get_main_network_id' ) );
+ $this->assertSame( 3, get_main_network_id() );
+ remove_filter( 'get_main_network_id', array( $this, 'get_main_network_id' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function get_main_network_id() {
- return 3;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_main_network_id() {
+ return 3;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests that the `WP_Network::$id` property is an integer.
- *
- * @ticket 37050
- *
- * @covers WP_Network::__get
- */
- public function test_wp_network_object_id_property_is_int() {
- $id = self::factory()->network->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests that the `WP_Network::$id` property is an integer.
+ *
+ * @ticket 37050
+ *
+ * @covers WP_Network::__get
+ */
+ public function test_wp_network_object_id_property_is_int() {
+ $id = self::factory()->network->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network = WP_Network::get_instance( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network = WP_Network::get_instance( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( (int) $id, $network->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( (int) $id, $network->id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests that the `WP_Network::$id` property is stored as an integer.
- *
- * Uses reflection to access the private property.
- * Differs from using the public getter method, which casts to an integer.
- *
- * @ticket 62035
- *
- * @covers WP_Network::__construct
- */
- public function test_wp_network_object_id_property_stored_as_int() {
- $id = self::factory()->network->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests that the `WP_Network::$id` property is stored as an integer.
+ *
+ * Uses reflection to access the private property.
+ * Differs from using the public getter method, which casts to an integer.
+ *
+ * @ticket 62035
+ *
+ * @covers WP_Network::__construct
+ */
+ public function test_wp_network_object_id_property_stored_as_int() {
+ $id = self::factory()->network->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network = WP_Network::get_instance( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network = WP_Network::get_instance( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $reflection = new ReflectionObject( $network );
- $property = $reflection->getProperty( 'id' );
- $property->setAccessible( true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $reflection = new ReflectionObject( $network );
+ $property = $reflection->getProperty( 'id' );
+ $property->setAccessible( true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( (int) $id, $property->getValue( $network ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( (int) $id, $property->getValue( $network ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests that the `WP_Network::$blog_id` property is a string.
- *
- * @ticket 62035
- *
- * @covers WP_Network::__get
- */
- public function test_wp_network_object_blog_id_property_is_int() {
- $id = self::factory()->network->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests that the `WP_Network::$blog_id` property is a string.
+ *
+ * @ticket 62035
+ *
+ * @covers WP_Network::__get
+ */
+ public function test_wp_network_object_blog_id_property_is_int() {
+ $id = self::factory()->network->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network = WP_Network::get_instance( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network = WP_Network::get_instance( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsString( $network->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsString( $network->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests that the `WP_Network::$blog_id` property is stored as a string.
- *
- * Uses reflection to access the private property.
- * Differs from using the public getter method, which casts to a string.
- *
- * @ticket 62035
- *
- * @covers WP_Network::__construct
- */
- public function test_wp_network_object_blog_id_property_stored_as_string() {
- $id = self::factory()->network->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests that the `WP_Network::$blog_id` property is stored as a string.
+ *
+ * Uses reflection to access the private property.
+ * Differs from using the public getter method, which casts to a string.
+ *
+ * @ticket 62035
+ *
+ * @covers WP_Network::__construct
+ */
+ public function test_wp_network_object_blog_id_property_stored_as_string() {
+ $id = self::factory()->network->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network = WP_Network::get_instance( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network = WP_Network::get_instance( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $reflection = new ReflectionObject( $network );
- $property = $reflection->getProperty( 'blog_id' );
- $property->setAccessible( true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $reflection = new ReflectionObject( $network );
+ $property = $reflection->getProperty( 'blog_id' );
+ $property->setAccessible( true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsString( $property->getValue( $network ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsString( $property->getValue( $network ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 22917
- */
- public function test_get_blog_count_no_filter_applied() {
- wp_update_network_counts();
- $site_count_start = get_blog_count();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 22917
+ */
+ public function test_get_blog_count_no_filter_applied() {
+ wp_update_network_counts();
+ $site_count_start = get_blog_count();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_ids = self::factory()->blog->create_many( 1 );
- $actual = (int) get_blog_count(); // Count only updated when cron runs, so should be unchanged.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_ids = self::factory()->blog->create_many( 1 );
+ $actual = (int) get_blog_count(); // Count only updated when cron runs, so should be unchanged.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $site_ids as $site_id ) {
- wp_delete_site( $site_id );
- }
- wp_update_network_counts();
-
- $this->assertSame( $site_count_start + 1, $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $site_ids as $site_id ) {
+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 22917
- */
- public function test_get_blog_count_enable_live_network_counts_false() {
- wp_update_network_counts();
- $site_count_start = get_blog_count();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $site_count_start + 1, $actual );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'enable_live_network_counts', '__return_false' );
- $site_ids = self::factory()->blog->create_many( 1 );
- $actual = (int) get_blog_count(); // Count only updated when cron runs, so should be unchanged.
- remove_filter( 'enable_live_network_counts', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 22917
+ */
+ public function test_get_blog_count_enable_live_network_counts_false() {
+ wp_update_network_counts();
+ $site_count_start = get_blog_count();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $site_ids as $site_id ) {
- wp_delete_site( $site_id );
- }
- wp_update_network_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'enable_live_network_counts', '__return_false' );
+ $site_ids = self::factory()->blog->create_many( 1 );
+ $actual = (int) get_blog_count(); // Count only updated when cron runs, so should be unchanged.
+ remove_filter( 'enable_live_network_counts', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $site_count_start, $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $site_ids as $site_id ) {
+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 22917
- */
- public function test_get_blog_count_enabled_live_network_counts_true() {
- wp_update_network_counts();
- $site_count_start = get_blog_count();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $site_count_start, $actual );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'enable_live_network_counts', '__return_true' );
- $site_ids = self::factory()->blog->create_many( 1 );
- $actual = get_blog_count();
- remove_filter( 'enable_live_network_counts', '__return_true' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 22917
+ */
+ public function test_get_blog_count_enabled_live_network_counts_true() {
+ wp_update_network_counts();
+ $site_count_start = get_blog_count();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $site_ids as $site_id ) {
- wp_delete_site( $site_id );
- }
- wp_update_network_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'enable_live_network_counts', '__return_true' );
+ $site_ids = self::factory()->blog->create_many( 1 );
+ $actual = get_blog_count();
+ remove_filter( 'enable_live_network_counts', '__return_true' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $site_count_start + 1, $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $site_ids as $site_id ) {
+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 37865
- */
- public function test_get_blog_count_on_different_network() {
- wp_update_network_site_counts( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $site_count_start + 1, $actual );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_count = get_blog_count( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37865
+ */
+ public function test_get_blog_count_on_different_network() {
+ wp_update_network_site_counts( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( count( self::$different_site_ids ), $site_count );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_count = get_blog_count( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_active_network_plugins() {
- $path = 'hello.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( count( self::$different_site_ids ), $site_count );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Local activate, should be invisible for the network.
- activate_plugin( $path ); // Enable the plugin for the current site.
- $active_plugins = wp_get_active_network_plugins();
- $this->assertSame( array(), $active_plugins );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_active_network_plugins() {
+ $path = 'hello.php';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'deactivated_plugin', array( $this, 'helper_deactivate_hook' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Local activate, should be invisible for the network.
+ activate_plugin( $path ); // Enable the plugin for the current site.
+ $active_plugins = wp_get_active_network_plugins();
+ $this->assertSame( array(), $active_plugins );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Activate the plugin sitewide.
- activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
- $active_plugins = wp_get_active_network_plugins();
- $this->assertSame( array( WP_PLUGIN_DIR . '/hello.php' ), $active_plugins );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'deactivated_plugin', array( $this, 'helper_deactivate_hook' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Deactivate the plugin.
- deactivate_plugins( $path );
- $active_plugins = wp_get_active_network_plugins();
- $this->assertSame( array(), $active_plugins );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Activate the plugin sitewide.
+ activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
+ $active_plugins = wp_get_active_network_plugins();
+ $this->assertSame( array( WP_PLUGIN_DIR . '/hello.php' ), $active_plugins );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Deactivate the plugin.
+ deactivate_plugins( $path );
+ $active_plugins = wp_get_active_network_plugins();
+ $this->assertSame( array(), $active_plugins );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
- deactivate_plugins( $path, true ); // Silent mode.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
+ deactivate_plugins( $path, true ); // Silent mode.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 28651
- */
- public function test_duplicate_network_active_plugin() {
- $path = 'hello.php';
- $mock = new MockAction();
- add_action( 'activate_' . $path, array( $mock, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Should activate on the first try.
- activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
- $active_plugins = wp_get_active_network_plugins();
- $this->assertCount( 1, $active_plugins );
- $this->assertSame( 1, $mock->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 28651
+ */
+ public function test_duplicate_network_active_plugin() {
+ $path = 'hello.php';
+ $mock = new MockAction();
+ add_action( 'activate_' . $path, array( $mock, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Should do nothing on the second try.
- activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
- $active_plugins = wp_get_active_network_plugins();
- $this->assertCount( 1, $active_plugins );
- $this->assertSame( 1, $mock->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Should activate on the first try.
+ activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
+ $active_plugins = wp_get_active_network_plugins();
+ $this->assertCount( 1, $active_plugins );
+ $this->assertSame( 1, $mock->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( 'activate_' . $path, array( $mock, 'action' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Should do nothing on the second try.
+ activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network.
+ $active_plugins = wp_get_active_network_plugins();
+ $this->assertCount( 1, $active_plugins );
+ $this->assertSame( 1, $mock->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_plugin_active_for_network_true() {
- activate_plugin( 'hello.php', '', true );
- $this->assertTrue( is_plugin_active_for_network( 'hello.php' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( 'activate_' . $path, array( $mock, 'action' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_plugin_active_for_network_false() {
- deactivate_plugins( 'hello.php', false, true );
- $this->assertFalse( is_plugin_active_for_network( 'hello.php' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_plugin_active_for_network_true() {
+ activate_plugin( 'hello.php', '', true );
+ $this->assertTrue( is_plugin_active_for_network( 'hello.php' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function helper_deactivate_hook() {
- ++$this->plugin_hook_count;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_plugin_active_for_network_false() {
+ deactivate_plugins( 'hello.php', false, true );
+ $this->assertFalse( is_plugin_active_for_network( 'hello.php' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_schedule_update_network_counts() {
- $this->assertFalse( wp_next_scheduled( 'update_network_counts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function helper_deactivate_hook() {
+ ++$this->plugin_hook_count;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set.
- wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_schedule_update_network_counts() {
+ $this->assertFalse( wp_next_scheduled( 'update_network_counts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsInt( wp_next_scheduled( 'update_network_counts' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set.
+ wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @expectedDeprecated get_dashboard_blog
- */
- public function test_get_dashboard_blog() {
- // If there is no dashboard blog set, current blog is used.
- $dashboard_blog = get_dashboard_blog();
- $this->assertEquals( 1, $dashboard_blog->blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( wp_next_scheduled( 'update_network_counts' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
- $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) );
- $this->assertIsInt( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @expectedDeprecated get_dashboard_blog
+ */
+ public function test_get_dashboard_blog() {
+ // If there is no dashboard blog set, current blog is used.
+ $dashboard_blog = get_dashboard_blog();
+ $this->assertEquals( 1, $dashboard_blog->blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the dashboard blog to another one.
- update_site_option( 'dashboard_blog', $blog_id );
- $dashboard_blog = get_dashboard_blog();
- $this->assertEquals( $blog_id, $dashboard_blog->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) );
+ $this->assertIsInt( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 37528
- */
- public function test_wp_update_network_site_counts() {
- update_network_option( null, 'blog_count', 40 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the dashboard blog to another one.
+ update_site_option( 'dashboard_blog', $blog_id );
+ $dashboard_blog = get_dashboard_blog();
+ $this->assertEquals( $blog_id, $dashboard_blog->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = get_sites(
- array(
- 'network_id' => get_current_network_id(),
- 'spam' => 0,
- 'deleted' => 0,
- 'archived' => 0,
- 'count' => true,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37528
+ */
+ public function test_wp_update_network_site_counts() {
+ update_network_option( null, 'blog_count', 40 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = get_sites(
+ array(
+ 'network_id' => get_current_network_id(),
+ 'spam' => 0,
+ 'deleted' => 0,
+ 'archived' => 0,
+ 'count' => true,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_blog_count();
- $this->assertSame( $expected, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 37528
- */
- public function test_wp_update_network_site_counts_on_different_network() {
- update_network_option( self::$different_network_id, 'blog_count', 40 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_blog_count();
+ $this->assertSame( $expected, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_site_counts( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 37528
+ */
+ public function test_wp_update_network_site_counts_on_different_network() {
+ update_network_option( self::$different_network_id, 'blog_count', 40 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_blog_count( self::$different_network_id );
- $this->assertSame( 3, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40349
- */
- public function test_wp_update_network_user_counts() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_blog_count( self::$different_network_id );
+ $this->assertSame( 3, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_option( null, 'user_count', 40 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40349
+ */
+ public function test_wp_update_network_user_counts() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = (int) $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_option( null, 'user_count', 40 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_user_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = (int) $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_user_count();
- $this->assertSame( $expected, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_user_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40349
- */
- public function test_wp_update_network_user_counts_on_different_network() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_user_count();
+ $this->assertSame( $expected, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_option( self::$different_network_id, 'user_count', 40 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40349
+ */
+ public function test_wp_update_network_user_counts_on_different_network() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = (int) $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_option( self::$different_network_id, 'user_count', 40 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_user_counts( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = (int) $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_user_count( self::$different_network_id );
- $this->assertSame( $expected, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_user_counts( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40386
- */
- public function test_wp_update_network_counts() {
- delete_network_option( null, 'blog_count' );
- delete_network_option( null, 'user_count' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_user_count( self::$different_network_id );
+ $this->assertSame( $expected, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40386
+ */
+ public function test_wp_update_network_counts() {
+ delete_network_option( null, 'blog_count' );
+ delete_network_option( null, 'user_count' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_count = (int) get_blog_count();
- $user_count = (int) get_user_count();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertGreaterThan( 0, $site_count );
- $this->assertGreaterThan( 0, $user_count );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_count = (int) get_blog_count();
+ $user_count = (int) get_user_count();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40386
- */
- public function test_wp_update_network_counts_on_different_network() {
- delete_network_option( self::$different_network_id, 'blog_count' );
- delete_network_option( self::$different_network_id, 'user_count' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertGreaterThan( 0, $site_count );
+ $this->assertGreaterThan( 0, $user_count );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_counts( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40386
+ */
+ public function test_wp_update_network_counts_on_different_network() {
+ delete_network_option( self::$different_network_id, 'blog_count' );
+ delete_network_option( self::$different_network_id, 'user_count' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_count = (int) get_blog_count( self::$different_network_id );
- $user_count = (int) get_user_count( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_counts( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertGreaterThan( 0, $site_count );
- $this->assertGreaterThan( 0, $user_count );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_count = (int) get_blog_count( self::$different_network_id );
+ $user_count = (int) get_user_count( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the default behavior of upload_size_limit_filter.
- * If any default option is changed, the function returns the min value between the
- * parameter passed and the `fileupload_maxk` site option (1500Kb by default)
- *
- * @ticket 55926
- */
- public function test_upload_size_limit_filter() {
- $return = upload_size_limit_filter( 1499 * KB_IN_BYTES );
- $this->assertSame( 1499 * KB_IN_BYTES, $return );
- $return = upload_size_limit_filter( 1501 * KB_IN_BYTES );
- $this->assertSame( 1500 * KB_IN_BYTES, $return );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertGreaterThan( 0, $site_count );
+ $this->assertGreaterThan( 0, $user_count );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test if upload_size_limit_filter behaves as expected when the `fileupload_maxk` is 0 or an empty string.
- *
- * @ticket 55926
- * @dataProvider data_upload_size_limit_filter_empty_fileupload_maxk
- */
- public function test_upload_size_limit_filter_empty_fileupload_maxk( $callable_set_fileupload_maxk ) {
- add_filter( 'site_option_fileupload_maxk', $callable_set_fileupload_maxk );
- $return = upload_size_limit_filter( 1500 );
- $this->assertSame( 0, $return );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the default behavior of upload_size_limit_filter.
+ * If any default option is changed, the function returns the min value between the
+ * parameter passed and the `fileupload_maxk` site option (1500Kb by default)
+ *
+ * @ticket 55926
+ */
+ public function test_upload_size_limit_filter() {
+ $return = upload_size_limit_filter( 1499 * KB_IN_BYTES );
+ $this->assertSame( 1499 * KB_IN_BYTES, $return );
+ $return = upload_size_limit_filter( 1501 * KB_IN_BYTES );
+ $this->assertSame( 1500 * KB_IN_BYTES, $return );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 55926
- */
- public function data_upload_size_limit_filter_empty_fileupload_maxk() {
- return array(
- array( '__return_zero' ),
- array( '__return_empty_string' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test if upload_size_limit_filter behaves as expected when the `fileupload_maxk` is 0 or an empty string.
+ *
+ * @ticket 55926
+ * @dataProvider data_upload_size_limit_filter_empty_fileupload_maxk
+ */
+ public function test_upload_size_limit_filter_empty_fileupload_maxk( $callable_set_fileupload_maxk ) {
+ add_filter( 'site_option_fileupload_maxk', $callable_set_fileupload_maxk );
+ $return = upload_size_limit_filter( 1500 );
+ $this->assertSame( 0, $return );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When upload_space_check is enabled, the space allowed is also considered by `upload_size_limit_filter`.
- *
- * @ticket 55926
- */
- public function test_upload_size_limit_filter_when_upload_space_check_enabled() {
- add_filter( 'get_space_allowed', '__return_zero' );
- add_filter( 'site_option_upload_space_check_disabled', '__return_false' );
- $return = upload_size_limit_filter( 100 );
- $this->assertSame( 0, $return );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55926
+ */
+ public function data_upload_size_limit_filter_empty_fileupload_maxk() {
+ return array(
+ array( '__return_zero' ),
+ array( '__return_empty_string' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40489
- * @dataProvider data_wp_is_large_network
- */
- public function test_wp_is_large_network( $using, $count, $expected, $different_network ) {
- $network_id = $different_network ? self::$different_network_id : null;
- $network_option = 'users' === $using ? 'user_count' : 'blog_count';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When upload_space_check is enabled, the space allowed is also considered by `upload_size_limit_filter`.
+ *
+ * @ticket 55926
+ */
+ public function test_upload_size_limit_filter_when_upload_space_check_enabled() {
+ add_filter( 'get_space_allowed', '__return_zero' );
+ add_filter( 'site_option_upload_space_check_disabled', '__return_false' );
+ $return = upload_size_limit_filter( 100 );
+ $this->assertSame( 0, $return );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_option( $network_id, $network_option, $count );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40489
+ * @dataProvider data_wp_is_large_network
+ */
+ public function test_wp_is_large_network( $using, $count, $expected, $different_network ) {
+ $network_id = $different_network ? self::$different_network_id : null;
+ $network_option = 'users' === $using ? 'user_count' : 'blog_count';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_is_large_network( $using, $network_id );
- if ( $expected ) {
- $this->assertTrue( $result );
- } else {
- $this->assertFalse( $result );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_option( $network_id, $network_option, $count );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_is_large_network() {
- return array(
- array( 'sites', 10000, false, false ),
- array( 'sites', 10001, true, false ),
- array( 'users', 10000, false, false ),
- array( 'users', 10001, true, false ),
- array( 'sites', 10000, false, true ),
- array( 'sites', 10001, true, true ),
- array( 'users', 10000, false, true ),
- array( 'users', 10001, true, true ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_is_large_network( $using, $network_id );
+ if ( $expected ) {
+ $this->assertTrue( $result );
+ } else {
+ $this->assertFalse( $result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40489
- * @dataProvider data_wp_is_large_network_filtered_by_component
- */
- public function test_wp_is_large_network_filtered_by_component( $using, $count, $expected, $different_network ) {
- $network_id = $different_network ? self::$different_network_id : null;
- $network_option = 'users' === $using ? 'user_count' : 'blog_count';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_is_large_network() {
+ return array(
+ array( 'sites', 10000, false, false ),
+ array( 'sites', 10001, true, false ),
+ array( 'users', 10000, false, false ),
+ array( 'users', 10001, true, false ),
+ array( 'sites', 10000, false, true ),
+ array( 'sites', 10001, true, true ),
+ array( 'users', 10000, false, true ),
+ array( 'users', 10001, true, true ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_option( $network_id, $network_option, $count );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40489
+ * @dataProvider data_wp_is_large_network_filtered_by_component
+ */
+ public function test_wp_is_large_network_filtered_by_component( $using, $count, $expected, $different_network ) {
+ $network_id = $different_network ? self::$different_network_id : null;
+ $network_option = 'users' === $using ? 'user_count' : 'blog_count';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_for_users' ), 10, 3 );
- $result = wp_is_large_network( $using, $network_id );
- remove_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_for_users' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_option( $network_id, $network_option, $count );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $expected ) {
- $this->assertTrue( $result );
- } else {
- $this->assertFalse( $result );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_for_users' ), 10, 3 );
+ $result = wp_is_large_network( $using, $network_id );
+ remove_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_for_users' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_is_large_network_filtered_by_component() {
- return array(
- array( 'sites', 10000, false, false ),
- array( 'sites', 10001, true, false ),
- array( 'users', 1000, false, false ),
- array( 'users', 1001, true, false ),
- array( 'sites', 10000, false, true ),
- array( 'sites', 10001, true, true ),
- array( 'users', 1000, false, true ),
- array( 'users', 1001, true, true ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $expected ) {
+ $this->assertTrue( $result );
+ } else {
+ $this->assertFalse( $result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_wp_is_large_network_for_users( $is_large_network, $using, $count ) {
- if ( 'users' === $using ) {
- return $count > 1000;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_is_large_network_filtered_by_component() {
+ return array(
+ array( 'sites', 10000, false, false ),
+ array( 'sites', 10001, true, false ),
+ array( 'users', 1000, false, false ),
+ array( 'users', 1001, true, false ),
+ array( 'sites', 10000, false, true ),
+ array( 'sites', 10001, true, true ),
+ array( 'users', 1000, false, true ),
+ array( 'users', 1001, true, true ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $is_large_network;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_wp_is_large_network_for_users( $is_large_network, $using, $count ) {
+ if ( 'users' === $using ) {
+ return $count > 1000;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40489
- * @dataProvider data_wp_is_large_network_filtered_by_network
- */
- public function test_wp_is_large_network_filtered_by_network( $using, $count, $expected, $different_network ) {
- $network_id = $different_network ? self::$different_network_id : null;
- $network_option = 'users' === $using ? 'user_count' : 'blog_count';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $is_large_network;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_option( $network_id, $network_option, $count );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40489
+ * @dataProvider data_wp_is_large_network_filtered_by_network
+ */
+ public function test_wp_is_large_network_filtered_by_network( $using, $count, $expected, $different_network ) {
+ $network_id = $different_network ? self::$different_network_id : null;
+ $network_option = 'users' === $using ? 'user_count' : 'blog_count';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_on_different_network' ), 10, 4 );
- $result = wp_is_large_network( $using, $network_id );
- remove_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_on_different_network' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_option( $network_id, $network_option, $count );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $expected ) {
- $this->assertTrue( $result );
- } else {
- $this->assertFalse( $result );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_on_different_network' ), 10, 4 );
+ $result = wp_is_large_network( $using, $network_id );
+ remove_filter( 'wp_is_large_network', array( $this, 'filter_wp_is_large_network_on_different_network' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_is_large_network_filtered_by_network() {
- return array(
- array( 'sites', 10000, false, false ),
- array( 'sites', 10001, true, false ),
- array( 'users', 10000, false, false ),
- array( 'users', 10001, true, false ),
- array( 'sites', 1000, false, true ),
- array( 'sites', 1001, true, true ),
- array( 'users', 1000, false, true ),
- array( 'users', 1001, true, true ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $expected ) {
+ $this->assertTrue( $result );
+ } else {
+ $this->assertFalse( $result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_wp_is_large_network_on_different_network( $is_large_network, $using, $count, $network_id ) {
- if ( $network_id === (int) self::$different_network_id ) {
- return $count > 1000;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_is_large_network_filtered_by_network() {
+ return array(
+ array( 'sites', 10000, false, false ),
+ array( 'sites', 10001, true, false ),
+ array( 'users', 10000, false, false ),
+ array( 'users', 10001, true, false ),
+ array( 'sites', 1000, false, true ),
+ array( 'sites', 1001, true, true ),
+ array( 'users', 1000, false, true ),
+ array( 'users', 1001, true, true ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $is_large_network;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_wp_is_large_network_on_different_network( $is_large_network, $using, $count, $network_id ) {
+ if ( $network_id === (int) self::$different_network_id ) {
+ return $count > 1000;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38699
- */
- public function test_wpmu_create_blog_updates_correct_network_site_count() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $is_large_network;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_count = get_blog_count( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38699
+ */
+ public function test_wpmu_create_blog_updates_correct_network_site_count() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $suppress = $wpdb->suppress_errors();
- $site_id = wpmu_create_blog( 'example.org', '/', '', 1, array(), self::$different_network_id );
- $wpdb->suppress_errors( $suppress );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_count = get_blog_count( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_blog_count( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $suppress = $wpdb->suppress_errors();
+ $site_id = wpmu_create_blog( 'example.org', '/', '', 1, array(), self::$different_network_id );
+ $wpdb->suppress_errors( $suppress );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_blog( $site_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_blog_count( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $original_count + 1, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_blog( $site_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_network_blog_id_set() {
- $network = get_network( self::$different_network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $original_count + 1, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( (string) self::$different_site_ids[0], $network->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_network_blog_id_set() {
+ $network = get_network( self::$different_network_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 42251
- */
- public function test_get_network_not_found_cache() {
- $new_network_id = $this->_get_next_network_id();
- $this->assertNull( get_network( $new_network_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( (string) self::$different_site_ids[0], $network->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
- $this->assertNull( get_network( $new_network_id ) );
- $this->assertSame( $num_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 42251
+ */
+ public function test_get_network_not_found_cache() {
+ $new_network_id = $this->_get_next_network_id();
+ $this->assertNull( get_network( $new_network_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 42251
- */
- public function test_get_network_not_found_cache_clear() {
- $new_network_id = $this->_get_next_network_id();
- $this->assertNull( get_network( $new_network_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
+ $this->assertNull( get_network( $new_network_id ) );
+ $this->assertSame( $num_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_network = self::factory()->network->create_and_get();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 42251
+ */
+ public function test_get_network_not_found_cache_clear() {
+ $new_network_id = $this->_get_next_network_id();
+ $this->assertNull( get_network( $new_network_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Double-check we got the ID of the new network correct.
- $this->assertSame( $new_network_id, $new_network->id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $new_network = self::factory()->network->create_and_get();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Verify that if we fetch the network now, it's no longer false.
- $fetched_network = get_network( $new_network_id );
- $this->assertInstanceOf( 'WP_Network', $fetched_network );
- $this->assertSame( $new_network_id, $fetched_network->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Double-check we got the ID of the new network correct.
+ $this->assertSame( $new_network_id, $new_network->id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Gets the ID of the site with the highest ID.
- * @return int
- */
- protected function _get_next_network_id() {
- global $wpdb;
- // Create an extra network, just to make sure we know the ID of the following one.
- static::factory()->network->create();
- return (int) $wpdb->get_var( 'SELECT id FROM ' . $wpdb->site . ' ORDER BY id DESC LIMIT 1' ) + 1;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Verify that if we fetch the network now, it's no longer false.
+ $fetched_network = get_network( $new_network_id );
+ $this->assertInstanceOf( 'WP_Network', $fetched_network );
+ $this->assertSame( $new_network_id, $fetched_network->id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Gets the ID of the site with the highest ID.
+ * @return int
+ */
+ protected function _get_next_network_id() {
+ global $wpdb;
+ // Create an extra network, just to make sure we know the ID of the following one.
+ static::factory()->network->create();
+ return (int) $wpdb->get_var( 'SELECT id FROM ' . $wpdb->site . ' ORDER BY id DESC LIMIT 1' ) + 1;
+ }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitesitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/site.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/site.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/site.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,2311 +1,2308 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to sites in multisite.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_Site extends WP_UnitTestCase {
+ protected $suppress = false;
+ protected $site_status_hooks = array();
+ protected $wp_initialize_site_args = array();
+ protected $wp_initialize_site_meta = array();
+ protected static $network_ids;
+ protected static $site_ids;
+ protected static $uninitialized_site_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to sites in multisite.
- *
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_Site extends WP_UnitTestCase {
- protected $suppress = false;
- protected $site_status_hooks = array();
- protected $wp_initialize_site_args = array();
- protected $wp_initialize_site_meta = array();
- protected static $network_ids;
- protected static $site_ids;
- protected static $uninitialized_site_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function set_up() {
+ global $wpdb;
+ parent::set_up();
+ $this->suppress = $wpdb->suppress_errors();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function set_up() {
- global $wpdb;
- parent::set_up();
- $this->suppress = $wpdb->suppress_errors();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function tear_down() {
+ global $wpdb;
+ $wpdb->suppress_errors( $this->suppress );
+ parent::tear_down();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function tear_down() {
- global $wpdb;
- $wpdb->suppress_errors( $this->suppress );
- parent::tear_down();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$network_ids = array(
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ ),
+ );
+
+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$network_ids = array(
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$site_ids = array(
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ ),
+ 'make.wordpress.org/foo/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
-
- self::$site_ids = array(
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- ),
- 'make.wordpress.org/foo/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- ),
- );
-
- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
-
- remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
- self::$uninitialized_site_id = wp_insert_site(
- array(
- 'domain' => 'uninitialized.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- )
- );
- add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
+ self::$uninitialized_site_id = wp_insert_site(
+ array(
+ 'domain' => 'uninitialized.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ )
+ );
+ add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10 );
- wp_delete_site( self::$uninitialized_site_id );
- add_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10 );
+ wp_delete_site( self::$uninitialized_site_id );
+ add_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as $id ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_switch_restore_blog() {
- global $_wp_switched_stack, $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as $id ) {
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array(), $_wp_switched_stack );
- $this->assertFalse( ms_is_switched() );
- $current_blog_id = get_current_blog_id();
- $this->assertIsInt( $current_blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_switch_restore_blog() {
+ global $_wp_switched_stack, $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' );
- $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array(), $_wp_switched_stack );
+ $this->assertFalse( ms_is_switched() );
+ $current_blog_id = get_current_blog_id();
+ $this->assertIsInt( $current_blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' );
+ $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cap_key = wp_get_current_user()->cap_key;
- switch_to_blog( $blog_id );
- $this->assertNotEquals( $cap_key, wp_get_current_user()->cap_key );
- $this->assertSame( array( $current_blog_id ), $_wp_switched_stack );
- $this->assertTrue( ms_is_switched() );
- $this->assertSame( $blog_id, $wpdb->blogid );
- $this->assertFalse( wp_cache_get( 'switch-test', 'switch-test' ) );
- wp_cache_set( 'switch-test', $blog_id, 'switch-test' );
- $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
- $this->assertSame( array( $current_blog_id, $blog_id ), $_wp_switched_stack );
- $this->assertTrue( ms_is_switched() );
- $this->assertSame( $blog_id, $wpdb->blogid );
- $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cap_key = wp_get_current_user()->cap_key;
+ switch_to_blog( $blog_id );
+ $this->assertNotEquals( $cap_key, wp_get_current_user()->cap_key );
+ $this->assertSame( array( $current_blog_id ), $_wp_switched_stack );
+ $this->assertTrue( ms_is_switched() );
+ $this->assertSame( $blog_id, $wpdb->blogid );
+ $this->assertFalse( wp_cache_get( 'switch-test', 'switch-test' ) );
+ wp_cache_set( 'switch-test', $blog_id, 'switch-test' );
+ $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
- $this->assertSame( array( $current_blog_id ), $_wp_switched_stack );
- $this->assertTrue( ms_is_switched() );
- $this->assertSame( $blog_id, $wpdb->blogid );
- $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
+ $this->assertSame( array( $current_blog_id, $blog_id ), $_wp_switched_stack );
+ $this->assertTrue( ms_is_switched() );
+ $this->assertSame( $blog_id, $wpdb->blogid );
+ $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
- $this->assertSame( $cap_key, wp_get_current_user()->cap_key );
- $this->assertSame( $current_blog_id, get_current_blog_id() );
- $this->assertSame( array(), $_wp_switched_stack );
- $this->assertFalse( ms_is_switched() );
- $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
+ $this->assertSame( array( $current_blog_id ), $_wp_switched_stack );
+ $this->assertTrue( ms_is_switched() );
+ $this->assertSame( $blog_id, $wpdb->blogid );
+ $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( restore_current_blog() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
+ $this->assertSame( $cap_key, wp_get_current_user()->cap_key );
+ $this->assertSame( $current_blog_id, get_current_blog_id() );
+ $this->assertSame( array(), $_wp_switched_stack );
+ $this->assertFalse( ms_is_switched() );
+ $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the cache keys and database tables setup through the creation of a site.
- */
- public function test_created_site_details() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( restore_current_blog() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the cache keys and database tables setup through the creation of a site.
+ */
+ public function test_created_site_details() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsInt( $blog_id );
- $prefix = $wpdb->get_blog_prefix( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // $get_all = false, only retrieve details from the blogs table.
- $details = get_blog_details( $blog_id, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( $blog_id );
+ $prefix = $wpdb->get_blog_prefix( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Combine domain and path for a site specific cache key.
- $key = md5( $details->domain . $details->path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // $get_all = false, only retrieve details from the blogs table.
+ $details = get_blog_details( $blog_id, false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Combine domain and path for a site specific cache key.
+ $key = md5( $details->domain . $details->path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // get_blogaddress_by_name().
- $this->assertSame( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // These are empty until get_blog_details() is called with $get_all = true.
- $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // get_blogaddress_by_name().
+ $this->assertSame( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // $get_all = true, populate the full blog-details cache and the blog slug lookup cache.
- $details = get_blog_details( $blog_id, true );
- $this->assertEquals( $details, wp_cache_get( $blog_id, 'blog-details' ) );
- $this->assertEquals( $details, wp_cache_get( $key, 'blog-lookup' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // These are empty until get_blog_details() is called with $get_all = true.
+ $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check existence of each database table for the created site.
- foreach ( $wpdb->tables( 'blog', false ) as $table ) {
- $suppress = $wpdb->suppress_errors();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // $get_all = true, populate the full blog-details cache and the blog slug lookup cache.
+ $details = get_blog_details( $blog_id, true );
+ $this->assertEquals( $details, wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertEquals( $details, wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check existence of each database table for the created site.
+ foreach ( $wpdb->tables( 'blog', false ) as $table ) {
+ $suppress = $wpdb->suppress_errors();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wpdb->suppress_errors( $suppress );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The table should exist.
- $this->assertNotEmpty( $table_fields );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wpdb->suppress_errors( $suppress );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // And the table should not be empty, unless commentmeta, termmeta, or links.
- // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $result = $wpdb->get_results( "SELECT * FROM $prefix$table LIMIT 1" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The table should exist.
+ $this->assertNotEmpty( $table_fields );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'commentmeta' === $table || 'termmeta' === $table || 'links' === $table ) {
- $this->assertEmpty( $result );
- } else {
- $this->assertNotEmpty( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // And the table should not be empty, unless commentmeta, termmeta, or links.
+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $result = $wpdb->get_results( "SELECT * FROM $prefix$table LIMIT 1" );
+
+ if ( 'commentmeta' === $table || 'termmeta' === $table || 'links' === $table ) {
+ $this->assertEmpty( $result );
+ } else {
+ $this->assertNotEmpty( $result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // Update the blog count cache to use get_blog_count().
- wp_update_network_counts();
- $this->assertSame( 2, (int) get_blog_count() );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_site_caches_should_invalidate_when_invalidation_is_not_suspended() {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Update the blog count cache to use get_blog_count().
+ wp_update_network_counts();
+ $this->assertSame( 2, (int) get_blog_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_site_caches_should_invalidate_when_invalidation_is_not_suspended() {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $suspend = wp_suspend_cache_invalidation( false );
- update_blog_details( $site_id, array( 'path' => '/a-non-random-test-path/' ) );
- $new_details = get_site( $site_id );
- wp_suspend_cache_invalidation( $suspend );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $details = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $details->path, $new_details->path );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $suspend = wp_suspend_cache_invalidation( false );
+ update_blog_details( $site_id, array( 'path' => '/a-non-random-test-path/' ) );
+ $new_details = get_site( $site_id );
+ wp_suspend_cache_invalidation( $suspend );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_site_caches_should_not_invalidate_when_invalidation_is_suspended() {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( $details->path, $new_details->path );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_site_caches_should_not_invalidate_when_invalidation_is_suspended() {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $suspend = wp_suspend_cache_invalidation();
- update_blog_details( $site_id, array( 'path' => '/a-non-random-test-path/' ) );
- $new_details = get_site( $site_id );
- wp_suspend_cache_invalidation( $suspend );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $details = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $details->path, $new_details->path );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $suspend = wp_suspend_cache_invalidation();
+ update_blog_details( $site_id, array( 'path' => '/a-non-random-test-path/' ) );
+ $new_details = get_site( $site_id );
+ wp_suspend_cache_invalidation( $suspend );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a site is flagged as 'deleted', its data should be cleared from cache.
- */
- public function test_data_in_cache_after_wpmu_delete_blog_drop_false() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $details->path, $new_details->path );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details = get_blog_details( $blog_id, false );
- $key = md5( $details->domain . $details->path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a site is flagged as 'deleted', its data should be cleared from cache.
+ */
+ public function test_data_in_cache_after_wpmu_delete_blog_drop_false() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site without forcing a table drop.
- wpmu_delete_blog( $blog_id, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $details = get_blog_details( $blog_id, false );
+ $key = md5( $details->domain . $details->path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site without forcing a table drop.
+ wpmu_delete_blog( $blog_id, false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a site is flagged as 'deleted', its data should remain in the database.
- */
- public function test_data_in_tables_after_wpmu_delete_blog_drop_false() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a site is flagged as 'deleted', its data should remain in the database.
+ */
+ public function test_data_in_tables_after_wpmu_delete_blog_drop_false() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site without forcing a table drop.
- wpmu_delete_blog( $blog_id, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $prefix = $wpdb->get_blog_prefix( $blog_id );
- foreach ( $wpdb->tables( 'blog', false ) as $table ) {
- $suppress = $wpdb->suppress_errors();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site without forcing a table drop.
+ wpmu_delete_blog( $blog_id, false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $prefix = $wpdb->get_blog_prefix( $blog_id );
+ foreach ( $wpdb->tables( 'blog', false ) as $table ) {
+ $suppress = $wpdb->suppress_errors();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wpdb->suppress_errors( $suppress );
- $this->assertNotEmpty( $table_fields, $prefix . $table );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
+
+ $wpdb->suppress_errors( $suppress );
+ $this->assertNotEmpty( $table_fields, $prefix . $table );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a site is fully deleted, its data should be cleared from cache.
- */
- public function test_data_in_cache_after_wpmu_delete_blog_drop_true() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a site is fully deleted, its data should be cleared from cache.
+ */
+ public function test_data_in_cache_after_wpmu_delete_blog_drop_true() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details = get_blog_details( $blog_id, false );
- $key = md5( $details->domain . $details->path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $details = get_blog_details( $blog_id, false );
+ $key = md5( $details->domain . $details->path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site and force a table drop.
- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site and force a table drop.
+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a site is fully deleted, its data should be removed from the database.
- */
- public function test_data_in_tables_after_wpmu_delete_blog_drop_true() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a site is fully deleted, its data should be removed from the database.
+ */
+ public function test_data_in_tables_after_wpmu_delete_blog_drop_true() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site and force a table drop.
- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site and force a table drop.
+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $prefix = $wpdb->get_blog_prefix( $blog_id );
- foreach ( $wpdb->tables( 'blog', false ) as $table ) {
- $suppress = $wpdb->suppress_errors();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $prefix = $wpdb->get_blog_prefix( $blog_id );
+ foreach ( $wpdb->tables( 'blog', false ) as $table ) {
+ $suppress = $wpdb->suppress_errors();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wpdb->suppress_errors( $suppress );
- $this->assertEmpty( $table_fields );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wpdb->suppress_errors( $suppress );
+ $this->assertEmpty( $table_fields );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the main site of a network is fully deleted, its data should be cleared from cache.
- */
- public function test_data_in_cache_after_wpmu_delete_blog_main_site_drop_true() {
- $blog_id = 1; // The main site in our test suite has an ID of 1.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the main site of a network is fully deleted, its data should be cleared from cache.
+ */
+ public function test_data_in_cache_after_wpmu_delete_blog_main_site_drop_true() {
+ $blog_id = 1; // The main site in our test suite has an ID of 1.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details = get_blog_details( $blog_id, false );
- $key = md5( $details->domain . $details->path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $details = get_blog_details( $blog_id, false );
+ $key = md5( $details->domain . $details->path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site and force a table drop.
- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site and force a table drop.
+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
- $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
+ $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the main site of a network is fully deleted, its data should remain in the database.
- */
- public function test_data_in_tables_after_wpmu_delete_blog_main_site_drop_true() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the main site of a network is fully deleted, its data should remain in the database.
+ */
+ public function test_data_in_tables_after_wpmu_delete_blog_main_site_drop_true() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = 1; // The main site in our test suite has an ID of 1.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = 1; // The main site in our test suite has an ID of 1.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site and force a table drop.
- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site and force a table drop.
+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $prefix = $wpdb->get_blog_prefix( $blog_id );
- foreach ( $wpdb->tables( 'blog', false ) as $table ) {
- $suppress = $wpdb->suppress_errors();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $prefix = $wpdb->get_blog_prefix( $blog_id );
+ foreach ( $wpdb->tables( 'blog', false ) as $table ) {
+ $suppress = $wpdb->suppress_errors();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wpdb->suppress_errors( $suppress );
- $this->assertNotEmpty( $table_fields, $prefix . $table );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wpdb->suppress_errors( $suppress );
+ $this->assertNotEmpty( $table_fields, $prefix . $table );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * The site count of a network should change when a site is flagged as 'deleted'.
- */
- public function test_network_count_after_wpmu_delete_blog_drop_false() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * The site count of a network should change when a site is flagged as 'deleted'.
+ */
+ public function test_network_count_after_wpmu_delete_blog_drop_false() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site without forcing a table drop.
- wpmu_delete_blog( $blog_id, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site without forcing a table drop.
+ wpmu_delete_blog( $blog_id, false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Update the blog count cache to use get_blog_count().
- wp_update_network_counts();
- $this->assertSame( 1, get_blog_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Update the blog count cache to use get_blog_count().
+ wp_update_network_counts();
+ $this->assertSame( 1, get_blog_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * The site count of a network should change when a site is fully deleted.
- */
- public function test_blog_count_after_wpmu_delete_blog_drop_true() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * The site count of a network should change when a site is fully deleted.
+ */
+ public function test_blog_count_after_wpmu_delete_blog_drop_true() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Delete the site and force a table drop.
- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Delete the site and force a table drop.
+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Update the blog count cache to use get_blog_count().
- wp_update_network_counts();
- $this->assertSame( 1, get_blog_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Update the blog count cache to use get_blog_count().
+ wp_update_network_counts();
+ $this->assertSame( 1, get_blog_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a site is deleted with wpmu_delete_blog(), only the files associated with
- * that site should be removed. When wpmu_delete_blog() is run a second time, nothing
- * should change with upload directories.
- */
- public function test_upload_directories_after_multiple_wpmu_delete_blog() {
- $filename = __FUNCTION__ . '.jpg';
- $contents = __FUNCTION__ . '_contents';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a site is deleted with wpmu_delete_blog(), only the files associated with
+ * that site should be removed. When wpmu_delete_blog() is run a second time, nothing
+ * should change with upload directories.
+ */
+ public function test_upload_directories_after_multiple_wpmu_delete_blog() {
+ $filename = __FUNCTION__ . '.jpg';
+ $contents = __FUNCTION__ . '_contents';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Upload a file to the main site on the network.
- $file1 = wp_upload_bits( $filename, null, $contents );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Upload a file to the main site on the network.
+ $file1 = wp_upload_bits( $filename, null, $contents );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
- $file2 = wp_upload_bits( $filename, null, $contents );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
+ $file2 = wp_upload_bits( $filename, null, $contents );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The file on the main site should still exist. The file on the deleted site should not.
- $this->assertFileExists( $file1['file'] );
- $this->assertFileDoesNotExist( $file2['file'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The file on the main site should still exist. The file on the deleted site should not.
+ $this->assertFileExists( $file1['file'] );
+ $this->assertFileDoesNotExist( $file2['file'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The file on the main site should still exist. The file on the deleted site should not.
- $this->assertFileExists( $file1['file'] );
- $this->assertFileDoesNotExist( $file2['file'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The file on the main site should still exist. The file on the deleted site should not.
+ $this->assertFileExists( $file1['file'] );
+ $this->assertFileDoesNotExist( $file2['file'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unlink( $file1['file'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unlink( $file1['file'] );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wpmu_update_blogs_date() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wpmu_update_blogs_date() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_update_blogs_date();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_update_blogs_date();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog = get_site( get_current_blog_id() );
- $current_time = time();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog = get_site( get_current_blog_id() );
+ $current_time = time();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Compare the update time with the current time, allow delta < 2.
- $this->assertEqualsWithDelta( $current_time, strtotime( $blog->last_updated ), 2, 'The dates should be equal' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Compare the update time with the current time, allow delta < 2.
+ $this->assertEqualsWithDelta( $current_time, strtotime( $blog->last_updated ), 2, 'The dates should be equal' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test cached data for a site that does not exist and then again after it exists.
- *
- * @ticket 23405
- */
- public function test_get_blog_details_when_site_does_not_exist() {
- // Create an unused site so that we can then assume an invalid site ID.
- $blog_id = self::factory()->blog->create();
- ++$blog_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test cached data for a site that does not exist and then again after it exists.
+ *
+ * @ticket 23405
+ */
+ public function test_get_blog_details_when_site_does_not_exist() {
+ // Create an unused site so that we can then assume an invalid site ID.
+ $blog_id = self::factory()->blog->create();
+ ++$blog_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Prime the cache for an invalid site.
- get_blog_details( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prime the cache for an invalid site.
+ get_blog_details( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When the cache is primed with an invalid site, the value is set to -1.
- $this->assertSame( -1, wp_cache_get( $blog_id, 'blog-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // When the cache is primed with an invalid site, the value is set to -1.
+ $this->assertSame( -1, wp_cache_get( $blog_id, 'blog-details' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Create a site in the invalid site's place.
- self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Create a site in the invalid site's place.
+ self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When a new site is created, its cache is cleared through refresh_blog_details.
- $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // When a new site is created, its cache is cleared through refresh_blog_details.
+ $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog = get_blog_details( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog = get_blog_details( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When the cache is refreshed, it should now equal the site data.
- $this->assertEquals( $blog, wp_cache_get( $blog_id, 'blog-details' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // When the cache is refreshed, it should now equal the site data.
+ $this->assertEquals( $blog, wp_cache_get( $blog_id, 'blog-details' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 26410
- */
- public function test_blog_details_cache_invalidation() {
- update_option( 'blogname', 'foo' );
- $details = get_site( get_current_blog_id() );
- $this->assertSame( 'foo', $details->blogname );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 26410
+ */
+ public function test_blog_details_cache_invalidation() {
+ update_option( 'blogname', 'foo' );
+ $details = get_site( get_current_blog_id() );
+ $this->assertSame( 'foo', $details->blogname );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_option( 'blogname', 'bar' );
- $details = get_site( get_current_blog_id() );
- $this->assertSame( 'bar', $details->blogname );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_option( 'blogname', 'bar' );
+ $details = get_site( get_current_blog_id() );
+ $this->assertSame( 'bar', $details->blogname );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the original and cached responses for a created and then deleted site when
- * the blog ID is requested through get_blog_id_from_url().
- */
- public function test_get_blog_id_from_url() {
- $blog_id = self::factory()->blog->create();
- $details = get_site( $blog_id );
- $key = md5( $details->domain . $details->path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the original and cached responses for a created and then deleted site when
+ * the blog ID is requested through get_blog_id_from_url().
+ */
+ public function test_get_blog_id_from_url() {
+ $blog_id = self::factory()->blog->create();
+ $details = get_site( $blog_id );
+ $key = md5( $details->domain . $details->path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Test the original response and cached response for the newly created site.
- $this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
- $this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Test the original response and cached response for the newly created site.
+ $this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
+ $this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the case insensitivity of the site lookup.
- */
- public function test_get_blog_id_from_url_is_case_insensitive() {
- $blog_id = self::factory()->blog->create(
- array(
- 'domain' => 'example.com',
- 'path' => '/xyz',
- )
- );
- $details = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the case insensitivity of the site lookup.
+ */
+ public function test_get_blog_id_from_url_is_case_insensitive() {
+ $blog_id = self::factory()->blog->create(
+ array(
+ 'domain' => 'example.com',
+ 'path' => '/xyz',
+ )
+ );
+ $details = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the first and cached responses for a site that does not exist.
- */
- public function test_get_blog_id_from_url_that_does_not_exist() {
- $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) );
- $details = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the first and cached responses for a site that does not exist.
+ */
+ public function test_get_blog_id_from_url_that_does_not_exist() {
+ $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) );
+ $details = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
- $this->assertSame( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
+ $this->assertSame( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * A blog ID is still available if only the `deleted` flag is set for a site. The same
- * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`.
- */
- public function test_get_blog_id_from_url_with_deleted_flag() {
- $blog_id = self::factory()->blog->create();
- $details = get_site( $blog_id );
- $key = md5( $details->domain . $details->path );
- wpmu_delete_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * A blog ID is still available if only the `deleted` flag is set for a site. The same
+ * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`.
+ */
+ public function test_get_blog_id_from_url_with_deleted_flag() {
+ $blog_id = self::factory()->blog->create();
+ $details = get_site( $blog_id );
+ $key = md5( $details->domain . $details->path );
+ wpmu_delete_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
- $this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
+ $this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When deleted with the drop parameter as true, the cache will first be false, then set to
- * -1 after an attempt at `get_blog_id_from_url()` is made.
- */
- public function test_get_blog_id_from_url_after_dropped() {
- $blog_id = self::factory()->blog->create();
- $details = get_site( $blog_id );
- $key = md5( $details->domain . $details->path );
- wpmu_delete_blog( $blog_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When deleted with the drop parameter as true, the cache will first be false, then set to
+ * -1 after an attempt at `get_blog_id_from_url()` is made.
+ */
+ public function test_get_blog_id_from_url_after_dropped() {
+ $blog_id = self::factory()->blog->create();
+ $details = get_site( $blog_id );
+ $key = md5( $details->domain . $details->path );
+ wpmu_delete_blog( $blog_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
- $this->assertSame( 0, get_blog_id_from_url( $details->domain, $details->path ) );
- $this->assertSame( -1, wp_cache_get( $key, 'blog-id-cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
+ $this->assertSame( 0, get_blog_id_from_url( $details->domain, $details->path ) );
+ $this->assertSame( -1, wp_cache_get( $key, 'blog-id-cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test with default parameter of site_id as null.
- */
- public function test_is_main_site() {
- $this->assertTrue( is_main_site() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test with default parameter of site_id as null.
+ */
+ public function test_is_main_site() {
+ $this->assertTrue( is_main_site() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test with a site id of get_current_blog_id(), which should be the same as the
- * default parameter tested above.
- */
- public function test_current_blog_id_is_main_site() {
- $this->assertTrue( is_main_site( get_current_blog_id() ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test with a site id of get_current_blog_id(), which should be the same as the
+ * default parameter tested above.
+ */
+ public function test_current_blog_id_is_main_site() {
+ $this->assertTrue( is_main_site( get_current_blog_id() ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test with a site ID other than the main site to ensure a false response.
- */
- public function test_is_main_site_is_false_with_other_blog_id() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test with a site ID other than the main site to ensure a false response.
+ */
+ public function test_is_main_site_is_false_with_other_blog_id() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( is_main_site( $blog_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( is_main_site( $blog_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test with no passed ID after switching to another site ID.
- */
- public function test_is_main_site_is_false_after_switch_to_blog() {
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test with no passed ID after switching to another site ID.
+ */
+ public function test_is_main_site_is_false_after_switch_to_blog() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( is_main_site() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( is_main_site() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_switch_upload_dir() {
- $this->assertTrue( is_main_site() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_switch_upload_dir() {
+ $this->assertTrue( is_main_site() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_current_site();
- $date = date_format( date_create( 'now' ), 'Y/m' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_current_site();
+ $date = date_format( date_create( 'now' ), 'Y/m' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $info = wp_upload_dir();
- $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . $date, $info['url'] );
- $this->assertSame( ABSPATH . 'wp-content/uploads/' . $date, $info['path'] );
- $this->assertSame( '/' . $date, $info['subdir'] );
- $this->assertFalse( $info['error'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $info = wp_upload_dir();
+ $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . $date, $info['url'] );
+ $this->assertSame( ABSPATH . 'wp-content/uploads/' . $date, $info['path'] );
+ $this->assertSame( '/' . $date, $info['subdir'] );
+ $this->assertFalse( $info['error'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
- $info = wp_upload_dir();
- $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . $date, $info['url'] );
- $this->assertSame( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . $date, $info['path'] );
- $this->assertSame( '/' . $date, $info['subdir'] );
- $this->assertFalse( $info['error'] );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
+ $info = wp_upload_dir();
+ $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . $date, $info['url'] );
+ $this->assertSame( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . $date, $info['path'] );
+ $this->assertSame( '/' . $date, $info['subdir'] );
+ $this->assertFalse( $info['error'] );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $info = wp_upload_dir();
- $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . $date, $info['url'] );
- $this->assertSame( ABSPATH . 'wp-content/uploads/' . $date, $info['path'] );
- $this->assertSame( '/' . $date, $info['subdir'] );
- $this->assertFalse( $info['error'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $info = wp_upload_dir();
+ $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . $date, $info['url'] );
+ $this->assertSame( ABSPATH . 'wp-content/uploads/' . $date, $info['path'] );
+ $this->assertSame( '/' . $date, $info['subdir'] );
+ $this->assertFalse( $info['error'] );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the primary purpose of get_blog_post(), to retrieve a post from
- * another site on the network.
- */
- public function test_get_blog_post_from_another_site_on_network() {
- $blog_id = self::factory()->blog->create();
- $post_id = self::factory()->post->create(); // Create a post on the primary site, ID 1.
- $post = get_post( $post_id );
- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the primary purpose of get_blog_post(), to retrieve a post from
+ * another site on the network.
+ */
+ public function test_get_blog_post_from_another_site_on_network() {
+ $blog_id = self::factory()->blog->create();
+ $post_id = self::factory()->post->create(); // Create a post on the primary site, ID 1.
+ $post = get_post( $post_id );
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The post created and retrieved on the main site should match the one retrieved "remotely".
- $this->assertEquals( $post, get_blog_post( 1, $post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The post created and retrieved on the main site should match the one retrieved "remotely".
+ $this->assertEquals( $post, get_blog_post( 1, $post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * If get_blog_post() is used on the same site, it should still work.
- */
- public function test_get_blog_post_from_same_site() {
- $post_id = self::factory()->post->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * If get_blog_post() is used on the same site, it should still work.
+ */
+ public function test_get_blog_post_from_same_site() {
+ $post_id = self::factory()->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( get_blog_post( 1, $post_id ), get_post( $post_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( get_blog_post( 1, $post_id ), get_post( $post_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * A null response should be returned if an invalid post is requested.
- */
- public function test_get_blog_post_invalid_returns_null() {
- $this->assertNull( get_blog_post( 1, 999999 ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * A null response should be returned if an invalid post is requested.
+ */
+ public function test_get_blog_post_invalid_returns_null() {
+ $this->assertNull( get_blog_post( 1, 999999 ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Added as a callback to the domain_exists filter to provide manual results for
- * the testing of the filter and for a test which does not need the database.
- */
- public function domain_exists_cb( $exists, $domain, $path, $site_id ) {
- if ( 'foo' === $domain && 'bar/' === $path ) {
- return 1234;
- } else {
- return null;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Added as a callback to the domain_exists filter to provide manual results for
+ * the testing of the filter and for a test which does not need the database.
+ */
+ public function domain_exists_cb( $exists, $domain, $path, $site_id ) {
+ if ( 'foo' === $domain && 'bar/' === $path ) {
+ return 1234;
+ } else {
+ return null;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_domain_exists_with_default_site_id() {
- $details = get_site( 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_domain_exists_with_default_site_id() {
+ $details = get_site( 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, domain_exists( $details->domain, $details->path ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, domain_exists( $details->domain, $details->path ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_domain_exists_with_specified_site_id() {
- $details = get_site( 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_domain_exists_with_specified_site_id() {
+ $details = get_site( 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 1, domain_exists( $details->domain, $details->path, $details->site_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 1, domain_exists( $details->domain, $details->path, $details->site_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the domain is valid, but the resulting site does not belong to the specified network,
- * it is marked as not existing.
- */
- public function test_domain_does_not_exist_with_invalid_site_id() {
- $details = get_site( 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the domain is valid, but the resulting site does not belong to the specified network,
+ * it is marked as not existing.
+ */
+ public function test_domain_does_not_exist_with_invalid_site_id() {
+ $details = get_site( 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( domain_exists( $details->domain, $details->path, 999 ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNull( domain_exists( $details->domain, $details->path, 999 ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_invalid_domain_does_not_exist_with_default_site_id() {
- $this->assertNull( domain_exists( 'foo', 'bar' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_invalid_domain_does_not_exist_with_default_site_id() {
+ $this->assertNull( domain_exists( 'foo', 'bar' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_domain_filtered_to_exist() {
- add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
- $exists = domain_exists( 'foo', 'bar' );
- remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
- $this->assertSame( 1234, $exists );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_domain_filtered_to_exist() {
+ add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
+ $exists = domain_exists( 'foo', 'bar' );
+ remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
+ $this->assertSame( 1234, $exists );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When a path is passed to domain_exists, it is immediately trailing slashed. A path
- * value with or without the slash should result in the same return value.
- */
- public function test_slashed_path_in_domain_exists() {
- add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
- $exists1 = domain_exists( 'foo', 'bar' );
- $exists2 = domain_exists( 'foo', 'bar/' );
- remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When a path is passed to domain_exists, it is immediately trailing slashed. A path
+ * value with or without the slash should result in the same return value.
+ */
+ public function test_slashed_path_in_domain_exists() {
+ add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
+ $exists1 = domain_exists( 'foo', 'bar' );
+ $exists2 = domain_exists( 'foo', 'bar/' );
+ remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure the same result is returned with or without a trailing slash.
- $this->assertSame( $exists1, $exists2 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure the same result is returned with or without a trailing slash.
+ $this->assertSame( $exists1, $exists2 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests returning an address for a given valid ID.
- */
- public function test_get_blogaddress_by_id_with_valid_id() {
- $blogaddress = get_blogaddress_by_id( 1 );
- $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests returning an address for a given valid ID.
+ */
+ public function test_get_blogaddress_by_id_with_valid_id() {
+ $blogaddress = get_blogaddress_by_id( 1 );
+ $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests returning an empty string for a non-existing ID.
- */
- public function test_get_blogaddress_by_id_with_invalid_id() {
- $blogaddress = get_blogaddress_by_id( PHP_INT_MAX );
- $this->assertSame( '', $blogaddress );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests returning an empty string for a non-existing ID.
+ */
+ public function test_get_blogaddress_by_id_with_invalid_id() {
+ $blogaddress = get_blogaddress_by_id( PHP_INT_MAX );
+ $this->assertSame( '', $blogaddress );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 14867
- */
- public function test_get_blogaddress_by_id_scheme_reflects_blog_scheme() {
- $blog = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 14867
+ */
+ public function test_get_blogaddress_by_id_scheme_reflects_blog_scheme() {
+ $blog = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'http', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'http', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_blog_option( $blog, 'home', set_url_scheme( get_blog_option( $blog, 'home' ), 'https' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_blog_option( $blog, 'home', set_url_scheme( get_blog_option( $blog, 'home' ), 'https' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'https', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'https', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 14867
- */
- public function test_get_blogaddress_by_id_scheme_is_unaffected_by_request() {
- $blog = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 14867
+ */
+ public function test_get_blogaddress_by_id_scheme_is_unaffected_by_request() {
+ $blog = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( is_ssl() );
- $this->assertSame( 'http', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( is_ssl() );
+ $this->assertSame( 'http', parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_SERVER['HTTPS'] = 'on';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_SERVER['HTTPS'] = 'on';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $is_ssl = is_ssl();
- $address = parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $is_ssl = is_ssl();
+ $address = parse_url( get_blogaddress_by_id( $blog ), PHP_URL_SCHEME );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $is_ssl );
- $this->assertSame( 'http', $address );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $is_ssl );
+ $this->assertSame( 'http', $address );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 33620
- * @dataProvider data_new_blog_url_schemes
- */
- public function test_new_blog_url_schemes( $home_scheme, $siteurl_scheme, $force_ssl_admin ) {
- $current_site = get_current_site();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 33620
+ * @dataProvider data_new_blog_url_schemes
+ */
+ public function test_new_blog_url_schemes( $home_scheme, $siteurl_scheme, $force_ssl_admin ) {
+ $current_site = get_current_site();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $home = get_option( 'home' );
- $siteurl = get_site_option( 'siteurl' );
- $admin = force_ssl_admin();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $home = get_option( 'home' );
+ $siteurl = get_site_option( 'siteurl' );
+ $admin = force_ssl_admin();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Setup:
- update_option( 'home', set_url_scheme( $home, $home_scheme ) );
- update_site_option( 'siteurl', set_url_scheme( $siteurl, $siteurl_scheme ) );
- force_ssl_admin( $force_ssl_admin );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Setup:
+ update_option( 'home', set_url_scheme( $home, $home_scheme ) );
+ update_site_option( 'siteurl', set_url_scheme( $siteurl, $siteurl_scheme ) );
+ force_ssl_admin( $force_ssl_admin );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Install:
- $new = wpmu_create_blog( $current_site->domain, '/new-blog/', 'New Blog', get_current_user_id() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Install:
+ $new = wpmu_create_blog( $current_site->domain, '/new-blog/', 'New Blog', get_current_user_id() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Reset:
- update_option( 'home', $home );
- update_site_option( 'siteurl', $siteurl );
- force_ssl_admin( $admin );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Reset:
+ update_option( 'home', $home );
+ update_site_option( 'siteurl', $siteurl );
+ force_ssl_admin( $admin );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Assert:
- $this->assertNotWPError( $new );
- $this->assertSame( $home_scheme, parse_url( get_blog_option( $new, 'home' ), PHP_URL_SCHEME ) );
- $this->assertSame( $siteurl_scheme, parse_url( get_blog_option( $new, 'siteurl' ), PHP_URL_SCHEME ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Assert:
+ $this->assertNotWPError( $new );
+ $this->assertSame( $home_scheme, parse_url( get_blog_option( $new, 'home' ), PHP_URL_SCHEME ) );
+ $this->assertSame( $siteurl_scheme, parse_url( get_blog_option( $new, 'siteurl' ), PHP_URL_SCHEME ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_new_blog_url_schemes() {
- return array(
- array(
- 'https',
- 'https',
- false,
- ),
- array(
- 'http',
- 'https',
- false,
- ),
- array(
- 'https',
- 'http',
- false,
- ),
- array(
- 'http',
- 'http',
- false,
- ),
- array(
- 'http',
- 'http',
- true,
- ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_new_blog_url_schemes() {
+ return array(
+ array(
+ 'https',
+ 'https',
+ false,
+ ),
+ array(
+ 'http',
+ 'https',
+ false,
+ ),
+ array(
+ 'https',
+ 'http',
+ false,
+ ),
+ array(
+ 'http',
+ 'http',
+ false,
+ ),
+ array(
+ 'http',
+ 'http',
+ true,
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 36918
- */
- public function test_new_blog_locale() {
- $current_site = get_current_site();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 36918
+ */
+ public function test_new_blog_locale() {
+ $current_site = get_current_site();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
- update_site_option( 'WPLANG', 'de_DE' );
- remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
+ update_site_option( 'WPLANG', 'de_DE' );
+ remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // No locale, use default locale.
- add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
- $blog_id = wpmu_create_blog( $current_site->domain, '/de-de/', 'New Blog', get_current_user_id() );
- remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // No locale, use default locale.
+ add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
+ $blog_id = wpmu_create_blog( $current_site->domain, '/de-de/', 'New Blog', get_current_user_id() );
+ remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotWPError( $blog_id );
- $this->assertSame( 'de_DE', get_blog_option( $blog_id, 'WPLANG' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotWPError( $blog_id );
+ $this->assertSame( 'de_DE', get_blog_option( $blog_id, 'WPLANG' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Custom locale.
- add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
- $blog_id = wpmu_create_blog( $current_site->domain, '/es-es/', 'New Blog', get_current_user_id(), array( 'WPLANG' => 'es_ES' ) );
- remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Custom locale.
+ add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
+ $blog_id = wpmu_create_blog( $current_site->domain, '/es-es/', 'New Blog', get_current_user_id(), array( 'WPLANG' => 'es_ES' ) );
+ remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotWPError( $blog_id );
- $this->assertSame( 'es_ES', get_blog_option( $blog_id, 'WPLANG' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotWPError( $blog_id );
+ $this->assertSame( 'es_ES', get_blog_option( $blog_id, 'WPLANG' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // en_US locale.
- add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
- $blog_id = wpmu_create_blog( $current_site->domain, '/en-us/', 'New Blog', get_current_user_id(), array( 'WPLANG' => '' ) );
- remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // en_US locale.
+ add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
+ $blog_id = wpmu_create_blog( $current_site->domain, '/en-us/', 'New Blog', get_current_user_id(), array( 'WPLANG' => '' ) );
+ remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotWPError( $blog_id );
- $this->assertSame( '', get_blog_option( $blog_id, 'WPLANG' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotWPError( $blog_id );
+ $this->assertSame( '', get_blog_option( $blog_id, 'WPLANG' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40503
- */
- public function test_different_network_language() {
- $network = get_network( self::$network_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40503
+ */
+ public function test_different_network_language() {
+ $network = get_network( self::$network_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG', 'wibble' );
- $blog_id = wpmu_create_blog( $network->domain, '/de-de/', 'New Blog', get_current_user_id(), array(), $network->id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG', 'wibble' );
+ $blog_id = wpmu_create_blog( $network->domain, '/de-de/', 'New Blog', get_current_user_id(), array(), $network->id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( get_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG' ), get_blog_option( $blog_id, 'WPLANG' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( get_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG' ), get_blog_option( $blog_id, 'WPLANG' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Allows to set the WPLANG option to any language.
- *
- * @param string $value The sanitized option value.
- * @param string $option The option name.
- * @param string $original_value The original value passed to the function.
- * @return string The original value.
- */
- public function filter_allow_unavailable_languages( $value, $option, $original_value ) {
- return $original_value;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Allows to set the WPLANG option to any language.
+ *
+ * @param string $value The sanitized option value.
+ * @param string $option The option name.
+ * @param string $original_value The original value passed to the function.
+ * @return string The original value.
+ */
+ public function filter_allow_unavailable_languages( $value, $option, $original_value ) {
+ return $original_value;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_is_main_site_different_network() {
- $this->assertTrue( is_main_site( self::$site_ids['make.wordpress.org/'], self::$network_ids['make.wordpress.org/'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_is_main_site_different_network() {
+ $this->assertTrue( is_main_site( self::$site_ids['make.wordpress.org/'], self::$network_ids['make.wordpress.org/'] ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 29684
- */
- public function test_is_main_site_different_network_random_site() {
- $this->assertFalse( is_main_site( self::$site_ids['make.wordpress.org/foo/'], self::$network_ids['make.wordpress.org/'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 29684
+ */
+ public function test_is_main_site_different_network_random_site() {
+ $this->assertFalse( is_main_site( self::$site_ids['make.wordpress.org/foo/'], self::$network_ids['make.wordpress.org/'] ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- * @dataProvider data_get_site_caches
- */
- public function test_clean_blog_cache( $key, $group ) {
- $site = get_site( self::$site_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ * @dataProvider data_get_site_caches
+ */
+ public function test_clean_blog_cache( $key, $group ) {
+ $site = get_site( self::$site_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $replacements = array(
- '%blog_id%' => $site->blog_id,
- '%domain%' => $site->domain,
- '%path%' => $site->path,
- '%domain_path_key%' => md5( $site->domain . $site->path ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $replacements = array(
+ '%blog_id%' => $site->blog_id,
+ '%domain%' => $site->domain,
+ '%path%' => $site->path,
+ '%domain_path_key%' => md5( $site->domain . $site->path ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups.
- wp_cache_set( $key, (object) $site->to_array(), $group );
- } else {
- wp_cache_set( $key, 'something', $group );
- }
-
- clean_blog_cache( $site );
- $this->assertFalse( wp_cache_get( $key, $group ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups.
+ wp_cache_set( $key, (object) $site->to_array(), $group );
+ } else {
+ wp_cache_set( $key, 'something', $group );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- * @dataProvider data_get_site_caches
- */
- public function test_clean_blog_cache_with_id( $key, $group ) {
- $site = get_site( self::$site_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( $site );
+ $this->assertFalse( wp_cache_get( $key, $group ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $replacements = array(
- '%blog_id%' => $site->blog_id,
- '%domain%' => $site->domain,
- '%path%' => $site->path,
- '%domain_path_key%' => md5( $site->domain . $site->path ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ * @dataProvider data_get_site_caches
+ */
+ public function test_clean_blog_cache_with_id( $key, $group ) {
+ $site = get_site( self::$site_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $replacements = array(
+ '%blog_id%' => $site->blog_id,
+ '%domain%' => $site->domain,
+ '%path%' => $site->path,
+ '%domain_path_key%' => md5( $site->domain . $site->path ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups.
- wp_cache_set( $key, (object) $site->to_array(), $group );
- } else {
- wp_cache_set( $key, 'something', $group );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_blog_cache( $site->blog_id );
- $this->assertFalse( wp_cache_get( $key, $group ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups.
+ wp_cache_set( $key, (object) $site->to_array(), $group );
+ } else {
+ wp_cache_set( $key, 'something', $group );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_clean_blog_cache_resets_last_changed() {
- $site = get_site( self::$site_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( $site->blog_id );
+ $this->assertFalse( wp_cache_get( $key, $group ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_cache_delete( 'last_changed', 'sites' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_clean_blog_cache_resets_last_changed() {
+ $site = get_site( self::$site_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_blog_cache( $site );
- $this->assertNotFalse( wp_cache_get( 'last_changed', 'sites' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_cache_delete( 'last_changed', 'sites' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_clean_blog_cache_fires_action() {
- $site = get_site( self::$site_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( $site );
+ $this->assertNotFalse( wp_cache_get( 'last_changed', 'sites' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $old_count = did_action( 'clean_site_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_clean_blog_cache_fires_action() {
+ $site = get_site( self::$site_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_blog_cache( $site );
- $this->assertSame( $old_count + 1, did_action( 'clean_site_cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $old_count = did_action( 'clean_site_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_clean_blog_cache_bails_on_suspend_cache_invalidation() {
- $site = get_site( self::$site_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( $site );
+ $this->assertSame( $old_count + 1, did_action( 'clean_site_cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $old_count = did_action( 'clean_site_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_clean_blog_cache_bails_on_suspend_cache_invalidation() {
+ $site = get_site( self::$site_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $suspend = wp_suspend_cache_invalidation();
- clean_blog_cache( $site );
- wp_suspend_cache_invalidation( $suspend );
- $this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $old_count = did_action( 'clean_site_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_clean_blog_cache_bails_on_empty_input() {
- $old_count = did_action( 'clean_site_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $suspend = wp_suspend_cache_invalidation();
+ clean_blog_cache( $site );
+ wp_suspend_cache_invalidation( $suspend );
+ $this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_blog_cache( null );
- $this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_clean_blog_cache_bails_on_empty_input() {
+ $old_count = did_action( 'clean_site_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_clean_blog_cache_bails_on_non_numeric_input() {
- $old_count = did_action( 'clean_site_cache' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( null );
+ $this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_blog_cache( 'something' );
- $this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_clean_blog_cache_bails_on_non_numeric_input() {
+ $old_count = did_action( 'clean_site_cache' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_clean_blog_cache_works_with_deleted_site() {
- $site_id = 12345;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( 'something' );
+ $this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_cache_set( $site_id, 'something', 'site-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_clean_blog_cache_works_with_deleted_site() {
+ $site_id = 12345;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_blog_cache( $site_id );
- $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_cache_set( $site_id, 'something', 'site-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- * @dataProvider data_get_site_caches
- */
- public function test_refresh_blog_details( $key, $group ) {
- $site = get_site( self::$site_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_blog_cache( $site_id );
+ $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $replacements = array(
- '%blog_id%' => $site->blog_id,
- '%domain%' => $site->domain,
- '%path%' => $site->path,
- '%domain_path_key%' => md5( $site->domain . $site->path ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ * @dataProvider data_get_site_caches
+ */
+ public function test_refresh_blog_details( $key, $group ) {
+ $site = get_site( self::$site_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $replacements = array(
+ '%blog_id%' => $site->blog_id,
+ '%domain%' => $site->domain,
+ '%path%' => $site->path,
+ '%domain_path_key%' => md5( $site->domain . $site->path ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups.
- wp_cache_set( $key, (object) $site->to_array(), $group );
- } else {
- wp_cache_set( $key, 'something', $group );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- refresh_blog_details( $site->blog_id );
- $this->assertFalse( wp_cache_get( $key, $group ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups.
+ wp_cache_set( $key, (object) $site->to_array(), $group );
+ } else {
+ wp_cache_set( $key, 'something', $group );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_refresh_blog_details_works_with_deleted_site() {
- $site_id = 12345;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ refresh_blog_details( $site->blog_id );
+ $this->assertFalse( wp_cache_get( $key, $group ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_cache_set( $site_id, 'something', 'site-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_refresh_blog_details_works_with_deleted_site() {
+ $site_id = 12345;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- refresh_blog_details( $site_id );
- $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_cache_set( $site_id, 'something', 'site-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40201
- */
- public function test_refresh_blog_details_uses_current_site_as_default() {
- $site_id = get_current_blog_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ refresh_blog_details( $site_id );
+ $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_cache_set( $site_id, 'something', 'site-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40201
+ */
+ public function test_refresh_blog_details_uses_current_site_as_default() {
+ $site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- refresh_blog_details();
- $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_cache_set( $site_id, 'something', 'site-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_get_site_caches() {
- return array(
- array( '%blog_id%', 'sites' ),
- array( '%blog_id%', 'site-details' ),
- array( '%blog_id%', 'blog-details' ),
- array( '%blog_id%' . 'short', 'blog-details' ),
- array( '%domain_path_key%', 'blog-lookup' ),
- array( '%domain_path_key%', 'blog-id-cache' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ refresh_blog_details();
+ $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- * @dataProvider data_wp_insert_site
- */
- public function test_wp_insert_site( $site_data, $expected_data ) {
- remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
- $site_id = wp_insert_site( $site_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_get_site_caches() {
+ return array(
+ array( '%blog_id%', 'sites' ),
+ array( '%blog_id%', 'site-details' ),
+ array( '%blog_id%', 'blog-details' ),
+ array( '%blog_id%' . 'short', 'blog-details' ),
+ array( '%domain_path_key%', 'blog-lookup' ),
+ array( '%domain_path_key%', 'blog-id-cache' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsInt( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ * @dataProvider data_wp_insert_site
+ */
+ public function test_wp_insert_site( $site_data, $expected_data ) {
+ remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
+ $site_id = wp_insert_site( $site_data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site( $site_id );
- foreach ( $expected_data as $key => $value ) {
- $this->assertEquals( $value, $site->$key );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( $site_id );
+
+ $site = get_site( $site_id );
+ foreach ( $expected_data as $key => $value ) {
+ $this->assertEquals( $value, $site->$key );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_insert_site() {
- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_insert_site() {
+ return array(
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com',
- ),
- array(
- 'domain' => 'example.com',
- 'path' => '/',
- 'network_id' => 1,
- 'public' => 1,
- 'archived' => 0,
- 'mature' => 0,
- 'spam' => 0,
- 'deleted' => 0,
- 'lang_id' => 0,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com',
- 'path' => '/foo',
- 'network_id' => 2,
- ),
- array(
- 'domain' => 'example.com',
- 'path' => '/foo/',
- 'network_id' => 2,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'path' => '/',
+ 'network_id' => 1,
+ 'public' => 1,
+ 'archived' => 0,
+ 'mature' => 0,
+ 'spam' => 0,
+ 'deleted' => 0,
+ 'lang_id' => 0,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com',
- 'path' => '/bar/',
- 'site_id' => 2,
- ),
- array(
- 'domain' => 'example.com',
- 'path' => '/bar/',
- 'network_id' => 2,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'path' => '/foo',
+ 'network_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com',
- 'path' => '/bar/',
- 'site_id' => 2,
- 'network_id' => 3,
- ),
- array(
- 'domain' => 'example.com',
- 'path' => '/bar/',
- 'network_id' => 3,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'path' => '/foo/',
+ 'network_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com',
- 'path' => 'foobar',
- 'public' => 0,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- 'lang_id' => 1,
- ),
- array(
- 'domain' => 'example.com',
- 'path' => '/foobar/',
- 'public' => 0,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- 'lang_id' => 1,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'path' => '/bar/',
+ 'site_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com:8888',
- ),
- array(
- 'domain' => 'example.com:8888',
- 'path' => '/',
- 'network_id' => 1,
- 'public' => 1,
- 'archived' => 0,
- 'mature' => 0,
- 'spam' => 0,
- 'deleted' => 0,
- 'lang_id' => 0,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'path' => '/bar/',
+ 'network_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
+ array(
+ 'domain' => 'example.com',
+ 'path' => '/bar/',
+ 'site_id' => 2,
+ 'network_id' => 3,
+ ),
+ array(
+ 'domain' => 'example.com',
+ 'path' => '/bar/',
+ 'network_id' => 3,
+ ),
+ ),
+ array(
+ array(
+ 'domain' => 'example.com',
+ 'path' => 'foobar',
+ 'public' => 0,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ 'lang_id' => 1,
+ ),
+ array(
+ 'domain' => 'example.com',
+ 'path' => '/foobar/',
+ 'public' => 0,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ 'lang_id' => 1,
+ ),
+ ),
+ array(
+ array(
+ 'domain' => 'example.com:8888',
+ ),
+ array(
+ 'domain' => 'example.com:8888',
+ 'path' => '/',
+ 'network_id' => 1,
+ 'public' => 1,
+ 'archived' => 0,
+ 'mature' => 0,
+ 'spam' => 0,
+ 'deleted' => 0,
+ 'lang_id' => 0,
+ ),
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 50324
- */
- public function test_wp_insert_site_with_clean_site_cache() {
- remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 50324
+ */
+ public function test_wp_insert_site_with_clean_site_cache() {
+ remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'clean_site_cache', array( $this, 'action_database_insert_on_clean_site_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'clean_site_cache', array( $this, 'action_database_insert_on_clean_site_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_id = wp_insert_site(
- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = wp_insert_site(
+ array(
+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( 'clean_site_cache', array( $this, 'action_database_insert_on_clean_site_cache' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( 'clean_site_cache', array( $this, 'action_database_insert_on_clean_site_cache' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsInt( $site_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( $site_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function action_database_insert_on_clean_site_cache() {
- update_site_option( 'database_write_test.' . time(), true );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function action_database_insert_on_clean_site_cache() {
+ update_site_option( 'database_write_test.' . time(), true );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_insert_site_empty_domain() {
- remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
- $site_id = wp_insert_site( array( 'public' => 0 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_insert_site_empty_domain() {
+ remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
+ $site_id = wp_insert_site( array( 'public' => 0 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertWPError( $site_id );
- $this->assertSame( 'site_empty_domain', $site_id->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertWPError( $site_id );
+ $this->assertSame( 'site_empty_domain', $site_id->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- * @dataProvider data_wp_update_site
- */
- public function test_wp_update_site( $site_data, $expected_data ) {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ * @dataProvider data_wp_update_site
+ */
+ public function test_wp_update_site( $site_data, $expected_data ) {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $old_site = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $old_site = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_update_site( $site_id, $site_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_update_site( $site_id, $site_data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $site_id, $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $site_id, $result );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_site = get_site( $site_id );
- foreach ( $new_site->to_array() as $key => $value ) {
- if ( isset( $expected_data[ $key ] ) ) {
- $this->assertEquals( $expected_data[ $key ], $value );
- } elseif ( 'last_updated' === $key ) {
- $this->assertLessThanOrEqual( $value, $old_site->last_updated );
- } else {
- $this->assertSame( $old_site->$key, $value );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $new_site = get_site( $site_id );
+ foreach ( $new_site->to_array() as $key => $value ) {
+ if ( isset( $expected_data[ $key ] ) ) {
+ $this->assertEquals( $expected_data[ $key ], $value );
+ } elseif ( 'last_updated' === $key ) {
+ $this->assertLessThanOrEqual( $value, $old_site->last_updated );
+ } else {
+ $this->assertSame( $old_site->$key, $value );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_update_site() {
- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_update_site() {
+ return array(
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com',
- 'network_id' => 2,
- ),
- array(
- 'domain' => 'example.com',
- 'site_id' => 2,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'network_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'path' => 'foo',
- ),
- array(
- 'path' => '/foo/',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example.com',
+ 'site_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'public' => 0,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- 'lang_id' => 1,
- ),
- array(
- 'public' => 0,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- 'lang_id' => 1,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'path' => 'foo',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example.com:8888',
- 'network_id' => 2,
- ),
- array(
- 'domain' => 'example.com:8888',
- 'site_id' => 2,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'path' => '/foo/',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
+ array(
+ 'public' => 0,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ 'lang_id' => 1,
+ ),
+ array(
+ 'public' => 0,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ 'lang_id' => 1,
+ ),
+ ),
+ array(
+ array(
+ 'domain' => 'example.com:8888',
+ 'network_id' => 2,
+ ),
+ array(
+ 'domain' => 'example.com:8888',
+ 'site_id' => 2,
+ ),
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_update_site_empty_domain() {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_update_site_empty_domain() {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_update_site( $site_id, array( 'domain' => '' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_update_site( $site_id, array( 'domain' => '' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertWPError( $result );
- $this->assertSame( 'site_empty_domain', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertWPError( $result );
+ $this->assertSame( 'site_empty_domain', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_update_site_invalid_id() {
- $result = wp_update_site( 444444, array( 'domain' => 'example.com' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_update_site_invalid_id() {
+ $result = wp_update_site( 444444, array( 'domain' => 'example.com' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertWPError( $result );
- $this->assertSame( 'site_not_exist', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertWPError( $result );
+ $this->assertSame( 'site_not_exist', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_update_site_cleans_cache() {
- $site_id = self::factory()->blog->create();
- $site1 = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_update_site_cleans_cache() {
+ $site_id = self::factory()->blog->create();
+ $site1 = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_update_site( $site_id, array( 'public' => 0 ) );
- $site2 = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_update_site( $site_id, array( 'public' => 0 ) );
+ $site2 = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_update_site( $site_id, array( 'public' => 1 ) );
- $site3 = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_update_site( $site_id, array( 'public' => 1 ) );
+ $site3 = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $site1->public );
- $this->assertSame( '0', $site2->public );
- $this->assertSame( '1', $site3->public );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $site1->public );
+ $this->assertSame( '0', $site2->public );
+ $this->assertSame( '1', $site3->public );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_delete_site() {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_delete_site() {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_delete_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertInstanceOf( 'WP_Site', $result );
- $this->assertSame( $result->to_array(), $site->to_array() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertInstanceOf( 'WP_Site', $result );
+ $this->assertSame( $result->to_array(), $site->to_array() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_delete_site_invalid_id() {
- $result = wp_delete_site( 444444 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_delete_site_invalid_id() {
+ $result = wp_delete_site( 444444 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertWPError( $result );
- $this->assertSame( 'site_not_exist', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertWPError( $result );
+ $this->assertSame( 'site_not_exist', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_delete_site_validate_site_deletion_action() {
- add_action( 'wp_validate_site_deletion', array( $this, 'action_wp_validate_site_deletion_prevent_deletion' ) );
- $result = wp_delete_site( self::$site_ids['make.wordpress.org/'] );
- $this->assertWPError( $result );
- $this->assertSame( 'action_does_not_like_deletion', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_delete_site_validate_site_deletion_action() {
+ add_action( 'wp_validate_site_deletion', array( $this, 'action_wp_validate_site_deletion_prevent_deletion' ) );
+ $result = wp_delete_site( self::$site_ids['make.wordpress.org/'] );
+ $this->assertWPError( $result );
+ $this->assertSame( 'action_does_not_like_deletion', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function action_wp_validate_site_deletion_prevent_deletion( $errors ) {
- $errors->add( 'action_does_not_like_deletion', 'You cannot delete this site because the action does not like it.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function action_wp_validate_site_deletion_prevent_deletion( $errors ) {
+ $errors->add( 'action_does_not_like_deletion', 'You cannot delete this site because the action does not like it.' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- * @dataProvider data_wp_normalize_site_data
- */
- public function test_wp_normalize_site_data( $data, $expected ) {
- $result = wp_normalize_site_data( $data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ * @dataProvider data_wp_normalize_site_data
+ */
+ public function test_wp_normalize_site_data( $data, $expected ) {
+ $result = wp_normalize_site_data( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSetsWithIndex( $expected, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSetsWithIndex( $expected, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_normalize_site_data() {
- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_normalize_site_data() {
+ return array(
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'network_id' => '4',
- ),
- array(
- 'network_id' => 4,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'network_id' => '4',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'invalid domain .com',
- 'path' => 'foo',
- ),
- array(
- 'domain' => 'invaliddomain.com',
- 'path' => '/foo/',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'network_id' => 4,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => '<yet>/another-invalid-domain.com',
- ),
- array(
- 'domain' => 'yetanother-invalid-domain.com',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'invalid domain .com',
+ 'path' => 'foo',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'with-port.com:8888',
- ),
- array(
- 'domain' => 'with-port.com:8888',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'invaliddomain.com',
+ 'path' => '/foo/',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'subdomain.with-port.com:8888',
- ),
- array(
- 'domain' => 'subdomain.with-port.com:8888',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => '<yet>/another-invalid-domain.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'path' => '',
- ),
- array(
- 'path' => '/',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'yetanother-invalid-domain.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'public' => '0',
- 'archived' => '1',
- 'mature' => '1',
- 'spam' => true,
- 'deleted' => true,
- ),
- array(
- 'public' => 0,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'with-port.com:8888',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'registered' => '',
- 'last_updated' => '',
- ),
- array(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'with-port.com:8888',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'registered' => '0000-00-00 00:00:00',
- 'last_updated' => '0000-00-00 00:00:00',
- ),
- array(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'subdomain.with-port.com:8888',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'domain' => 'subdomain.with-port.com:8888',
+ ),
+ ),
+ array(
+ array(
+ 'path' => '',
+ ),
+ array(
+ 'path' => '/',
+ ),
+ ),
+ array(
+ array(
+ 'public' => '0',
+ 'archived' => '1',
+ 'mature' => '1',
+ 'spam' => true,
+ 'deleted' => true,
+ ),
+ array(
+ 'public' => 0,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ ),
+ ),
+ array(
+ array(
+ 'registered' => '',
+ 'last_updated' => '',
+ ),
+ array(),
+ ),
+ array(
+ array(
+ 'registered' => '0000-00-00 00:00:00',
+ 'last_updated' => '0000-00-00 00:00:00',
+ ),
+ array(),
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- * @dataProvider data_wp_validate_site_data
- */
- public function test_wp_validate_site_data( $data, $expected_errors ) {
- $result = new WP_Error();
- wp_validate_site_data( $result, $data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ * @dataProvider data_wp_validate_site_data
+ */
+ public function test_wp_validate_site_data( $data, $expected_errors ) {
+ $result = new WP_Error();
+ wp_validate_site_data( $result, $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $expected_errors ) ) {
- $this->assertEmpty( $result->errors );
- } else {
- $this->assertSameSets( $expected_errors, array_keys( $result->errors ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $expected_errors ) ) {
+ $this->assertEmpty( $result->errors );
+ } else {
+ $this->assertSameSets( $expected_errors, array_keys( $result->errors ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_validate_site_data() {
- $date = current_time( 'mysql', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wp_validate_site_data() {
+ $date = current_time( 'mysql', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return array(
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example-site.com',
- 'path' => '/',
- 'network_id' => 1,
- 'registered' => $date,
- 'last_updated' => $date,
- ),
- array(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example-site.com',
+ 'path' => '/',
+ 'network_id' => 1,
+ 'registered' => $date,
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'path' => '/',
- 'network_id' => 1,
- 'registered' => $date,
- 'last_updated' => $date,
- ),
- array( 'site_empty_domain' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'path' => '/',
+ 'network_id' => 1,
+ 'registered' => $date,
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_empty_domain' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example-site.com',
- 'network_id' => 1,
- 'registered' => $date,
- 'last_updated' => $date,
- ),
- array( 'site_empty_path' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example-site.com',
+ 'network_id' => 1,
+ 'registered' => $date,
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_empty_path' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'example-site.com',
- 'path' => '/',
- 'registered' => $date,
- 'last_updated' => $date,
- ),
- array( 'site_empty_network_id' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'example-site.com',
+ 'path' => '/',
+ 'registered' => $date,
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_empty_network_id' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => get_site()->domain,
- 'path' => get_site()->path,
- 'network_id' => get_site()->network_id,
- 'registered' => $date,
- 'last_updated' => $date,
- ),
- array( 'site_taken' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => get_site()->domain,
+ 'path' => get_site()->path,
+ 'network_id' => get_site()->network_id,
+ 'registered' => $date,
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_taken' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- 'registered' => '',
- 'last_updated' => $date,
- ),
- array( 'site_empty_registered' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ 'registered' => '',
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_empty_registered' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- 'registered' => $date,
- 'last_updated' => '',
- ),
- array( 'site_empty_last_updated' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ 'registered' => $date,
+ 'last_updated' => '',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_empty_last_updated' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- 'registered' => '2000-13-32 25:25:61',
- 'last_updated' => $date,
- ),
- array( 'site_invalid_registered' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ 'registered' => '2000-13-32 25:25:61',
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_invalid_registered' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- 'registered' => $date,
- 'last_updated' => '2000-13-32 25:25:61',
- ),
- array( 'site_invalid_last_updated' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ 'registered' => $date,
+ 'last_updated' => '2000-13-32 25:25:61',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'site_invalid_last_updated' ),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- 'registered' => '0000-00-00 00:00:00',
- 'last_updated' => $date,
- ),
- array(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ 'registered' => '0000-00-00 00:00:00',
+ 'last_updated' => $date,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- 'registered' => $date,
- 'last_updated' => '0000-00-00 00:00:00',
- ),
- array(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ 'registered' => $date,
+ 'last_updated' => '0000-00-00 00:00:00',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(),
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_site_dates_are_gmt() {
- $first_date = current_time( 'mysql', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_site_dates_are_gmt() {
+ $first_date = current_time( 'mysql', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
- $site_id = wp_insert_site(
- array(
- 'domain' => 'valid-domain.com',
- 'path' => '/valid-path/',
- 'network_id' => 1,
- )
- );
- $this->assertIsInt( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
+ $site_id = wp_insert_site(
+ array(
+ 'domain' => 'valid-domain.com',
+ 'path' => '/valid-path/',
+ 'network_id' => 1,
+ )
+ );
+ $this->assertIsInt( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site( $site_id );
- $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' );
- $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->last_updated ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_site( $site_id );
+ $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' );
+ $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->last_updated ), 2, 'The dates should be equal' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $second_date = current_time( 'mysql', true );
- $site_id = wp_update_site( $site_id, array() );
- $this->assertIsInt( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $second_date = current_time( 'mysql', true );
+ $site_id = wp_update_site( $site_id, array() );
+ $this->assertIsInt( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site( $site_id );
- $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' );
- $this->assertEqualsWithDelta( strtotime( $second_date ), strtotime( $site->last_updated ), 2, 'The dates should be equal' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_site( $site_id );
+ $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' );
+ $this->assertEqualsWithDelta( strtotime( $second_date ), strtotime( $site->last_updated ), 2, 'The dates should be equal' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_delete_site_cleans_cache() {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_delete_site_cleans_cache() {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( get_site( $site_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNull( get_site( $site_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_update_site_cleans_old_cache_on_domain_change() {
- $old_domain = 'old.wordpress.org';
- $new_domain = 'new.wordpress.org';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_update_site_cleans_old_cache_on_domain_change() {
+ $old_domain = 'old.wordpress.org';
+ $new_domain = 'new.wordpress.org';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = self::factory()->blog->create_and_get(
- array(
- 'domain' => $old_domain,
- 'path' => '/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = self::factory()->blog->create_and_get(
+ array(
+ 'domain' => $old_domain,
+ 'path' => '/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Populate the caches.
- get_blog_details(
- array(
- 'domain' => $old_domain,
- 'path' => '/',
- )
- );
- get_blog_id_from_url( $old_domain, '/' );
- get_blog_details(
- array(
- 'domain' => $new_domain,
- 'path' => '/',
- )
- );
- get_blog_id_from_url( $new_domain, '/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Populate the caches.
+ get_blog_details(
+ array(
+ 'domain' => $old_domain,
+ 'path' => '/',
+ )
+ );
+ get_blog_id_from_url( $old_domain, '/' );
+ get_blog_details(
+ array(
+ 'domain' => $new_domain,
+ 'path' => '/',
+ )
+ );
+ get_blog_id_from_url( $new_domain, '/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_site(
- $site->id,
- array(
- 'domain' => $new_domain,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_site(
+ $site->id,
+ array(
+ 'domain' => $new_domain,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $domain_path_key_old = md5( $old_domain . '/' );
- $domain_path_key_new = md5( $new_domain . '/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $domain_path_key_old = md5( $old_domain . '/' );
+ $domain_path_key_new = md5( $new_domain . '/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Ensure all respective cache values are empty.
- $result = array(
- wp_cache_get( $domain_path_key_old, 'blog-lookup' ),
- wp_cache_get( $domain_path_key_old, 'blog-id-cache' ),
- wp_cache_get( 'current_blog_' . $old_domain, 'site-options' ),
- wp_cache_get( 'current_blog_' . $old_domain . '/', 'site-options' ),
- wp_cache_get( $domain_path_key_new, 'blog-lookup' ),
- wp_cache_get( $domain_path_key_new, 'blog-id-cache' ),
- wp_cache_get( 'current_blog_' . $new_domain, 'site-options' ),
- wp_cache_get( 'current_blog_' . $new_domain . '/', 'site-options' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Ensure all respective cache values are empty.
+ $result = array(
+ wp_cache_get( $domain_path_key_old, 'blog-lookup' ),
+ wp_cache_get( $domain_path_key_old, 'blog-id-cache' ),
+ wp_cache_get( 'current_blog_' . $old_domain, 'site-options' ),
+ wp_cache_get( 'current_blog_' . $old_domain . '/', 'site-options' ),
+ wp_cache_get( $domain_path_key_new, 'blog-lookup' ),
+ wp_cache_get( $domain_path_key_new, 'blog-id-cache' ),
+ wp_cache_get( 'current_blog_' . $new_domain, 'site-options' ),
+ wp_cache_get( 'current_blog_' . $new_domain . '/', 'site-options' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( array_filter( $result ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( array_filter( $result ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- */
- public function test_wp_update_site_cleans_old_cache_on_path_change() {
- $old_path = '/foo/';
- $new_path = '/bar/';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ */
+ public function test_wp_update_site_cleans_old_cache_on_path_change() {
+ $old_path = '/foo/';
+ $new_path = '/bar/';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = self::factory()->blog->create_and_get(
- array(
- 'domain' => 'test.wordpress.org',
- 'path' => $old_path,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = self::factory()->blog->create_and_get(
+ array(
+ 'domain' => 'test.wordpress.org',
+ 'path' => $old_path,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Populate the caches.
- get_blog_details(
- array(
- 'domain' => 'test.wordpress.org',
- 'path' => $old_path,
- )
- );
- get_blog_id_from_url( 'test.wordpress.org', $old_path );
- get_blog_details(
- array(
- 'domain' => 'test.wordpress.org',
- 'path' => $new_path,
- )
- );
- get_blog_id_from_url( 'test.wordpress.org', $new_path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Populate the caches.
+ get_blog_details(
+ array(
+ 'domain' => 'test.wordpress.org',
+ 'path' => $old_path,
+ )
+ );
+ get_blog_id_from_url( 'test.wordpress.org', $old_path );
+ get_blog_details(
+ array(
+ 'domain' => 'test.wordpress.org',
+ 'path' => $new_path,
+ )
+ );
+ get_blog_id_from_url( 'test.wordpress.org', $new_path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_site(
- $site->id,
- array(
- 'path' => $new_path,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_site(
+ $site->id,
+ array(
+ 'path' => $new_path,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $domain_path_key_old = md5( 'test.wordpress.org' . $old_path );
- $domain_path_key_new = md5( 'test.wordpress.org' . $new_path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $domain_path_key_old = md5( 'test.wordpress.org' . $old_path );
+ $domain_path_key_new = md5( 'test.wordpress.org' . $new_path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Ensure all respective cache values are empty.
- $result = array(
- wp_cache_get( $domain_path_key_old, 'blog-lookup' ),
- wp_cache_get( $domain_path_key_old, 'blog-id-cache' ),
- wp_cache_get( 'current_blog_test.wordpress.org' . $old_path, 'site-options' ),
- wp_cache_get( $domain_path_key_new, 'blog-lookup' ),
- wp_cache_get( $domain_path_key_new, 'blog-id-cache' ),
- wp_cache_get( 'current_blog_test.wordpress.org' . $new_path, 'site-options' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Ensure all respective cache values are empty.
+ $result = array(
+ wp_cache_get( $domain_path_key_old, 'blog-lookup' ),
+ wp_cache_get( $domain_path_key_old, 'blog-id-cache' ),
+ wp_cache_get( 'current_blog_test.wordpress.org' . $old_path, 'site-options' ),
+ wp_cache_get( $domain_path_key_new, 'blog-lookup' ),
+ wp_cache_get( $domain_path_key_new, 'blog-id-cache' ),
+ wp_cache_get( 'current_blog_test.wordpress.org' . $new_path, 'site-options' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( array_filter( $result ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( array_filter( $result ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40364
- * @dataProvider data_site_status_hook_triggers
- */
- public function test_site_status_hook_triggers( $insert_site_data, $expected_insert_hooks, $update_site_data, $expected_update_hooks ) {
- // First: Insert a site.
- $this->listen_to_site_status_hooks();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40364
+ * @dataProvider data_site_status_hook_triggers
+ */
+ public function test_site_status_hook_triggers( $insert_site_data, $expected_insert_hooks, $update_site_data, $expected_update_hooks ) {
+ // First: Insert a site.
+ $this->listen_to_site_status_hooks();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data = array_merge(
- array(
- 'domain' => 'example-site.com',
- 'path' => '/',
- ),
- $insert_site_data
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_data = array_merge(
+ array(
+ 'domain' => 'example-site.com',
+ 'path' => '/',
+ ),
+ $insert_site_data
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_id = wp_insert_site( $site_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = wp_insert_site( $site_data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $insert_expected = array_fill_keys( $expected_insert_hooks, $site_id );
- $insert_result = $this->get_listen_to_site_status_hooks_result();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $insert_expected = array_fill_keys( $expected_insert_hooks, $site_id );
+ $insert_result = $this->get_listen_to_site_status_hooks_result();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Second: Update that site.
- $this->listen_to_site_status_hooks();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Second: Update that site.
+ $this->listen_to_site_status_hooks();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_site( $site_id, $update_site_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_site( $site_id, $update_site_data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $update_expected = array_fill_keys( $expected_update_hooks, $site_id );
- $update_result = $this->get_listen_to_site_status_hooks_result();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $update_expected = array_fill_keys( $expected_update_hooks, $site_id );
+ $update_result = $this->get_listen_to_site_status_hooks_result();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check both insert and update results.
- $this->assertSameSetsWithIndex( $insert_expected, $insert_result );
- $this->assertSameSetsWithIndex( $update_expected, $update_result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check both insert and update results.
+ $this->assertSameSetsWithIndex( $insert_expected, $insert_result );
+ $this->assertSameSetsWithIndex( $update_expected, $update_result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_site_status_hook_triggers() {
- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_site_status_hook_triggers() {
+ return array(
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'public' => 1,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- ),
- array(
- 'archive_blog',
- 'mature_blog',
- 'make_spam_blog',
- 'make_delete_blog',
- ),
- array(
- 'public' => 0,
- 'archived' => 0,
- 'mature' => 0,
- 'spam' => 0,
- 'deleted' => 0,
- ),
- array(
- 'update_blog_public',
- 'unarchive_blog',
- 'unmature_blog',
- 'make_ham_blog',
- 'make_undelete_blog',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => 1,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'public' => 0,
- 'archived' => 0,
- 'mature' => 0,
- 'spam' => 0,
- 'deleted' => 0,
- ),
- array(
- 'update_blog_public',
- ),
- array(
- 'public' => 1,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- ),
- array(
- 'update_blog_public',
- 'archive_blog',
- 'mature_blog',
- 'make_spam_blog',
- 'make_delete_blog',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'archive_blog',
+ 'mature_blog',
+ 'make_spam_blog',
+ 'make_delete_blog',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'public' => 0,
- 'archived' => 0,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 1,
- ),
- array(
- 'update_blog_public',
- 'mature_blog',
- 'make_spam_blog',
- 'make_delete_blog',
- ),
- array(
- 'public' => 0,
- 'archived' => 1,
- 'mature' => 1,
- 'spam' => 1,
- 'deleted' => 0,
- ),
- array(
- 'archive_blog',
- 'make_undelete_blog',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => 0,
+ 'archived' => 0,
+ 'mature' => 0,
+ 'spam' => 0,
+ 'deleted' => 0,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'update_blog_public',
+ 'unarchive_blog',
+ 'unmature_blog',
+ 'make_ham_blog',
+ 'make_undelete_blog',
+ ),
+ ),
+ array(
+ array(
+ 'public' => 0,
+ 'archived' => 0,
+ 'mature' => 0,
+ 'spam' => 0,
+ 'deleted' => 0,
+ ),
+ array(
+ 'update_blog_public',
+ ),
+ array(
+ 'public' => 1,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ ),
+ array(
+ 'update_blog_public',
+ 'archive_blog',
+ 'mature_blog',
+ 'make_spam_blog',
+ 'make_delete_blog',
+ ),
+ ),
+ array(
+ array(
+ 'public' => 0,
+ 'archived' => 0,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 1,
+ ),
+ array(
+ 'update_blog_public',
+ 'mature_blog',
+ 'make_spam_blog',
+ 'make_delete_blog',
+ ),
+ array(
+ 'public' => 0,
+ 'archived' => 1,
+ 'mature' => 1,
+ 'spam' => 1,
+ 'deleted' => 0,
+ ),
+ array(
+ 'archive_blog',
+ 'make_undelete_blog',
+ ),
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private function listen_to_site_status_hooks() {
- $this->site_status_hooks = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function listen_to_site_status_hooks() {
+ $this->site_status_hooks = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hooknames = array(
- 'make_spam_blog',
- 'make_ham_blog',
- 'mature_blog',
- 'unmature_blog',
- 'archive_blog',
- 'unarchive_blog',
- 'make_delete_blog',
- 'make_undelete_blog',
- 'update_blog_public',
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hooknames = array(
+ 'make_spam_blog',
+ 'make_ham_blog',
+ 'mature_blog',
+ 'unmature_blog',
+ 'archive_blog',
+ 'unarchive_blog',
+ 'make_delete_blog',
+ 'make_undelete_blog',
+ 'update_blog_public',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $hooknames as $hookname ) {
- add_action( $hookname, array( $this, 'action_site_status_hook' ), 10, 1 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $hooknames as $hookname ) {
+ add_action( $hookname, array( $this, 'action_site_status_hook' ), 10, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private function get_listen_to_site_status_hooks_result() {
- $hooknames = array(
- 'make_spam_blog',
- 'make_ham_blog',
- 'mature_blog',
- 'unmature_blog',
- 'archive_blog',
- 'unarchive_blog',
- 'make_delete_blog',
- 'make_undelete_blog',
- 'update_blog_public',
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function get_listen_to_site_status_hooks_result() {
+ $hooknames = array(
+ 'make_spam_blog',
+ 'make_ham_blog',
+ 'mature_blog',
+ 'unmature_blog',
+ 'archive_blog',
+ 'unarchive_blog',
+ 'make_delete_blog',
+ 'make_undelete_blog',
+ 'update_blog_public',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $hooknames as $hookname ) {
- remove_action( $hookname, array( $this, 'action_site_status_hook' ), 10 );
- }
-
- return $this->site_status_hooks;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $hooknames as $hookname ) {
+ remove_action( $hookname, array( $this, 'action_site_status_hook' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function action_site_status_hook( $site_id ) {
- $this->site_status_hooks[ current_action() ] = $site_id;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->site_status_hooks;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- * @dataProvider data_wp_initialize_site
- */
- public function test_wp_initialize_site( $args, $expected_options, $expected_meta ) {
- $result = wp_initialize_site( self::$uninitialized_site_id, $args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function action_site_status_hook( $site_id ) {
+ $this->site_status_hooks[ current_action() ] = $site_id;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( self::$uninitialized_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ * @dataProvider data_wp_initialize_site
+ */
+ public function test_wp_initialize_site( $args, $expected_options, $expected_meta ) {
+ $result = wp_initialize_site( self::$uninitialized_site_id, $args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $options = array();
- foreach ( $expected_options as $option => $value ) {
- $options[ $option ] = get_option( $option );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( self::$uninitialized_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = array();
- foreach ( $expected_meta as $meta_key => $value ) {
- $meta[ $meta_key ] = get_site_meta( self::$uninitialized_site_id, $meta_key, true );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options = array();
+ foreach ( $expected_options as $option => $value ) {
+ $options[ $option ] = get_option( $option );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = array();
+ foreach ( $expected_meta as $meta_key => $value ) {
+ $meta[ $meta_key ] = get_site_meta( self::$uninitialized_site_id, $meta_key, true );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $initialized = wp_is_site_initialized( self::$uninitialized_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_uninitialize_site( self::$uninitialized_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $initialized = wp_is_site_initialized( self::$uninitialized_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- $this->assertTrue( $initialized );
- $this->assertSame( $expected_options, $options );
- $this->assertSame( $expected_meta, $meta );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_uninitialize_site( self::$uninitialized_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_initialize_site() {
- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ $this->assertTrue( $initialized );
+ $this->assertSame( $expected_options, $options );
+ $this->assertSame( $expected_meta, $meta );
+ }
+
+ public function data_wp_initialize_site() {
+ return array(
+ array(
+ array(),
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(),
- array(
- 'home' => 'http://uninitialized.org',
- 'siteurl' => 'http://uninitialized.org',
- 'admin_email' => '',
- 'blog_public' => '1',
- ),
- array(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'home' => 'http://uninitialized.org',
+ 'siteurl' => 'http://uninitialized.org',
+ 'admin_email' => '',
+ 'blog_public' => '1',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(),
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'options' => array(
- 'home' => 'https://uninitialized.org',
- 'siteurl' => 'https://uninitialized.org',
- 'key' => 'value',
- ),
- 'meta' => array(
- 'key1' => 'value1',
- 'key2' => 'value2',
- ),
- ),
- array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'options' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'home' => 'https://uninitialized.org',
</span><span class="cx" style="display: block; padding: 0 10px"> 'siteurl' => 'https://uninitialized.org',
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'value',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'meta' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'key1' => 'value1',
</span><span class="cx" style="display: block; padding: 0 10px"> 'key2' => 'value2',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'key3' => '',
</del><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'title' => 'My New Site',
- 'options' => array(
- 'blogdescription' => 'Just My New Site',
- ),
- ),
- array(
- 'blogname' => 'My New Site',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'home' => 'https://uninitialized.org',
+ 'siteurl' => 'https://uninitialized.org',
+ 'key' => 'value',
+ ),
+ array(
+ 'key1' => 'value1',
+ 'key2' => 'value2',
+ 'key3' => '',
+ ),
+ ),
+ array(
+ array(
+ 'title' => 'My New Site',
+ 'options' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'blogdescription' => 'Just My New Site',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(),
</del><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'blogname' => 'My New Site',
+ 'blogdescription' => 'Just My New Site',
+ ),
+ array(),
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_initialize_site_user_roles() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_initialize_site_user_roles() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_initialize_site( self::$uninitialized_site_id, array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_initialize_site( self::$uninitialized_site_id, array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( self::$uninitialized_site_id );
- $table_prefix = $wpdb->get_blog_prefix( self::$uninitialized_site_id );
- $roles = get_option( $table_prefix . 'user_roles' );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( self::$uninitialized_site_id );
+ $table_prefix = $wpdb->get_blog_prefix( self::$uninitialized_site_id );
+ $roles = get_option( $table_prefix . 'user_roles' );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_uninitialize_site( self::$uninitialized_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_uninitialize_site( self::$uninitialized_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- $this->assertSameSets(
- array(
- 'administrator',
- 'editor',
- 'author',
- 'contributor',
- 'subscriber',
- ),
- array_keys( $roles )
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ $this->assertSameSets(
+ array(
+ 'administrator',
+ 'editor',
+ 'author',
+ 'contributor',
+ 'subscriber',
+ ),
+ array_keys( $roles )
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_initialize_site_user_is_admin() {
- $result = wp_initialize_site( self::$uninitialized_site_id, array( 'user_id' => 1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_initialize_site_user_is_admin() {
+ $result = wp_initialize_site( self::$uninitialized_site_id, array( 'user_id' => 1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( self::$uninitialized_site_id );
- $user_is_admin = user_can( 1, 'manage_options' );
- $admin_email = get_option( 'admin_email' );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( self::$uninitialized_site_id );
+ $user_is_admin = user_can( 1, 'manage_options' );
+ $admin_email = get_option( 'admin_email' );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_uninitialize_site( self::$uninitialized_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_uninitialize_site( self::$uninitialized_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- $this->assertTrue( $user_is_admin );
- $this->assertSame( get_userdata( 1 )->user_email, $admin_email );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ $this->assertTrue( $user_is_admin );
+ $this->assertSame( get_userdata( 1 )->user_email, $admin_email );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_initialize_site_args_filter() {
- add_filter( 'wp_initialize_site_args', array( $this, 'filter_wp_initialize_site_args' ), 10, 3 );
- $result = wp_initialize_site( self::$uninitialized_site_id, array( 'title' => 'My Site' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_initialize_site_args_filter() {
+ add_filter( 'wp_initialize_site_args', array( $this, 'filter_wp_initialize_site_args' ), 10, 3 );
+ $result = wp_initialize_site( self::$uninitialized_site_id, array( 'title' => 'My Site' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( self::$uninitialized_site_id );
- $site_title = get_option( 'blogname' );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( self::$uninitialized_site_id );
+ $site_title = get_option( 'blogname' );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_uninitialize_site( self::$uninitialized_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_uninitialize_site( self::$uninitialized_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame(
- sprintf( 'My Site %1$d in Network %2$d', self::$uninitialized_site_id, get_site( self::$uninitialized_site_id )->network_id ),
- $site_title
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame(
+ sprintf( 'My Site %1$d in Network %2$d', self::$uninitialized_site_id, get_site( self::$uninitialized_site_id )->network_id ),
+ $site_title
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_wp_initialize_site_args( $args, $site, $network ) {
- $args['title'] = sprintf( 'My Site %1$d in Network %2$d', $site->id, $network->id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_wp_initialize_site_args( $args, $site, $network ) {
+ $args['title'] = sprintf( 'My Site %1$d in Network %2$d', $site->id, $network->id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $args;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $args;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_initialize_site_empty_id() {
- $result = wp_initialize_site( 0 );
- $this->assertWPError( $result );
- $this->assertSame( 'site_empty_id', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_initialize_site_empty_id() {
+ $result = wp_initialize_site( 0 );
+ $this->assertWPError( $result );
+ $this->assertSame( 'site_empty_id', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_initialize_site_invalid_id() {
- $result = wp_initialize_site( 123 );
- $this->assertWPError( $result );
- $this->assertSame( 'site_invalid_id', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_initialize_site_invalid_id() {
+ $result = wp_initialize_site( 123 );
+ $this->assertWPError( $result );
+ $this->assertSame( 'site_invalid_id', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_initialize_site_already_initialized() {
- $result = wp_initialize_site( get_current_blog_id() );
- $this->assertWPError( $result );
- $this->assertSame( 'site_already_initialized', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_initialize_site_already_initialized() {
+ $result = wp_initialize_site( get_current_blog_id() );
+ $this->assertWPError( $result );
+ $this->assertSame( 'site_already_initialized', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_uninitialize_site() {
- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_uninitialize_site() {
+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wp_uninitialize_site( $site_id );
- $this->assertTrue( $result );
- $this->assertFalse( wp_is_site_initialized( $site_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wp_uninitialize_site( $site_id );
+ $this->assertTrue( $result );
+ $this->assertFalse( wp_is_site_initialized( $site_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_uninitialize_site_empty_id() {
- $result = wp_uninitialize_site( 0 );
- $this->assertWPError( $result );
- $this->assertSame( 'site_empty_id', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_uninitialize_site_empty_id() {
+ $result = wp_uninitialize_site( 0 );
+ $this->assertWPError( $result );
+ $this->assertSame( 'site_empty_id', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_uninitialize_site_invalid_id() {
- $result = wp_uninitialize_site( 123 );
- $this->assertWPError( $result );
- $this->assertSame( 'site_invalid_id', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_uninitialize_site_invalid_id() {
+ $result = wp_uninitialize_site( 123 );
+ $this->assertWPError( $result );
+ $this->assertSame( 'site_invalid_id', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_uninitialize_site_already_uninitialized() {
- $result = wp_uninitialize_site( self::$uninitialized_site_id );
- $this->assertWPError( $result );
- $this->assertSame( 'site_already_uninitialized', $result->get_error_code() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_uninitialize_site_already_uninitialized() {
+ $result = wp_uninitialize_site( self::$uninitialized_site_id );
+ $this->assertWPError( $result );
+ $this->assertSame( 'site_already_uninitialized', $result->get_error_code() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_is_site_initialized() {
- $this->assertTrue( wp_is_site_initialized( get_current_blog_id() ) );
- $this->assertFalse( wp_is_site_initialized( self::$uninitialized_site_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_is_site_initialized() {
+ $this->assertTrue( wp_is_site_initialized( get_current_blog_id() ) );
+ $this->assertFalse( wp_is_site_initialized( self::$uninitialized_site_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_is_site_initialized_prefilter() {
- add_filter( 'pre_wp_is_site_initialized', '__return_false' );
- $this->assertFalse( wp_is_site_initialized( get_current_blog_id() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_is_site_initialized_prefilter() {
+ add_filter( 'pre_wp_is_site_initialized', '__return_false' );
+ $this->assertFalse( wp_is_site_initialized( get_current_blog_id() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'pre_wp_is_site_initialized', '__return_true' );
- $this->assertTrue( wp_is_site_initialized( self::$uninitialized_site_id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'pre_wp_is_site_initialized', '__return_true' );
+ $this->assertTrue( wp_is_site_initialized( self::$uninitialized_site_id ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41333
- */
- public function test_wp_insert_site_forwards_args_to_wp_initialize_site() {
- $args = array(
- 'user_id' => 1,
- 'title' => 'My Site',
- 'options' => array( 'option1' => 'value1' ),
- 'meta' => array( 'meta1' => 'value1' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41333
+ */
+ public function test_wp_insert_site_forwards_args_to_wp_initialize_site() {
+ $args = array(
+ 'user_id' => 1,
+ 'title' => 'My Site',
+ 'options' => array( 'option1' => 'value1' ),
+ 'meta' => array( 'meta1' => 'value1' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'wp_initialize_site_args', array( $this, 'filter_wp_initialize_site_args_catch_args' ) );
- $site_id = wp_insert_site(
- array_merge(
- array(
- 'domain' => 'testsite.org',
- 'path' => '/',
- ),
- $args
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'wp_initialize_site_args', array( $this, 'filter_wp_initialize_site_args_catch_args' ) );
+ $site_id = wp_insert_site(
+ array_merge(
+ array(
+ 'domain' => 'testsite.org',
+ 'path' => '/',
+ ),
+ $args
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $passed_args = $this->wp_initialize_site_args;
- $this->wp_initialize_site_args = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $passed_args = $this->wp_initialize_site_args;
+ $this->wp_initialize_site_args = null;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSetsWithIndex( $args, $passed_args );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSetsWithIndex( $args, $passed_args );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_wp_initialize_site_args_catch_args( $args ) {
- $this->wp_initialize_site_args = $args;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_wp_initialize_site_args_catch_args( $args ) {
+ $this->wp_initialize_site_args = $args;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $args;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $args;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 46125
- */
- public function test_wpmu_create_blog_cache_cleanup_backward_compatible() {
- add_action( 'populate_options', array( $this, 'populate_options_callback' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 46125
+ */
+ public function test_wpmu_create_blog_cache_cleanup_backward_compatible() {
+ add_action( 'populate_options', array( $this, 'populate_options_callback' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = wpmu_create_blog( 'testsite1.example.org', '/test', 'test', 1, array( 'public' => 1 ), 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = wpmu_create_blog( 'testsite1.example.org', '/test', 'test', 1, array( 'public' => 1 ), 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Should not hit blog_details cache initialized in $this->populate_options_callback triggered during
- * populate_options callback's call of get_blog_details.
- */
- $this->assertSame( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl );
- $this->assertSame( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Should not hit blog_details cache initialized in $this->populate_options_callback triggered during
+ * populate_options callback's call of get_blog_details.
+ */
+ $this->assertSame( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl );
+ $this->assertSame( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( 'populate_options', array( $this, 'populate_options_callback' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( 'populate_options', array( $this, 'populate_options_callback' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Populate options callback to warm cache for blog-details / site-details cache group
- */
- public function populate_options_callback() {
- // Cache blog details.
- $blog_id = get_current_blog_id();
- get_blog_details( $blog_id );
- get_site( $blog_id )->siteurl;
- // Set siteurl.
- update_option( 'siteurl', 'http://testsite1.example.org/test' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Populate options callback to warm cache for blog-details / site-details cache group
+ */
+ public function populate_options_callback() {
+ // Cache blog details.
+ $blog_id = get_current_blog_id();
+ get_blog_details( $blog_id );
+ get_site( $blog_id )->siteurl;
+ // Set siteurl.
+ update_option( 'siteurl', 'http://testsite1.example.org/test' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests whether all expected meta are provided in deprecated `wpmu_new_blog` action.
- *
- * @dataProvider data_wpmu_new_blog_action_backward_compatible
- *
- * @ticket 46351
- */
- public function test_wpmu_new_blog_action_backward_compatible( $meta, $expected_meta ) {
- // We are testing deprecated hook. Register it to expected deprecated notices.
- $this->setExpectedDeprecated( 'wpmu_new_blog' );
- add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog_callback' ), 10, 6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tests whether all expected meta are provided in deprecated `wpmu_new_blog` action.
+ *
+ * @dataProvider data_wpmu_new_blog_action_backward_compatible
+ *
+ * @ticket 46351
+ */
+ public function test_wpmu_new_blog_action_backward_compatible( $meta, $expected_meta ) {
+ // We are testing deprecated hook. Register it to expected deprecated notices.
+ $this->setExpectedDeprecated( 'wpmu_new_blog' );
+ add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog_callback' ), 10, 6 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_create_blog( 'testsite1.example.org', '/new-blog/', 'New Blog', get_current_user_id(), $meta, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_create_blog( 'testsite1.example.org', '/new-blog/', 'New Blog', get_current_user_id(), $meta, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSetsWithIndex( $expected_meta, $this->wp_initialize_site_meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSetsWithIndex( $expected_meta, $this->wp_initialize_site_meta );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->wp_initialize_site_meta = array();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->wp_initialize_site_meta = array();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 42251
- */
- public function test_get_site_not_found_cache() {
- $new_site_id = $this->_get_next_site_id();
- $this->assertNull( get_site( $new_site_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 42251
+ */
+ public function test_get_site_not_found_cache() {
+ $new_site_id = $this->_get_next_site_id();
+ $this->assertNull( get_site( $new_site_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
- $this->assertNull( get_site( $new_site_id ) );
- $this->assertSame( $num_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
+ $this->assertNull( get_site( $new_site_id ) );
+ $this->assertSame( $num_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 42251
- */
- public function test_get_site_not_found_cache_clear() {
- $new_site_id = $this->_get_next_site_id();
- $this->assertNull( get_site( $new_site_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 42251
+ */
+ public function test_get_site_not_found_cache_clear() {
+ $new_site_id = $this->_get_next_site_id();
+ $this->assertNull( get_site( $new_site_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_site = self::factory()->blog->create_and_get();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $new_site = self::factory()->blog->create_and_get();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Double-check we got the ID of the new site correct.
- $this->assertEquals( $new_site_id, $new_site->blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Double-check we got the ID of the new site correct.
+ $this->assertEquals( $new_site_id, $new_site->blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Verify that if we fetch the site now, it's no longer false.
- $fetched_site = get_site( $new_site_id );
- $this->assertInstanceOf( 'WP_Site', $fetched_site );
- $this->assertEquals( $new_site_id, $fetched_site->blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Verify that if we fetch the site now, it's no longer false.
+ $fetched_site = get_site( $new_site_id );
+ $this->assertInstanceOf( 'WP_Site', $fetched_site );
+ $this->assertEquals( $new_site_id, $fetched_site->blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Gets the ID of the next site that will get inserted
- * @return int
- */
- protected function _get_next_site_id() {
- global $wpdb;
- // Create an entry.
- static::factory()->blog->create();
- // Get the ID after it.
- return (int) $wpdb->get_var( 'SELECT blog_id FROM ' . $wpdb->blogs . ' ORDER BY blog_ID DESC LIMIT 1' ) + 1;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Gets the ID of the next site that will get inserted
+ * @return int
+ */
+ protected function _get_next_site_id() {
+ global $wpdb;
+ // Create an entry.
+ static::factory()->blog->create();
+ // Get the ID after it.
+ return (int) $wpdb->get_var( 'SELECT blog_id FROM ' . $wpdb->blogs . ' ORDER BY blog_ID DESC LIMIT 1' ) + 1;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Capture the $meta value passed to the wpmu_new_blog action and compare it.
- */
- public function wpmu_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
- $this->wp_initialize_site_meta = $meta;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Capture the $meta value passed to the wpmu_new_blog action and compare it.
+ */
+ public function wpmu_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
+ $this->wp_initialize_site_meta = $meta;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wpmu_new_blog_action_backward_compatible() {
- return array(
- 'default values' => array(
- array(),
- array(
- 'public' => 0, // `public` is one of the default metas in `wpmu_create_blog()' function prior to WordPress 5.1.0.
- 'WPLANG' => 'en_US', // WPLANG is another default meta in `wpmu_create_blog()` function prior to WordPress 5.1.0.
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_wpmu_new_blog_action_backward_compatible() {
+ return array(
+ 'default values' => array(
+ array(),
+ array(
+ 'public' => 0, // `public` is one of the default metas in `wpmu_create_blog()' function prior to WordPress 5.1.0.
+ 'WPLANG' => 'en_US', // WPLANG is another default meta in `wpmu_create_blog()` function prior to WordPress 5.1.0.
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'public site' => array(
- array(
- 'public' => 1,
- ),
- array(
- 'public' => 1,
- 'WPLANG' => 'en_US',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ 'public site' => array(
+ array(
+ 'public' => 1,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'allowed_keys' => array(
- array(
- 'public' => -1,
- 'archived' => 0,
- 'mature' => 0,
- 'spam' => 0,
- 'deleted' => 0,
- 'lang_id' => 11,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'public' => 1,
+ 'WPLANG' => 'en_US',
+ ),
+ ),
+ 'allowed_keys' => array(
+ array(
+ 'public' => -1,
+ 'archived' => 0,
+ 'mature' => 0,
+ 'spam' => 0,
+ 'deleted' => 0,
+ 'lang_id' => 11,
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ),
- array(
- 'public' => -1,
- 'WPLANG' => 'en_US',
- 'archived' => 0,
- 'mature' => 0,
- 'spam' => 0,
- 'deleted' => 0,
- 'lang_id' => 11,
- ),
</del><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'extra meta key' => array(
- array(
- 'foo' => 'bar',
- ),
- array(
- 'public' => 0,
- 'foo' => 'bar',
- 'WPLANG' => 'en_US',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'public' => -1,
+ 'WPLANG' => 'en_US',
+ 'archived' => 0,
+ 'mature' => 0,
+ 'spam' => 0,
+ 'deleted' => 0,
+ 'lang_id' => 11,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ 'extra meta key' => array(
+ array(
+ 'foo' => 'bar',
+ ),
+ array(
+ 'public' => 0,
+ 'foo' => 'bar',
+ 'WPLANG' => 'en_US',
+ ),
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitesiteDetailsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/siteDetails.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/siteDetails.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/siteDetails.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,192 +1,191 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Test 'site_details' functionality.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_SiteDetails extends WP_UnitTestCase {
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Test 'site_details' functionality.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @dataProvider data_allowed_options
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-site
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 40063
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_SiteDetails extends WP_UnitTestCase {
- /**
- * @dataProvider data_allowed_options
- *
- * @ticket 40063
- */
- public function test_update_allowed_option_deletes_site_details_cache( $allowed_option, $temporary_value ) {
- $site = get_site();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_allowed_option_deletes_site_details_cache( $allowed_option, $temporary_value ) {
+ $site = get_site();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_value = $site->$allowed_option;
- update_option( $allowed_option, $temporary_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_value = $site->$allowed_option;
+ update_option( $allowed_option, $temporary_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_result = wp_cache_get( $site->id, 'site-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cached_result = wp_cache_get( $site->id, 'site-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Reset to original value. */
- update_option( $allowed_option, $original_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* Reset to original value. */
+ update_option( $allowed_option, $original_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $cached_result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $cached_result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_allowed_options
- *
- * @ticket 40063
- */
- public function test_update_allowed_option_deletes_blog_details_cache( $allowed_option, $temporary_value ) {
- $blog_details = get_blog_details();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_allowed_options
+ *
+ * @ticket 40063
+ */
+ public function test_update_allowed_option_deletes_blog_details_cache( $allowed_option, $temporary_value ) {
+ $blog_details = get_blog_details();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_value = $blog_details->$allowed_option;
- update_option( $allowed_option, $temporary_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_value = $blog_details->$allowed_option;
+ update_option( $allowed_option, $temporary_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_result = wp_cache_get( $blog_details->id, 'blog-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cached_result = wp_cache_get( $blog_details->id, 'blog-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Reset to original value. */
- update_option( $allowed_option, $original_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* Reset to original value. */
+ update_option( $allowed_option, $original_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $cached_result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $cached_result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_allowed_options
- *
- * @ticket 40063
- */
- public function test_update_allowed_option_does_not_delete_site_cache( $allowed_option, $temporary_value ) {
- $site = get_site();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_allowed_options
+ *
+ * @ticket 40063
+ */
+ public function test_update_allowed_option_does_not_delete_site_cache( $allowed_option, $temporary_value ) {
+ $site = get_site();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_value = $site->$allowed_option;
- update_option( $allowed_option, $temporary_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_value = $site->$allowed_option;
+ update_option( $allowed_option, $temporary_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_result = wp_cache_get( $site->id, 'sites' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cached_result = wp_cache_get( $site->id, 'sites' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Reset to original value. */
- update_option( $allowed_option, $original_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* Reset to original value. */
+ update_option( $allowed_option, $original_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotFalse( $cached_result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotFalse( $cached_result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_allowed_options
- *
- * @ticket 40063
- */
- public function test_update_allowed_option_does_not_delete_short_blog_details_cache( $allowed_option, $temporary_value ) {
- $blog_details = get_blog_details( null, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_allowed_options
+ *
+ * @ticket 40063
+ */
+ public function test_update_allowed_option_does_not_delete_short_blog_details_cache( $allowed_option, $temporary_value ) {
+ $blog_details = get_blog_details( null, false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_value = get_option( $allowed_option );
- update_option( $allowed_option, $temporary_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_value = get_option( $allowed_option );
+ update_option( $allowed_option, $temporary_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_result = wp_cache_get( $blog_details->id . 'short', 'blog-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cached_result = wp_cache_get( $blog_details->id . 'short', 'blog-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Reset to original value. */
- update_option( $allowed_option, $original_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* Reset to original value. */
+ update_option( $allowed_option, $original_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotFalse( $cached_result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotFalse( $cached_result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_allowed_options
- *
- * @ticket 40063
- */
- public function test_update_allowed_option_does_not_update_sites_last_changed( $allowed_option, $temporary_value ) {
- $last_changed = wp_cache_get_last_changed( 'sites' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_allowed_options
+ *
+ * @ticket 40063
+ */
+ public function test_update_allowed_option_does_not_update_sites_last_changed( $allowed_option, $temporary_value ) {
+ $last_changed = wp_cache_get_last_changed( 'sites' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_value = get_option( $allowed_option );
- update_option( $allowed_option, $temporary_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_value = get_option( $allowed_option );
+ update_option( $allowed_option, $temporary_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_last_changed = wp_cache_get_last_changed( 'sites' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $new_last_changed = wp_cache_get_last_changed( 'sites' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Reset to original value. */
- update_option( $allowed_option, $original_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* Reset to original value. */
+ update_option( $allowed_option, $original_value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $new_last_changed, $last_changed );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $new_last_changed, $last_changed );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_allowed_options() {
- return array(
- array( 'blogname', 'Custom Site' ),
- array( 'home', 'http://custom-site-url.org' ),
- array( 'siteurl', 'http://custom-site-url.org' ),
- array( 'post_count', '4' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_allowed_options() {
+ return array(
+ array( 'blogname', 'Custom Site' ),
+ array( 'home', 'http://custom-site-url.org' ),
+ array( 'siteurl', 'http://custom-site-url.org' ),
+ array( 'post_count', '4' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40063
- */
- public function test_update_random_blog_option_does_not_delete_cache() {
- $site = get_site();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40063
+ */
+ public function test_update_random_blog_option_does_not_delete_cache() {
+ $site = get_site();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_option( 'foobar_option', 'foobar_value' );
- $cached_result = wp_cache_get( $site->id, 'sites' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_option( 'foobar_option', 'foobar_value' );
+ $cached_result = wp_cache_get( $site->id, 'sites' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_option( 'foobar_option' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_option( 'foobar_option' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotFalse( $cached_result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotFalse( $cached_result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40247
- */
- public function test_site_details_cached_including_false_values() {
- $id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40247
+ */
+ public function test_site_details_cached_including_false_values() {
+ $id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site = get_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Trigger retrieving site details (post_count is not set on new sites).
- $post_count = $site->post_count;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Trigger retrieving site details (post_count is not set on new sites).
+ $post_count = $site->post_count;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_details = wp_cache_get( $site->id, 'site-details' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cached_details = wp_cache_get( $site->id, 'site-details' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $id );
- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $id );
+ wp_update_network_site_counts();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotFalse( $cached_details );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotFalse( $cached_details );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_site_details_filter_with_blogname() {
- add_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) );
- $site = get_site();
- $blogname = $site->blogname;
- remove_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_site_details_filter_with_blogname() {
+ add_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) );
+ $site = get_site();
+ $blogname = $site->blogname;
+ remove_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'Foo Bar', $blogname );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'Foo Bar', $blogname );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function _filter_site_details_blogname( $details ) {
- $details->blogname = 'Foo Bar';
- return $details;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_site_details_blogname( $details ) {
+ $details->blogname = 'Foo Bar';
+ return $details;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40458
- */
- public function test_site_details_filter_with_custom_value_isetter() {
- add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
- $site = get_site();
- $custom_value_isset = isset( $site->custom_value );
- remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40458
+ */
+ public function test_site_details_filter_with_custom_value_isetter() {
+ add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
+ $site = get_site();
+ $custom_value_isset = isset( $site->custom_value );
+ remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $custom_value_isset );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $custom_value_isset );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40458
- */
- public function test_site_details_filter_with_custom_value_getter() {
- add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
- $site = get_site();
- $custom_value = $site->custom_value;
- remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40458
+ */
+ public function test_site_details_filter_with_custom_value_getter() {
+ add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
+ $site = get_site();
+ $custom_value = $site->custom_value;
+ remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'foo', $custom_value );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'foo', $custom_value );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function _filter_site_details_custom_value( $details ) {
- $details->custom_value = 'foo';
- return $details;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_site_details_custom_value( $details ) {
+ $details->custom_value = 'foo';
+ return $details;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitesiteMetaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/siteMeta.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/siteMeta.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/siteMeta.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,474 +1,472 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ * @group meta
+ * @ticket 37923
+ */
+class Tests_Multisite_SiteMeta extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group ms-site
- * @group multisite
- * @group meta
- * @ticket 37923
- */
- class Tests_Multisite_SiteMeta extends WP_UnitTestCase {
- protected static $site_id;
- protected static $site_id2;
- protected static $flag_was_set;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $site_id;
+ protected static $site_id2;
+ protected static $flag_was_set;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$site_id = $factory->blog->create(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- )
- );
- self::$site_id2 = $factory->blog->create(
- array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$site_id = $factory->blog->create(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ )
+ );
+ self::$site_id2 = $factory->blog->create(
+ array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Populate the main network flag as necessary.
- self::$flag_was_set = true;
- if ( false === get_network_option( get_main_network_id(), 'site_meta_supported', false ) ) {
- self::$flag_was_set = false;
- is_site_meta_supported();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Populate the main network flag as necessary.
+ self::$flag_was_set = true;
+ if ( false === get_network_option( get_main_network_id(), 'site_meta_supported', false ) ) {
+ self::$flag_was_set = false;
+ is_site_meta_supported();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- // Delete the possibly previously populated main network flag.
- if ( ! self::$flag_was_set ) {
- delete_network_option( get_main_network_id(), 'site_meta_supported' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ // Delete the possibly previously populated main network flag.
+ if ( ! self::$flag_was_set ) {
+ delete_network_option( get_main_network_id(), 'site_meta_supported' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( self::$site_id );
- wp_delete_site( self::$site_id2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( self::$site_id );
+ wp_delete_site( self::$site_id2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_site_counts();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_site_meta_supported() {
- $this->assertTrue( is_site_meta_supported() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_site_meta_supported() {
+ $this->assertTrue( is_site_meta_supported() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_site_meta_supported_filtered() {
- add_filter( 'pre_site_option_site_meta_supported', '__return_zero' );
- $this->assertFalse( is_site_meta_supported() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_site_meta_supported_filtered() {
+ add_filter( 'pre_site_option_site_meta_supported', '__return_zero' );
+ $this->assertFalse( is_site_meta_supported() );
+ }
+
+ public function test_add() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_add() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
+ $this->assertSame( 'bar', get_site_meta( self::$site_id, 'foo', true ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
- $this->assertSame( 'bar', get_site_meta( self::$site_id, 'foo', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_add_unique() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_add_unique() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
+ $this->assertFalse( add_site_meta( self::$site_id, 'foo', 'bar', true ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( add_site_meta( self::$site_id, 'foo', 'bar' ) );
- $this->assertFalse( add_site_meta( self::$site_id, 'foo', 'bar', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_delete() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_delete() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( delete_site_meta( self::$site_id, 'foo' ) );
+ $this->assertEmpty( get_site_meta( self::$site_id, 'foo', true ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( delete_site_meta( self::$site_id, 'foo' ) );
- $this->assertEmpty( get_site_meta( self::$site_id, 'foo', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_delete_with_invalid_meta_key_should_return_false() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_delete_with_invalid_meta_key_should_return_false() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( delete_site_meta( self::$site_id, 'foo' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( delete_site_meta( self::$site_id, 'foo' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_delete_should_respect_meta_value() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_delete_should_respect_meta_value() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
+ add_site_meta( self::$site_id, 'foo', 'baz' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
- add_site_meta( self::$site_id, 'foo', 'baz' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( delete_site_meta( self::$site_id, 'foo', 'bar' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( delete_site_meta( self::$site_id, 'foo', 'bar' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $metas = get_site_meta( self::$site_id, 'foo' );
+ $this->assertSame( array( 'baz' ), $metas );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $metas = get_site_meta( self::$site_id, 'foo' );
- $this->assertSame( array( 'baz' ), $metas );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_with_no_key_should_fetch_all_keys() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_with_no_key_should_fetch_all_keys() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
+ add_site_meta( self::$site_id, 'foo1', 'baz' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
- add_site_meta( self::$site_id, 'foo1', 'baz' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_site_meta( self::$site_id );
+ $expected = array(
+ 'foo' => array( 'bar' ),
+ 'foo1' => array( 'baz' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_site_meta( self::$site_id );
- $expected = array(
- 'foo' => array( 'bar' ),
- 'foo1' => array( 'baz' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_with_key_should_fetch_all_for_key() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_with_key_should_fetch_all_for_key() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
+ add_site_meta( self::$site_id, 'foo', 'baz' );
+ add_site_meta( self::$site_id, 'foo1', 'baz' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
- add_site_meta( self::$site_id, 'foo', 'baz' );
- add_site_meta( self::$site_id, 'foo1', 'baz' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_site_meta( self::$site_id, 'foo' );
+ $expected = array( 'bar', 'baz' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_site_meta( self::$site_id, 'foo' );
- $expected = array( 'bar', 'baz' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_should_respect_single_true() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_should_respect_single_true() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
+ add_site_meta( self::$site_id, 'foo', 'baz' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
- add_site_meta( self::$site_id, 'foo', 'baz' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_site_meta( self::$site_id, 'foo', true );
+ $this->assertSame( 'bar', $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_site_meta( self::$site_id, 'foo', true );
- $this->assertSame( 'bar', $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_should_pass_to_add_when_no_value_exists_for_key() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_should_pass_to_add_when_no_value_exists_for_key() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $actual = update_site_meta( self::$site_id, 'foo', 'bar' );
+ $this->assertIsInt( $actual );
+ $this->assertNotEmpty( $actual );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $actual = update_site_meta( self::$site_id, 'foo', 'bar' );
- $this->assertIsInt( $actual );
- $this->assertNotEmpty( $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_site_meta( self::$site_id, 'foo', true );
+ $this->assertSame( 'bar', $meta );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_site_meta( self::$site_id, 'foo', true );
- $this->assertSame( 'bar', $meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_should_return_true_when_updating_existing_value_for_key() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_should_return_true_when_updating_existing_value_for_key() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $actual = update_site_meta( self::$site_id, 'foo', 'baz' );
+ $this->assertTrue( $actual );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $actual = update_site_meta( self::$site_id, 'foo', 'baz' );
- $this->assertTrue( $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_site_meta( self::$site_id, 'foo', true );
+ $this->assertSame( 'baz', $meta );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_site_meta( self::$site_id, 'foo', true );
- $this->assertSame( 'baz', $meta );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_delete_by_key() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_delete_by_key() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'unique_delete_by_key', 'value', true );
+ add_site_meta( self::$site_id2, 'unique_delete_by_key', 'value', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'unique_delete_by_key', 'value', true );
- add_site_meta( self::$site_id2, 'unique_delete_by_key', 'value', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
+ $this->assertSame( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
- $this->assertSame( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( delete_site_meta_by_key( 'unique_delete_by_key' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( delete_site_meta_by_key( 'unique_delete_by_key' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
+ $this->assertSame( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
- $this->assertSame( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_site_meta_should_be_deleted_when_site_is_deleted() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_site_meta_should_be_deleted_when_site_is_deleted() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = self::factory()->blog->create(
+ array(
+ 'domain' => 'foo.org',
+ 'path' => '/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_id = self::factory()->blog->create(
- array(
- 'domain' => 'foo.org',
- 'path' => '/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( $site_id, 'foo', 'bar' );
+ add_site_meta( $site_id, 'foo1', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( $site_id, 'foo', 'bar' );
- add_site_meta( $site_id, 'foo1', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'bar', get_site_meta( $site_id, 'foo', true ) );
+ $this->assertSame( 'bar', get_site_meta( $site_id, 'foo1', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'bar', get_site_meta( $site_id, 'foo', true ) );
- $this->assertSame( 'bar', get_site_meta( $site_id, 'foo1', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '', get_site_meta( $site_id, 'foo', true ) );
+ $this->assertSame( '', get_site_meta( $site_id, 'foo1', true ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '', get_site_meta( $site_id, 'foo', true ) );
- $this->assertSame( '', get_site_meta( $site_id, 'foo1', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_site_meta_cache() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_site_meta_cache() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_meta( self::$site_id, 'foo', 'bar' );
+ update_sitemeta_cache( array( self::$site_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_meta( self::$site_id, 'foo', 'bar' );
- update_sitemeta_cache( array( self::$site_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
+ get_site_meta( self::$site_id, 'foo', true );
+ $this->assertSame( $num_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
- get_site_meta( self::$site_id, 'foo', true );
- $this->assertSame( $num_queries, get_num_queries() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_query_update_site_meta_cache_true() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_query_update_site_meta_cache_true() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_meta( self::$site_id, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_meta( self::$site_id, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do not include 'update_site_meta_cache' as true as its the default.
+ new WP_Site_Query(
+ array(
+ 'ID' => self::$site_id,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Do not include 'update_site_meta_cache' as true as its the default.
- new WP_Site_Query(
- array(
- 'ID' => self::$site_id,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
+ get_site_meta( self::$site_id, 'foo', true );
+ $this->assertSame( 1, get_num_queries() - $num_queries );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
- get_site_meta( self::$site_id, 'foo', true );
- $this->assertSame( 1, get_num_queries() - $num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 58185
+ */
+ public function test_lazy_load_site_meta() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 58185
- */
- public function test_lazy_load_site_meta() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $filter = new MockAction();
+ add_filter( 'update_blog_metadata_cache', array( $filter, 'filter' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $filter = new MockAction();
- add_filter( 'update_blog_metadata_cache', array( $filter, 'filter' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query(
+ array(
+ 'ID' => self::$site_id,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query(
- array(
- 'ID' => self::$site_id,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( (string) self::$site_id ), wp_list_pluck( $q->sites, 'blog_id' ), 'Site query should return the first test site' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( (string) self::$site_id ), wp_list_pluck( $q->sites, 'blog_id' ), 'Site query should return the first test site' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query(
+ array(
+ 'ID' => self::$site_id2,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query(
- array(
- 'ID' => self::$site_id2,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( (string) self::$site_id2 ), wp_list_pluck( $q->sites, 'blog_id' ), 'Site query should return the second test site' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( (string) self::$site_id2 ), wp_list_pluck( $q->sites, 'blog_id' ), 'Site query should return the second test site' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_site_meta( self::$site_id2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_site_meta( self::$site_id2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args = $filter->get_args();
+ $first = reset( $args );
+ $site_ids = end( $first );
+ $this->assertSameSets( $site_ids, array( self::$site_id, self::$site_id2 ), 'This should have two site\'s meta' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args = $filter->get_args();
- $first = reset( $args );
- $site_ids = end( $first );
- $this->assertSameSets( $site_ids, array( self::$site_id, self::$site_id2 ), 'This should have two site\'s meta' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 58185
+ */
+ public function test_lazy_load_site_meta_fields_id() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 58185
- */
- public function test_lazy_load_site_meta_fields_id() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $filter = new MockAction();
+ add_filter( 'update_blog_metadata_cache', array( $filter, 'filter' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $filter = new MockAction();
- add_filter( 'update_blog_metadata_cache', array( $filter, 'filter' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query(
+ array(
+ 'ID' => self::$site_id,
+ 'fields' => 'ids',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query(
- array(
- 'ID' => self::$site_id,
- 'fields' => 'ids',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id ), $q->sites, 'Site query should return the first test site' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id ), $q->sites, 'Site query should return the first test site' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query(
+ array(
+ 'ID' => self::$site_id2,
+ 'fields' => 'ids',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query(
- array(
- 'ID' => self::$site_id2,
- 'fields' => 'ids',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id2 ), $q->sites, 'Site query should return the second test site' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id2 ), $q->sites, 'Site query should return the second test site' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_site_meta( self::$site_id2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_site_meta( self::$site_id2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args = $filter->get_args();
+ $first = reset( $args );
+ $site_ids = end( $first );
+ $this->assertSameSets( $site_ids, array( self::$site_id, self::$site_id2 ), 'This should have two sites meta' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args = $filter->get_args();
- $first = reset( $args );
- $site_ids = end( $first );
- $this->assertSameSets( $site_ids, array( self::$site_id, self::$site_id2 ), 'This should have two sites meta' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_query_update_site_meta_cache_false() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_query_update_site_meta_cache_false() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_meta( self::$site_id, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_meta( self::$site_id, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ new WP_Site_Query(
+ array(
+ 'ID' => self::$site_id,
+ 'update_site_meta_cache' => false,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- new WP_Site_Query(
- array(
- 'ID' => self::$site_id,
- 'update_site_meta_cache' => false,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
+ get_site_meta( self::$site_id, 'foo', true );
+ $this->assertSame( 1, get_num_queries() - $num_queries );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
- get_site_meta( self::$site_id, 'foo', true );
- $this->assertSame( 1, get_num_queries() - $num_queries );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40229
+ */
+ public function test_add_site_meta_should_bust_get_sites_cache() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40229
- */
- public function test_add_site_meta_should_bust_get_sites_cache() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
-
- // Prime cache.
- $found = get_sites(
- array(
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prime cache.
+ $found = get_sites(
+ array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id ), $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id ), $found );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id2, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id2, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_sites(
- array(
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_sites(
+ array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
+ }
+
+ /**
+ * @ticket 40229
+ */
+ public function test_update_site_meta_should_bust_get_sites_cache() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40229
- */
- public function test_update_site_meta_should_bust_get_sites_cache() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
+ add_site_meta( self::$site_id2, 'foo', 'baz' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
- add_site_meta( self::$site_id2, 'foo', 'baz' );
-
- // Prime cache.
- $found = get_sites(
- array(
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prime cache.
+ $found = get_sites(
+ array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id ), $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id ), $found );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_meta( self::$site_id2, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_meta( self::$site_id2, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_sites(
- array(
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_sites(
+ array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
+ }
+
+ /**
+ * @ticket 40229
+ */
+ public function test_delete_site_meta_should_bust_get_sites_cache() {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40229
- */
- public function test_delete_site_meta_should_bust_get_sites_cache() {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_id, 'foo', 'bar' );
+ add_site_meta( self::$site_id2, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_id, 'foo', 'bar' );
- add_site_meta( self::$site_id2, 'foo', 'bar' );
-
- // Prime cache.
- $found = get_sites(
- array(
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prime cache.
+ $found = get_sites(
+ array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_site_meta( self::$site_id2, 'foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_site_meta( self::$site_id2, 'foo', 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_sites(
- array(
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_sites(
+ array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_id ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_id ), $found );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteupdateBlogDetailsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/updateBlogDetails.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/updateBlogDetails.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/updateBlogDetails.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,131 +1,129 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_UpdateBlogDetails extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-site
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * If `update_blog_details()` is called with any kind of empty arguments, it
+ * should return false.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_UpdateBlogDetails extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_details_with_empty_args() {
+ $result = update_blog_details( 1, array() );
+ $this->assertFalse( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * If `update_blog_details()` is called with any kind of empty arguments, it
- * should return false.
- */
- public function test_update_blog_details_with_empty_args() {
- $result = update_blog_details( 1, array() );
- $this->assertFalse( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * If the ID passed is not that of a current site, we should expect false.
+ */
+ public function test_update_blog_details_invalid_blog_id() {
+ $result = update_blog_details( 999, array( 'domain' => 'example.com' ) );
+ $this->assertFalse( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * If the ID passed is not that of a current site, we should expect false.
- */
- public function test_update_blog_details_invalid_blog_id() {
- $result = update_blog_details( 999, array( 'domain' => 'example.com' ) );
- $this->assertFalse( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_details() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_details() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = update_blog_details(
+ $blog_id,
+ array(
+ 'domain' => 'example.com',
+ 'path' => 'my_path/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = update_blog_details(
- $blog_id,
- array(
- 'domain' => 'example.com',
- 'path' => 'my_path/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'example.com', $blog->domain );
+ $this->assertSame( '/my_path/', $blog->path );
+ $this->assertSame( '0', $blog->spam );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'example.com', $blog->domain );
- $this->assertSame( '/my_path/', $blog->path );
- $this->assertSame( '0', $blog->spam );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test each of the actions that should fire in update_blog_details() depending on
+ * the flag and flag value being set. Each action should fire once and should not
+ * fire if a flag is already set for the given flag value.
+ *
+ * @param string $flag The name of the flag being set or unset on a site.
+ * @param string $flag_value '0' or '1'. The value of the flag being set.
+ * @param string $action The hook expected to fire for the flag name and flag combination.
+ *
+ * @dataProvider data_flag_hooks
+ */
+ public function test_update_blog_details_flag_action( $flag, $flag_value, $hook ) {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test each of the actions that should fire in update_blog_details() depending on
- * the flag and flag value being set. Each action should fire once and should not
- * fire if a flag is already set for the given flag value.
- *
- * @param string $flag The name of the flag being set or unset on a site.
- * @param string $flag_value '0' or '1'. The value of the flag being set.
- * @param string $action The hook expected to fire for the flag name and flag combination.
- *
- * @dataProvider data_flag_hooks
- */
- public function test_update_blog_details_flag_action( $flag, $flag_value, $hook ) {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set an initial value of '1' for the flag when '0' is the flag value being tested.
+ if ( '0' === $flag_value ) {
+ update_blog_details( $blog_id, array( $flag => '1' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set an initial value of '1' for the flag when '0' is the flag value being tested.
- if ( '0' === $flag_value ) {
- update_blog_details( $blog_id, array( $flag => '1' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook, array( $test_action_counter, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $hook, array( $test_action_counter, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_blog_details( $blog_id, array( $flag => $flag_value ) );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_blog_details( $blog_id, array( $flag => $flag_value ) );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $flag_value, $blog->{$flag} );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $flag_value, $blog->{$flag} );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The hook attached to this flag should have fired once during update_blog_details().
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The hook attached to this flag should have fired once during update_blog_details().
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Update the site to the exact same flag value for this flag.
+ update_blog_details( $blog_id, array( $flag => $flag_value ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Update the site to the exact same flag value for this flag.
- update_blog_details( $blog_id, array( $flag => $flag_value ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The hook attached to this flag should not have fired again.
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The hook attached to this flag should not have fired again.
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_flag_hooks() {
+ return array(
+ array( 'spam', '0', 'make_ham_blog' ),
+ array( 'spam', '1', 'make_spam_blog' ),
+ array( 'archived', '1', 'archive_blog' ),
+ array( 'archived', '0', 'unarchive_blog' ),
+ array( 'deleted', '1', 'make_delete_blog' ),
+ array( 'deleted', '0', 'make_undelete_blog' ),
+ array( 'mature', '1', 'mature_blog' ),
+ array( 'mature', '0', 'unmature_blog' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_flag_hooks() {
- return array(
- array( 'spam', '0', 'make_ham_blog' ),
- array( 'spam', '1', 'make_spam_blog' ),
- array( 'archived', '1', 'archive_blog' ),
- array( 'archived', '0', 'unarchive_blog' ),
- array( 'deleted', '1', 'make_delete_blog' ),
- array( 'deleted', '0', 'make_undelete_blog' ),
- array( 'mature', '1', 'mature_blog' ),
- array( 'mature', '0', 'unmature_blog' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the path for a site is updated with update_blog_details(), the final path
+ * should have a leading and trailing slash.
+ *
+ * @dataProvider data_single_directory_path
+ */
+ public function test_update_blog_details_single_directory_path( $path, $expected ) {
+ update_blog_details( 1, array( 'path' => $path ) );
+ $site = get_site( 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the path for a site is updated with update_blog_details(), the final path
- * should have a leading and trailing slash.
- *
- * @dataProvider data_single_directory_path
- */
- public function test_update_blog_details_single_directory_path( $path, $expected ) {
- update_blog_details( 1, array( 'path' => $path ) );
- $site = get_site( 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $site->path );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $site->path );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_single_directory_path() {
+ return array(
+ array( 'my_path', '/my_path/' ),
+ array( 'my_path//', '/my_path/' ),
+ array( '//my_path', '/my_path/' ),
+ array( 'my_path/', '/my_path/' ),
+ array( '/my_path', '/my_path/' ),
+ array( '/my_path/', '/my_path/' ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_single_directory_path() {
- return array(
- array( 'my_path', '/my_path/' ),
- array( 'my_path//', '/my_path/' ),
- array( '//my_path', '/my_path/' ),
- array( 'my_path/', '/my_path/' ),
- array( '/my_path', '/my_path/' ),
- array( '/my_path/', '/my_path/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'multiple/dirs', '/multiple/dirs/' ),
+ array( '/multiple/dirs', '/multiple/dirs/' ),
+ array( 'multiple/dirs/', '/multiple/dirs/' ),
+ array( '/multiple/dirs/', '/multiple/dirs/' ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array( 'multiple/dirs', '/multiple/dirs/' ),
- array( '/multiple/dirs', '/multiple/dirs/' ),
- array( 'multiple/dirs/', '/multiple/dirs/' ),
- array( '/multiple/dirs/', '/multiple/dirs/' ),
-
- // update_blog_details() does not resolve multiple slashes in the middle of a path string.
- array( 'multiple///dirs', '/multiple///dirs/' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // update_blog_details() does not resolve multiple slashes in the middle of a path string.
+ array( 'multiple///dirs', '/multiple///dirs/' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteupdateBlogStatusphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/updateBlogStatus.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/updateBlogStatus.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/updateBlogStatus.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,244 +1,241 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_UpdateBlogStatus extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-site
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Updating a field returns the same value that was passed.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_UpdateBlogStatus extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status() {
+ $result = update_blog_status( 1, 'spam', 0 );
+ $this->assertSame( 0, $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Updating a field returns the same value that was passed.
- */
- public function test_update_blog_status() {
- $result = update_blog_status( 1, 'spam', 0 );
- $this->assertSame( 0, $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Updating an invalid field returns the same value that was passed.
+ */
+ public function test_update_blog_status_invalid_status() {
+ $result = update_blog_status( 1, 'doesnotexist', 'invalid' );
+ $this->assertSame( 'invalid', $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Updating an invalid field returns the same value that was passed.
- */
- public function test_update_blog_status_invalid_status() {
- $result = update_blog_status( 1, 'doesnotexist', 'invalid' );
- $this->assertSame( 'invalid', $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_make_ham_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_make_ham_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
+ update_blog_details( $blog_id, array( 'spam' => 1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
- update_blog_details( $blog_id, array( 'spam' => 1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'make_ham_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'spam', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'make_ham_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'spam', 0 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->spam );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '0', $blog->spam );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'spam' stays the same.
+ update_blog_status( $blog_id, 'spam', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'spam' stays the same.
- update_blog_status( $blog_id, 'spam', 0 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->spam );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '0', $blog->spam );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @group external-http
+ */
+ public function test_content_from_spam_blog_is_not_available() {
+ $spam_blog_id = self::factory()->blog->create();
+ switch_to_blog( $spam_blog_id );
+ $post_data = array(
+ 'post_title' => 'Hello World!',
+ 'post_content' => 'Hello world content',
+ );
+ $post_id = self::factory()->post->create( $post_data );
+ $post = get_post( $post_id );
+ $spam_permalink = site_url() . '/?p=' . $post->ID;
+ $spam_embed_url = get_post_embed_url( $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group external-http
- */
- public function test_content_from_spam_blog_is_not_available() {
- $spam_blog_id = self::factory()->blog->create();
- switch_to_blog( $spam_blog_id );
- $post_data = array(
- 'post_title' => 'Hello World!',
- 'post_content' => 'Hello world content',
- );
- $post_id = self::factory()->post->create( $post_data );
- $post = get_post( $post_id );
- $spam_permalink = site_url() . '/?p=' . $post->ID;
- $spam_embed_url = get_post_embed_url( $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
+ $this->assertNotEmpty( $spam_permalink );
+ $this->assertSame( $post_data['post_title'], $post->post_title );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
- $this->assertNotEmpty( $spam_permalink );
- $this->assertSame( $post_data['post_title'], $post->post_title );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_blog_status( $spam_blog_id, 'spam', 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_blog_status( $spam_blog_id, 'spam', 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => "\n $spam_permalink \n",
+ )
+ );
+ $post = get_post( $post_id );
+ $content = apply_filters( 'the_content', $post->post_content );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create(
- array(
- 'post_content' => "\n $spam_permalink \n",
- )
- );
- $post = get_post( $post_id );
- $content = apply_filters( 'the_content', $post->post_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringNotContainsString( $post_data['post_title'], $content );
+ $this->assertStringNotContainsString( "src=\"{$spam_embed_url}#?", $content );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringNotContainsString( $post_data['post_title'], $content );
- $this->assertStringNotContainsString( "src=\"{$spam_embed_url}#?", $content );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_make_spam_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_make_spam_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'make_spam_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'spam', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'make_spam_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'spam', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->spam );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->spam );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'spam' stays the same.
+ update_blog_status( $blog_id, 'spam', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'spam' stays the same.
- update_blog_status( $blog_id, 'spam', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->spam );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->spam );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_archive_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_archive_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'archive_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'archived', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'archive_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'archived', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->archived );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->archived );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'archived' stays the same.
+ update_blog_status( $blog_id, 'archived', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'archived' stays the same.
- update_blog_status( $blog_id, 'archived', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->archived );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->archived );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_unarchive_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_unarchive_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
+ update_blog_details( $blog_id, array( 'archived' => 1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
- update_blog_details( $blog_id, array( 'archived' => 1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'unarchive_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'archived', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'unarchive_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'archived', 0 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->archived );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '0', $blog->archived );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'archived' stays the same.
+ update_blog_status( $blog_id, 'archived', 0 );
+ $blog = get_site( $blog_id );
+ $this->assertSame( '0', $blog->archived );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'archived' stays the same.
- update_blog_status( $blog_id, 'archived', 0 );
- $blog = get_site( $blog_id );
- $this->assertSame( '0', $blog->archived );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_make_delete_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_make_delete_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'make_delete_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'deleted', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'make_delete_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'deleted', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->deleted );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->deleted );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'deleted' stays the same.
+ update_blog_status( $blog_id, 'deleted', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'deleted' stays the same.
- update_blog_status( $blog_id, 'deleted', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->deleted );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->deleted );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_make_undelete_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_make_undelete_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
+ update_blog_details( $blog_id, array( 'deleted' => 1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
- update_blog_details( $blog_id, array( 'deleted' => 1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'make_undelete_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'deleted', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'make_undelete_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'deleted', 0 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->deleted );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '0', $blog->deleted );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'deleted' stays the same.
+ update_blog_status( $blog_id, 'deleted', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'deleted' stays the same.
- update_blog_status( $blog_id, 'deleted', 0 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->deleted );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '0', $blog->deleted );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_mature_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_mature_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'mature_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'mature', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'mature_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'mature', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->mature );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->mature );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'mature' stays the same.
+ update_blog_status( $blog_id, 'mature', 1 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'mature' stays the same.
- update_blog_status( $blog_id, 'mature', 1 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '1', $blog->mature );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '1', $blog->mature );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_unmature_blog_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_unmature_blog_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
+ update_blog_details( $blog_id, array( 'mature' => 1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
- update_blog_details( $blog_id, array( 'mature' => 1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'unmature_blog', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'mature', 0 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'unmature_blog', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'mature', 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog = get_site( $blog_id );
+ $this->assertSame( '0', $blog->mature );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog = get_site( $blog_id );
- $this->assertSame( '0', $blog->mature );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'mature' stays the same.
+ update_blog_status( $blog_id, 'mature', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'mature' stays the same.
- update_blog_status( $blog_id, 'mature', 0 );
- $blog = get_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->mature );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '0', $blog->mature );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_blog_status_update_blog_public_action() {
+ $test_action_counter = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_update_blog_status_update_blog_public_action() {
- $test_action_counter = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'update_blog_public', array( $test_action_counter, 'action' ) );
+ update_blog_status( $blog_id, 'public', 0 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'update_blog_public', array( $test_action_counter, 'action' ) );
- update_blog_status( $blog_id, 'public', 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog = get_site( $blog_id );
+ $this->assertSame( '0', $blog->public );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog = get_site( $blog_id );
- $this->assertSame( '0', $blog->public );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The action should not fire if the status of 'mature' stays the same.
+ update_blog_status( $blog_id, 'public', 0 );
+ $blog = get_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The action should not fire if the status of 'mature' stays the same.
- update_blog_status( $blog_id, 'public', 0 );
- $blog = get_site( $blog_id );
-
- $this->assertSame( '0', $blog->public );
- $this->assertSame( 1, $test_action_counter->get_call_count() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '0', $blog->public );
+ $this->assertSame( 1, $test_action_counter->get_call_count() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteupdatePostsCountphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/updatePostsCount.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/updatePostsCount.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/updatePostsCount.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,59 +1,57 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Test that update_posts_count() gets called via default filters on multisite.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ *
+ * @covers ::update_posts_count
+ */
+class Tests_Multisite_UpdatePostsCount extends WP_UnitTestCase {
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Test that update_posts_count() gets called via default filters on multisite.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tests that posts count is updated correctly when posts are added or deleted.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-site
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 27952
+ * @ticket 53443
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::update_posts_count
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @covers ::_update_posts_count_on_transition_post_status
+ * @covers ::_update_posts_count_on_delete
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_UpdatePostsCount extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_posts_count() {
+ $blog_id = self::factory()->blog->create();
+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests that posts count is updated correctly when posts are added or deleted.
- *
- * @ticket 27952
- * @ticket 53443
- *
- * @covers ::_update_posts_count_on_transition_post_status
- * @covers ::_update_posts_count_on_delete
- */
- public function test_update_posts_count() {
- $blog_id = self::factory()->blog->create();
- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $original_post_count = (int) get_site()->post_count;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $original_post_count = (int) get_site()->post_count;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = self::factory()->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_count_after_creating = get_site()->post_count;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_count_after_creating = get_site()->post_count;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_post( $post_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_post( $post_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_count_after_deleting = get_site()->post_count;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_count_after_deleting = get_site()->post_count;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Check that posts count is updated when a post is created:
+ * add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
+ *
+ * Check that _update_posts_count_on_transition_post_status() is called on that filter,
+ * which then calls update_posts_count() to update the count.
+ */
+ $this->assertSame( $original_post_count + 1, $post_count_after_creating, 'Post count should be incremented by 1.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Check that posts count is updated when a post is created:
- * add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
- *
- * Check that _update_posts_count_on_transition_post_status() is called on that filter,
- * which then calls update_posts_count() to update the count.
- */
- $this->assertSame( $original_post_count + 1, $post_count_after_creating, 'Post count should be incremented by 1.' );
-
- /*
- * Check that posts count is updated when a post is deleted:
- * add_action( 'after_delete_post', '_update_posts_count_on_delete', 10, 2 );
- *
- * Check that _update_posts_count_on_delete() is called on that filter,
- * which then calls update_posts_count() to update the count.
- */
- $this->assertSame( $original_post_count, $post_count_after_deleting, 'Post count should match the original count.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Check that posts count is updated when a post is deleted:
+ * add_action( 'after_delete_post', '_update_posts_count_on_delete', 10, 2 );
+ *
+ * Check that _update_posts_count_on_delete() is called on that filter,
+ * which then calls update_posts_count() to update the count.
+ */
+ $this->assertSame( $original_post_count, $post_count_after_deleting, 'Post count should match the original count.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisiteuploadIsUserOverQuotaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,123 +1,120 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to `upload_is_user_over_quota()` in multisite.
+ *
+ * These tests filter `get_space_allowed` and `pre_get_space_used` in
+ * most cases as those are tested elsewhere.
+ *
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_UploadIsUserOverQuota extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to `upload_is_user_over_quota()` in multisite.
- *
- * These tests filter `get_space_allowed` and `pre_get_space_used` in
- * most cases as those are tested elsewhere.
- *
- * @group multisite
- */
- class Tests_Multisite_UploadIsUserOverQuota extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function set_up() {
+ parent::set_up();
+ update_site_option( 'upload_space_check_disabled', false );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function set_up() {
- parent::set_up();
- update_site_option( 'upload_space_check_disabled', false );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_0_used_5() {
+ add_filter( 'get_space_allowed', '__return_zero' );
+ add_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', '__return_zero' );
+ remove_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_0_used_5() {
- add_filter( 'get_space_allowed', '__return_zero' );
- add_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', '__return_zero' );
- remove_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_0_used_0() {
+ add_filter( 'get_space_allowed', '__return_zero' );
+ add_filter( 'pre_get_space_used', '__return_zero' );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', '__return_zero' );
+ remove_filter( 'pre_get_space_used', '__return_zero' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_0_used_0() {
- add_filter( 'get_space_allowed', '__return_zero' );
- add_filter( 'pre_get_space_used', '__return_zero' );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', '__return_zero' );
- remove_filter( 'pre_get_space_used', '__return_zero' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_0_used_100() {
+ add_filter( 'get_space_allowed', '__return_zero' );
+ add_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', '__return_zero' );
+ remove_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_0_used_100() {
- add_filter( 'get_space_allowed', '__return_zero' );
- add_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', '__return_zero' );
- remove_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_100_used_0() {
+ add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ add_filter( 'pre_get_space_used', '__return_zero' );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ remove_filter( 'pre_get_space_used', '__return_zero' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_100_used_0() {
- add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- add_filter( 'pre_get_space_used', '__return_zero' );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- remove_filter( 'pre_get_space_used', '__return_zero' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_100_used_100() {
+ add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ add_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ remove_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_100_used_100() {
- add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- add_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- remove_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_100_used_200() {
+ add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ add_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ remove_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_100_used_200() {
- add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- add_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- remove_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_upload_is_user_over_quota_allowed_negative_used_100() {
+ add_filter( 'get_space_allowed', array( $this, '_filter_space_negative' ) );
+ add_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', array( $this, '_filter_space_negative' ) );
+ remove_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_upload_is_user_over_quota_allowed_negative_used_100() {
- add_filter( 'get_space_allowed', array( $this, '_filter_space_negative' ) );
- add_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', array( $this, '_filter_space_negative' ) );
- remove_filter( 'pre_get_space_used', array( $this, '_filter_space_100' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * When the upload space check is disabled, using more than the available
+ * quota is allowed.
+ */
+ public function test_upload_is_user_over_check_disabled() {
+ update_site_option( 'upload_space_check_disabled', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * When the upload space check is disabled, using more than the available
- * quota is allowed.
- */
- public function test_upload_is_user_over_check_disabled() {
- update_site_option( 'upload_space_check_disabled', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ add_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
+ $result = upload_is_user_over_quota( false );
+ remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
+ remove_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- add_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
- $result = upload_is_user_over_quota( false );
- remove_filter( 'get_space_allowed', array( $this, '_filter_space_100' ) );
- remove_filter( 'pre_get_space_used', array( $this, '_filter_space_200' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_space_5() {
+ return 5;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function _filter_space_5() {
- return 5;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_space_100() {
+ return 100;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function _filter_space_100() {
- return 100;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_space_200() {
+ return 200;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function _filter_space_200() {
- return 200;
- }
-
- public function _filter_space_negative() {
- return -1;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _filter_space_negative() {
+ return -1;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpCountSitesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpCountSites.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpCountSites.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpCountSites.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,68 +1,65 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_wpCountSites extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-site
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 37392
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_wpCountSites extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_count_sites() {
+ // Create a random number of sites with each status.
+ $site_ids = array(
+ 'public' => self::factory()->blog->create_many(
+ random_int( 0, 5 ),
+ array(
+ 'public' => 1,
+ )
+ ),
+ 'archived' => self::factory()->blog->create_many(
+ random_int( 0, 5 ),
+ array(
+ 'public' => 0,
+ 'archived' => 1,
+ )
+ ),
+ 'mature' => self::factory()->blog->create_many(
+ random_int( 0, 5 ),
+ array(
+ 'public' => 0,
+ 'mature' => 1,
+ )
+ ),
+ 'spam' => self::factory()->blog->create_many(
+ random_int( 0, 5 ),
+ array(
+ 'public' => 0,
+ 'spam' => 1,
+ )
+ ),
+ 'deleted' => self::factory()->blog->create_many(
+ random_int( 0, 5 ),
+ array(
+ 'public' => 0,
+ 'deleted' => 1,
+ )
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 37392
- */
- public function test_wp_count_sites() {
- // Create a random number of sites with each status.
- $site_ids = array(
- 'public' => self::factory()->blog->create_many(
- random_int( 0, 5 ),
- array(
- 'public' => 1,
- )
- ),
- 'archived' => self::factory()->blog->create_many(
- random_int( 0, 5 ),
- array(
- 'public' => 0,
- 'archived' => 1,
- )
- ),
- 'mature' => self::factory()->blog->create_many(
- random_int( 0, 5 ),
- array(
- 'public' => 0,
- 'mature' => 1,
- )
- ),
- 'spam' => self::factory()->blog->create_many(
- random_int( 0, 5 ),
- array(
- 'public' => 0,
- 'spam' => 1,
- )
- ),
- 'deleted' => self::factory()->blog->create_many(
- random_int( 0, 5 ),
- array(
- 'public' => 0,
- 'deleted' => 1,
- )
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $counts = wp_count_sites();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $counts = wp_count_sites();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $counts_by_status = array_map( 'count', $site_ids );
+ $expected = array_merge(
+ array( 'all' => array_sum( $counts_by_status ) ),
+ $counts_by_status
+ );
+ // Add 1 to all & public for the main site.
+ $expected['all'] += 1;
+ $expected['public'] += 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $counts_by_status = array_map( 'count', $site_ids );
- $expected = array_merge(
- array( 'all' => array_sum( $counts_by_status ) ),
- $counts_by_status
- );
- // Add 1 to all & public for the main site.
- $expected['all'] += 1;
- $expected['public'] += 1;
-
- $this->assertSame( $expected, $counts );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $counts );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpGetSitesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpGetSites.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpGetSites.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpGetSites.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,147 +1,143 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_wpGetSites extends WP_UnitTestCase {
+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group wp-get-site
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_wpGetSites extends WP_UnitTestCase {
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$site_ids = array(
+ 'w.org/' => array(
+ 'domain' => 'w.org',
+ 'path' => '/',
+ 'network_id' => 2,
+ ),
+ 'wp.org/' => array(
+ 'domain' => 'wp.org',
+ 'path' => '/',
+ 'network_id' => 2,
+ 'public' => 0,
+ ),
+ 'wp.org/foo/' => array(
+ 'domain' => 'wp.org',
+ 'path' => '/foo/',
+ 'network_id' => 1,
+ 'public' => 0,
+ ),
+ 'wp.org/oof/' => array(
+ 'domain' => 'wp.org',
+ 'path' => '/oof/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$site_ids = array(
- 'w.org/' => array(
- 'domain' => 'w.org',
- 'path' => '/',
- 'network_id' => 2,
- ),
- 'wp.org/' => array(
- 'domain' => 'wp.org',
- 'path' => '/',
- 'network_id' => 2,
- 'public' => 0,
- ),
- 'wp.org/foo/' => array(
- 'domain' => 'wp.org',
- 'path' => '/foo/',
- 'network_id' => 1,
- 'public' => 0,
- ),
- 'wp.org/oof/' => array(
- 'domain' => 'wp.org',
- 'path' => '/oof/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
+ }
+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_network_site_counts();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @expectedDeprecated wp_get_sites
+ */
+ public function test_wp_get_sites_site_is_expected_array() {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @expectedDeprecated wp_get_sites
- */
- public function test_wp_get_sites_site_is_expected_array() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $keys = array(
+ 'blog_id',
+ 'site_id',
+ 'domain',
+ 'path',
+ 'registered',
+ 'last_updated',
+ 'public',
+ 'archived',
+ 'mature',
+ 'spam',
+ 'deleted',
+ 'lang_id',
+ );
+ $sites = wp_get_sites();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $keys = array(
- 'blog_id',
- 'site_id',
- 'domain',
- 'path',
- 'registered',
- 'last_updated',
- 'public',
- 'archived',
- 'mature',
- 'spam',
- 'deleted',
- 'lang_id',
- );
- $sites = wp_get_sites();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $missing_keys = array_diff_key( array_flip( $keys ), $sites[0] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $missing_keys = array_diff_key( array_flip( $keys ), $sites[0] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array(), $missing_keys, 'Keys are missing from site arrays.' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array(), $missing_keys, 'Keys are missing from site arrays.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @expectedDeprecated wp_get_sites
+ * @dataProvider data_wp_get_sites
+ *
+ * @param $expected
+ * @param $args
+ * @param $error
+ */
+ public function test_wp_get_sites( $expected, $args, $error ) {
+ $this->assertCount( $expected, wp_get_sites( $args ), $error );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @expectedDeprecated wp_get_sites
- * @dataProvider data_wp_get_sites
- *
- * @param $expected
- * @param $args
- * @param $error
- */
- public function test_wp_get_sites( $expected, $args, $error ) {
- $this->assertCount( $expected, wp_get_sites( $args ), $error );
- }
-
- /**
- * @return array
- */
- public function data_wp_get_sites() {
- return array(
- array( 3, array(), 'Default arguments should return all sites from the current network.' ),
- array( 0, array( 'network_id' => 999 ), 'No sites should match a query with an invalid network ID.' ),
- array( 5, array( 'network_id' => null ), 'A network ID of null should return all sites on all networks.' ),
- array( 2, array( 'network_id' => 2 ), 'Only sites on a specified network ID should be returned.' ),
- array( 5, array( 'network_id' => array( 1, 2 ) ), 'If multiple network IDs are specified, sites from both should be returned.' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @return array
+ */
+ public function data_wp_get_sites() {
+ return array(
+ array( 3, array(), 'Default arguments should return all sites from the current network.' ),
+ array( 0, array( 'network_id' => 999 ), 'No sites should match a query with an invalid network ID.' ),
+ array( 5, array( 'network_id' => null ), 'A network ID of null should return all sites on all networks.' ),
+ array( 2, array( 'network_id' => 2 ), 'Only sites on a specified network ID should be returned.' ),
+ array( 5, array( 'network_id' => array( 1, 2 ) ), 'If multiple network IDs are specified, sites from both should be returned.' ),
+ array(
+ 3,
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 3,
- array(
- 'public' => 1,
- 'network_id' => null,
- ),
- 'Public sites on all networks.',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => 1,
+ 'network_id' => null,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Public sites on all networks.',
+ ),
+ array(
+ 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 2,
- array(
- 'public' => 0,
- 'network_id' => null,
- ),
- 'Non public sites on all networks.',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => 0,
+ 'network_id' => null,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Non public sites on all networks.',
+ ),
+ array(
+ 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 2,
- array(
- 'public' => 1,
- 'network_id' => 1,
- ),
- 'Public sites on a single network.',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => 1,
+ 'network_id' => 1,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Public sites on a single network.',
+ ),
+ array(
+ 1,
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 1,
- array(
- 'public' => 1,
- 'network_id' => 2,
- ),
- 'Public sites on a second network.',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => 1,
+ 'network_id' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array( 2, array( 'limit' => 2 ), 'Provide only a limit argument.' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Public sites on a second network.',
+ ),
+ array( 2, array( 'limit' => 2 ), 'Provide only a limit argument.' ),
+ array(
+ 1,
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 1,
- array(
- 'limit' => 2,
- 'offset' => 2,
- ),
- 'Provide both limit and offset arguments.',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'limit' => 2,
+ 'offset' => 2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array( 2, array( 'offset' => 1 ), 'Provide only an offset argument.' ),
- array( 0, array( 'offset' => 20 ), 'Expect 0 sites when using an offset larger than the total number of sites.' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Provide both limit and offset arguments.',
+ ),
+ array( 2, array( 'offset' => 1 ), 'Provide only an offset argument.' ),
+ array( 0, array( 'offset' => 20 ), 'Expect 0 sites when using an offset larger than the total number of sites.' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpInstallDefaultsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,84 +1,82 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Saving network settings without altering starter content ( first page, post, and comment ) shouldn't affect
+ * the way it is added to new sites.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Saving network settings without altering starter content ( first page, post, and comment ) shouldn't affect
- * the way it is added to new sites.
- *
- * @group ms-site
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 40036
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase {
- /**
- * @ticket 40036
- */
- public function test_option_should_not_be_empty_by_default() {
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_option_should_not_be_empty_by_default() {
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $first_page = get_page_by_path( '/sample-page' );
- $first_comment = get_comments();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $first_page = get_page_by_path( '/sample-page' );
+ $first_comment = get_comments();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( $first_page->post_content );
- $this->assertNotEmpty( $first_comment[0]->comment_content );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( $first_page->post_content );
+ $this->assertNotEmpty( $first_comment[0]->comment_content );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40036
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40036
+ */
+ public function test_empty_option_should_fall_back_to_default() {
+ /*
+ * Update first_page / first_comment options,
+ * just like what happens when the network settings page is saved
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_empty_option_should_fall_back_to_default() {
- /*
- * Update first_page / first_comment options,
- * just like what happens when the network settings page is saved
- */
- update_site_option( 'first_page', '' );
- update_site_option( 'first_comment', '' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_option( 'first_page', '' );
+ update_site_option( 'first_comment', '' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $first_page = get_page_by_path( '/sample-page' );
- $first_comment = get_comments();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $first_page = get_page_by_path( '/sample-page' );
+ $first_comment = get_comments();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( $first_page->post_content );
- $this->assertNotEmpty( $first_comment[0]->comment_content );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( $first_page->post_content );
+ $this->assertNotEmpty( $first_comment[0]->comment_content );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40036
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40036
+ */
+ public function test_non_default_option_values() {
+ /*
+ * Update first_page / first_comment options,
+ * just like what happens when the network settings page is saved
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_non_default_option_values() {
- /*
- * Update first_page / first_comment options,
- * just like what happens when the network settings page is saved
- */
- update_site_option( 'first_page', 'Some page content' );
- update_site_option( 'first_comment', 'Some comment content' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_option( 'first_page', 'Some page content' );
+ update_site_option( 'first_comment', 'Some comment content' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $first_page = get_page_by_path( '/sample-page' );
- $first_comment = get_comments();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $first_page = get_page_by_path( '/sample-page' );
+ $first_comment = get_comments();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'Some page content', $first_page->post_content );
- $this->assertSame( 'Some comment content', $first_comment[0]->comment_content );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'Some page content', $first_page->post_content );
+ $this->assertSame( 'Some comment content', $first_comment[0]->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpMsSitesListTablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,246 +1,245 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group admin
+ * @group ms-required
+ * @group network-admin
+ */
+class Tests_Multisite_wpMsSitesListTable extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $site_ids;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group admin
- * @group network-admin
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var WP_MS_Sites_List_Table
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_wpMsSitesListTable extends WP_UnitTestCase {
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $table = false;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @var WP_MS_Sites_List_Table
- */
- public $table = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function set_up() {
+ parent::set_up();
+ $this->table = _get_list_table( 'WP_MS_Sites_List_Table', array( 'screen' => 'ms-sites' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function set_up() {
- parent::set_up();
- $this->table = _get_list_table( 'WP_MS_Sites_List_Table', array( 'screen' => 'ms-sites' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$site_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'wordpress.org/foo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ ),
+ 'wordpress.org/foo/bar/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/bar/',
+ ),
+ 'wordpress.org/afoo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/afoo/',
+ ),
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ ),
+ 'make.wordpress.org/foo/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/foo/',
+ ),
+ 'www.w.org/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/',
+ ),
+ 'www.w.org/foo/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/',
+ ),
+ 'www.w.org/foo/bar/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/bar/',
+ ),
+ 'test.example.org/' => array(
+ 'domain' => 'test.example.org',
+ 'path' => '/',
+ ),
+ 'test2.example.org/' => array(
+ 'domain' => 'test2.example.org',
+ 'path' => '/',
+ ),
+ 'test3.example.org/zig/' => array(
+ 'domain' => 'test3.example.org',
+ 'path' => '/zig/',
+ ),
+ 'atest.example.org/' => array(
+ 'domain' => 'atest.example.org',
+ 'path' => '/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$site_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'wordpress.org/foo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- ),
- 'wordpress.org/foo/bar/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/bar/',
- ),
- 'wordpress.org/afoo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/afoo/',
- ),
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- ),
- 'make.wordpress.org/foo/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/foo/',
- ),
- 'www.w.org/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/',
- ),
- 'www.w.org/foo/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/',
- ),
- 'www.w.org/foo/bar/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/bar/',
- ),
- 'test.example.org/' => array(
- 'domain' => 'test.example.org',
- 'path' => '/',
- ),
- 'test2.example.org/' => array(
- 'domain' => 'test2.example.org',
- 'path' => '/',
- ),
- 'test3.example.org/zig/' => array(
- 'domain' => 'test3.example.org',
- 'path' => '/zig/',
- ),
- 'atest.example.org/' => array(
- 'domain' => 'atest.example.org',
- 'path' => '/',
- ),
- );
-
- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- foreach ( self::$site_ids as $site_id ) {
- wp_delete_site( $site_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ foreach ( self::$site_ids as $site_id ) {
+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_default_items() {
- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_ms_sites_list_table_default_items() {
+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( 1 ) + self::$site_ids, $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( 1 ) + self::$site_ids, $items );
+ }
+
+ public function test_ms_sites_list_table_subdirectory_path_search_items() {
+ if ( is_subdomain_install() ) {
+ $this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_subdirectory_path_search_items() {
- if ( is_subdomain_install() ) {
- $this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_REQUEST['s'] = 'foo';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_REQUEST['s'] = 'foo';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $_REQUEST['s'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $_REQUEST['s'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['wordpress.org/afoo/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['wordpress.org/afoo/'],
- self::$site_ids['make.wordpress.org/foo/'],
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $items );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_ms_sites_list_table_subdirectory_multiple_path_search_items() {
+ if ( is_subdomain_install() ) {
+ $this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_subdirectory_multiple_path_search_items() {
- if ( is_subdomain_install() ) {
- $this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_REQUEST['s'] = 'foo/bar';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_REQUEST['s'] = 'foo/bar';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $_REQUEST['s'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $_REQUEST['s'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $items );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $items );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_ms_sites_list_table_invalid_path_search_items() {
+ $_REQUEST['s'] = 'foobar';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_invalid_path_search_items() {
- $_REQUEST['s'] = 'foobar';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $_REQUEST['s'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $_REQUEST['s'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $items );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_ms_sites_list_table_subdomain_domain_search_items() {
+ if ( ! is_subdomain_install() ) {
+ $this->markTestSkipped( 'Domain search is not available for subdirectory configurations.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_subdomain_domain_search_items() {
- if ( ! is_subdomain_install() ) {
- $this->markTestSkipped( 'Domain search is not available for subdirectory configurations.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_REQUEST['s'] = 'test';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_REQUEST['s'] = 'test';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $_REQUEST['s'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $_REQUEST['s'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['test.example.org/'],
+ self::$site_ids['test2.example.org/'],
+ self::$site_ids['test3.example.org/zig/'],
+ self::$site_ids['atest.example.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['test.example.org/'],
- self::$site_ids['test2.example.org/'],
- self::$site_ids['test3.example.org/zig/'],
- self::$site_ids['atest.example.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $items );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_ms_sites_list_table_subdomain_domain_search_items_with_trailing_wildcard() {
+ if ( ! is_subdomain_install() ) {
+ $this->markTestSkipped( 'Domain search is not available for subdirectory configurations.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_subdomain_domain_search_items_with_trailing_wildcard() {
- if ( ! is_subdomain_install() ) {
- $this->markTestSkipped( 'Domain search is not available for subdirectory configurations.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_REQUEST['s'] = 'test*';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_REQUEST['s'] = 'test*';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $_REQUEST['s'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $_REQUEST['s'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['test.example.org/'],
+ self::$site_ids['test2.example.org/'],
+ self::$site_ids['test3.example.org/zig/'],
+ self::$site_ids['atest.example.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['test.example.org/'],
- self::$site_ids['test2.example.org/'],
- self::$site_ids['test3.example.org/zig/'],
- self::$site_ids['atest.example.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $items );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_ms_sites_list_table_subdirectory_path_search_items_with_trailing_wildcard() {
+ if ( is_subdomain_install() ) {
+ $this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_ms_sites_list_table_subdirectory_path_search_items_with_trailing_wildcard() {
- if ( is_subdomain_install() ) {
- $this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_REQUEST['s'] = 'fo*';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_REQUEST['s'] = 'fo*';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->table->prepare_items();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->table->prepare_items();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $_REQUEST['s'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $_REQUEST['s'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['wordpress.org/afoo/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['wordpress.org/afoo/'],
- self::$site_ids['make.wordpress.org/foo/'],
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $items );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $items );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 42066
+ */
+ public function test_get_views_should_return_views_by_default() {
+ $expected = array(
+ 'all' => '<a href="sites.php" class="current" aria-current="page">All <span class="count">(14)</span></a>',
+ 'public' => '<a href="sites.php?status=public">Public <span class="count">(14)</span></a>',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 42066
- */
- public function test_get_views_should_return_views_by_default() {
- $expected = array(
- 'all' => '<a href="sites.php" class="current" aria-current="page">All <span class="count">(14)</span></a>',
- 'public' => '<a href="sites.php?status=public">Public <span class="count">(14)</span></a>',
- );
-
- $this->assertSame( $expected, $this->table->get_views() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $this->table->get_views() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpMsThemesListTablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpMsThemesListTable.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpMsThemesListTable.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpMsThemesListTable.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,8 +1,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group admin
</ins><span class="cx" style="display: block; padding: 0 10px"> * @group ms-required
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group admin
</del><span class="cx" style="display: block; padding: 0 10px"> * @group network-admin
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_MS_Themes_List_Table
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpMsUsersListTablephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpMsUsersListTable.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpMsUsersListTable.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpMsUsersListTable.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,8 +2,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @group admin
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group ms-required
</ins><span class="cx" style="display: block; padding: 0 10px"> * @group network-admin
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group ms-required
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_MS_Users_List_Table
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpNetworkQueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,630 +1,627 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Test network query functionality in multisite.
+ *
+ * @group ms-network
+ * @group ms-network-query
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_wpNetworkQuery extends WP_UnitTestCase {
+ protected static $network_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test network query functionality in multisite.
- *
- * @group ms-network
- * @group ms-network-query
- * @group multisite
- */
- class Tests_Multisite_wpNetworkQuery extends WP_UnitTestCase {
- protected static $network_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$network_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ ),
+ 'www.wordpress.net/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/',
+ ),
+ 'www.w.org/foo/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$network_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- ),
- 'www.wordpress.net/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/',
- ),
- 'www.w.org/foo/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/',
- ),
- );
-
- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as $id ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as $id ) {
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_number() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_number() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertCount( 3, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertCount( 3, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_network__in_with_order() {
- $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_network__in_with_order() {
+ $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- 'order' => 'ASC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ 'order' => 'ASC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $found );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- 'order' => 'DESC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ 'order' => 'DESC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array_reverse( $expected ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array_reverse( $expected ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_network__in_with_single_id() {
- $expected = array( self::$network_ids['wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_network__in_with_single_id() {
+ $expected = array( self::$network_ids['wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_network__in_with_multiple_ids() {
- $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['www.wordpress.net/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_network__in_with_multiple_ids() {
+ $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['www.wordpress.net/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_network__in_and_count_with_multiple_ids() {
- $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_network__in_and_count_with_multiple_ids() {
+ $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'count' => true,
- 'network__in' => $expected,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'count' => true,
+ 'network__in' => $expected,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 2, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 2, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_network__not_in_with_single_id() {
- $excluded = array( self::$network_ids['wordpress.org/'] );
- $expected = array_diff( self::$network_ids, $excluded );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_network__not_in_with_single_id() {
+ $excluded = array( self::$network_ids['wordpress.org/'] );
+ $expected = array_diff( self::$network_ids, $excluded );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Exclude main network since we don't have control over it here.
- $excluded[] = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Exclude main network since we don't have control over it here.
+ $excluded[] = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__not_in' => $excluded,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__not_in' => $excluded,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_network__not_in_with_multiple_ids() {
- $excluded = array( self::$network_ids['wordpress.org/'], self::$network_ids['www.w.org/foo/'] );
- $expected = array_diff( self::$network_ids, $excluded );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_network__not_in_with_multiple_ids() {
+ $excluded = array( self::$network_ids['wordpress.org/'], self::$network_ids['www.w.org/foo/'] );
+ $expected = array_diff( self::$network_ids, $excluded );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Exclude main network since we don't have control over it here.
- $excluded[] = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Exclude main network since we don't have control over it here.
+ $excluded[] = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__not_in' => $excluded,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__not_in' => $excluded,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain' => 'www.w.org',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain' => 'www.w.org',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['www.w.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['www.w.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__in_with_single_domain() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__in' => array( 'make.wordpress.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__in_with_single_domain() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__in' => array( 'make.wordpress.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['make.wordpress.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['make.wordpress.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__in_with_multiple_domains() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__in_with_multiple_domains() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__in_with_multiple_domains_and_number() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 1,
- 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__in_with_multiple_domains_and_number() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 1,
+ 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['wordpress.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['wordpress.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__in_with_multiple_domains_and_number_and_offset() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 1,
- 'offset' => 1,
- 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__in_with_multiple_domains_and_number_and_offset() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 1,
+ 'offset' => 1,
+ 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['make.wordpress.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['make.wordpress.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__not_in_with_single_domain() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__not_in' => array( 'www.w.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__not_in_with_single_domain() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__not_in' => array( 'www.w.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- get_current_site()->id, // Account for the initial network added by the test suite.
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- self::$network_ids['www.wordpress.net/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ get_current_site()->id, // Account for the initial network added by the test suite.
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ self::$network_ids['www.wordpress.net/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__not_in_with_multiple_domains() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__not_in_with_multiple_domains() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- get_current_site()->id, // Account for the initial network added by the test suite.
- self::$network_ids['make.wordpress.org/'],
- self::$network_ids['www.wordpress.net/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ get_current_site()->id, // Account for the initial network added by the test suite.
+ self::$network_ids['make.wordpress.org/'],
+ self::$network_ids['www.wordpress.net/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__not_in_with_multiple_domains_and_number() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 2,
- 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__not_in_with_multiple_domains_and_number() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 2,
+ 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- get_current_site()->id, // Account for the initial network added by the test suite.
- self::$network_ids['make.wordpress.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ get_current_site()->id, // Account for the initial network added by the test suite.
+ self::$network_ids['make.wordpress.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_domain__not_in_with_multiple_domains_and_number_and_offset() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 2,
- 'offset' => 1,
- 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_domain__not_in_with_multiple_domains_and_number_and_offset() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 2,
+ 'offset' => 1,
+ 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['make.wordpress.org/'],
- self::$network_ids['www.wordpress.net/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['make.wordpress.org/'],
+ self::$network_ids['www.wordpress.net/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_path_with_expected_results() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'path' => '/',
- 'network__not_in' => get_current_site()->id, // Exclude the initial network added by the test suite.
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_path_with_expected_results() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'path' => '/',
+ 'network__not_in' => get_current_site()->id, // Exclude the initial network added by the test suite.
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- self::$network_ids['www.wordpress.net/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ self::$network_ids['www.wordpress.net/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_path_and_number_and_offset_with_expected_results() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 1,
- 'offset' => 2,
- 'path' => '/',
- 'network__not_in' => get_current_site()->id, // Exclude the initial network added by the test suite.
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_path_and_number_and_offset_with_expected_results() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 1,
+ 'offset' => 2,
+ 'path' => '/',
+ 'network__not_in' => get_current_site()->id, // Exclude the initial network added by the test suite.
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['www.wordpress.net/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['www.wordpress.net/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_path_with_no_expected_results() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'path' => '/bar/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_path_with_no_expected_results() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'path' => '/bar/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_search_with_text_in_domain() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'ww.word',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_search_with_text_in_domain() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'ww.word',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['www.wordpress.net/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['www.wordpress.net/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_search_with_text_in_path() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'foo',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_search_with_text_in_path() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'foo',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['www.w.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['www.w.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_network_query_by_path_order_by_domain_desc() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'path' => '/',
- 'network__not_in' => get_current_site()->id, // Exclude the initial network added by the test suite.
- 'order' => 'DESC',
- 'orderby' => 'domain',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_network_query_by_path_order_by_domain_desc() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'path' => '/',
+ 'network__not_in' => get_current_site()->id, // Exclude the initial network added by the test suite.
+ 'order' => 'DESC',
+ 'orderby' => 'domain',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$network_ids['www.wordpress.net/'],
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$network_ids['www.wordpress.net/'],
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41347
- */
- public function test_wp_network_query_cache_with_different_fields_no_count() {
- $q = new WP_Network_Query();
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41347
+ */
+ public function test_wp_network_query_cache_with_different_fields_no_count() {
+ $q = new WP_Network_Query();
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41347
- */
- public function test_wp_network_query_cache_with_different_fields_active_count() {
- $q = new WP_Network_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41347
+ */
+ public function test_wp_network_query_cache_with_different_fields_active_count() {
+ $q = new WP_Network_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41347
- */
- public function test_wp_network_query_cache_with_same_fields_different_count() {
- $q = new WP_Network_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41347
+ */
+ public function test_wp_network_query_cache_with_same_fields_different_count() {
+ $q = new WP_Network_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_1 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_1 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $this->assertSame( $number_of_queries + 1, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries + 1, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 55461
- */
- public function test_wp_network_query_cache_with_same_fields_same_cache_field() {
- $q = new WP_Network_Query();
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'update_network_cache' => true,
- )
- );
- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55461
+ */
+ public function test_wp_network_query_cache_with_same_fields_same_cache_field() {
+ $q = new WP_Network_Query();
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_network_cache' => true,
+ )
+ );
+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'update_network_cache' => true,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_network_cache' => true,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 55461
- */
- public function test_wp_network_query_cache_with_same_fields_different_cache_field() {
- $q = new WP_Network_Query();
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'update_network_cache' => true,
- )
- );
- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55461
+ */
+ public function test_wp_network_query_cache_with_same_fields_different_cache_field() {
+ $q = new WP_Network_Query();
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_network_cache' => true,
+ )
+ );
+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'update_network_cache' => false,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_network_cache' => false,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 45749
- * @ticket 47599
- */
- public function test_networks_pre_query_filter_should_bypass_database_query() {
- add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 45749
+ * @ticket 47599
+ */
+ public function test_networks_pre_query_filter_should_bypass_database_query() {
+ add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $results = $q->query( array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $results = $q->query( array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure no queries were executed.
- $this->assertSame( $num_queries, get_num_queries() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure no queries were executed.
+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We manually inserted a non-existing site and overrode the results with it.
- $this->assertSame( array( 555 ), $results );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // We manually inserted a non-existing site and overrode the results with it.
+ $this->assertSame( array( 555 ), $results );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure manually setting found_networks doesn't get overwritten.
- $this->assertSame( 1, $q->found_networks );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure manually setting found_networks doesn't get overwritten.
+ $this->assertSame( 1, $q->found_networks );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function filter_networks_pre_query( $networks, $query ) {
- $query->found_networks = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function filter_networks_pre_query( $networks, $query ) {
+ $query->found_networks = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array( 555 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return array( 555 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 51333
- */
- public function test_networks_pre_query_filter_should_set_networks_property() {
- add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query_and_set_networks' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 51333
+ */
+ public function test_networks_pre_query_filter_should_set_networks_property() {
+ add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query_and_set_networks' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Network_Query();
- $results = $q->query( array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Network_Query();
+ $results = $q->query( array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query_and_set_networks' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query_and_set_networks' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure the networks property is the same as the results.
- $this->assertSame( $results, $q->networks );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure the networks property is the same as the results.
+ $this->assertSame( $results, $q->networks );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure the network domain is `wordpress.org`.
- $this->assertSame( 'wordpress.org', $q->networks[0]->domain );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure the network domain is `wordpress.org`.
+ $this->assertSame( 'wordpress.org', $q->networks[0]->domain );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function filter_networks_pre_query_and_set_networks( $networks, $query ) {
- return array( get_network( self::$network_ids['wordpress.org/'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function filter_networks_pre_query_and_set_networks( $networks, $query ) {
+ return array( get_network( self::$network_ids['wordpress.org/'] ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 56841
- */
- public function test_wp_network_query_does_not_have_leading_whitespace() {
- $q = new WP_Network_Query();
- $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'update_network_cache' => true,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 56841
+ */
+ public function test_wp_network_query_does_not_have_leading_whitespace() {
+ $q = new WP_Network_Query();
+ $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_network_cache' => true,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( ltrim( $q->request ), $q->request, 'The query has leading whitespace' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( ltrim( $q->request ), $q->request, 'The query has leading whitespace' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpSiteQueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpSiteQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpSiteQuery.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpSiteQuery.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,1187 +1,1184 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Test site query functionality in multisite.
+ *
+ * @group ms-required
+ * @group ms-site
+ * @group multisite
+ */
+class Tests_Multisite_wpSiteQuery extends WP_UnitTestCase {
+ protected static $network_ids;
+ protected static $site_ids;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test site query functionality in multisite.
- *
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_wpSiteQuery extends WP_UnitTestCase {
- protected static $network_ids;
- protected static $site_ids;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$network_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ ),
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ ),
+ 'www.wordpress.net/' => array(
+ 'domain' => 'www.wordpress.net',
+ 'path' => '/',
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$network_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- ),
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- ),
- 'www.wordpress.net/' => array(
- 'domain' => 'www.wordpress.net',
- 'path' => '/',
- ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
+ }
+ unset( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$site_ids = array(
+ 'wordpress.org/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'wordpress.org/foo/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'wordpress.org/foo/bar/' => array(
+ 'domain' => 'wordpress.org',
+ 'path' => '/foo/bar/',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ ),
+ 'make.wordpress.org/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ ),
+ 'make.wordpress.org/foo/' => array(
+ 'domain' => 'make.wordpress.org',
+ 'path' => '/foo/',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ ),
+ 'www.w.org/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/',
+ ),
+ 'www.w.org/foo/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/',
+ ),
+ 'www.w.org/foo/bar/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/foo/bar/',
+ ),
+ 'www.w.org/make/' => array(
+ 'domain' => 'www.w.org',
+ 'path' => '/make/',
+ 'public' => 1,
+ 'lang_id' => 1,
+ ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$site_ids = array(
- 'wordpress.org/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'wordpress.org/foo/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'wordpress.org/foo/bar/' => array(
- 'domain' => 'wordpress.org',
- 'path' => '/foo/bar/',
- 'network_id' => self::$network_ids['wordpress.org/'],
- ),
- 'make.wordpress.org/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- ),
- 'make.wordpress.org/foo/' => array(
- 'domain' => 'make.wordpress.org',
- 'path' => '/foo/',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- ),
- 'www.w.org/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/',
- ),
- 'www.w.org/foo/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/',
- ),
- 'www.w.org/foo/bar/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/foo/bar/',
- ),
- 'www.w.org/make/' => array(
- 'domain' => 'www.w.org',
- 'path' => '/make/',
- 'public' => 1,
- 'lang_id' => 1,
- ),
- );
-
- foreach ( self::$site_ids as &$id ) {
- $id = $factory->blog->create( $id );
- }
- unset( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as &$id ) {
+ $id = $factory->blog->create( $id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$site_ids as $id ) {
- wp_delete_site( $id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$site_ids as $id ) {
+ wp_delete_site( $id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( self::$network_ids as $id ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
- }
-
- wp_update_network_site_counts();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( self::$network_ids as $id ) {
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_ID() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'ID' => self::$site_ids['www.w.org/'],
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_network_site_counts();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array( self::$site_ids['www.w.org/'] ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_ID() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'ID' => self::$site_ids['www.w.org/'],
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_number() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array( self::$site_ids['www.w.org/'] ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertCount( 3, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_number() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_site__in_with_single_id() {
- $expected = array( self::$site_ids['wordpress.org/foo/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertCount( 3, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__in' => $expected,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_site__in_with_single_id() {
+ $expected = array( self::$site_ids['wordpress.org/foo/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__in' => $expected,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_site__in_with_multiple_ids() {
- $expected = array( self::$site_ids['wordpress.org/'], self::$site_ids['wordpress.org/foo/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__in' => $expected,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_site__in_with_multiple_ids() {
+ $expected = array( self::$site_ids['wordpress.org/'], self::$site_ids['wordpress.org/foo/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__in' => $expected,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the `count` query var
- */
- public function test_wp_site_query_by_site__in_and_count_with_multiple_ids() {
- $expected = array( self::$site_ids['wordpress.org/'], self::$site_ids['wordpress.org/foo/'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'count' => true,
- 'site__in' => $expected,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the `count` query var
+ */
+ public function test_wp_site_query_by_site__in_and_count_with_multiple_ids() {
+ $expected = array( self::$site_ids['wordpress.org/'], self::$site_ids['wordpress.org/foo/'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 2, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'count' => true,
+ 'site__in' => $expected,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_site__not_in_with_single_id() {
- $excluded = array( self::$site_ids['wordpress.org/foo/'] );
- $expected = array_diff( self::$site_ids, $excluded );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 2, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Exclude main site since we don't have control over it here.
- $excluded[] = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_site__not_in_with_single_id() {
+ $excluded = array( self::$site_ids['wordpress.org/foo/'] );
+ $expected = array_diff( self::$site_ids, $excluded );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__not_in' => $excluded,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Exclude main site since we don't have control over it here.
+ $excluded[] = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__not_in' => $excluded,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_site__not_in_with_multiple_ids() {
- $excluded = array( self::$site_ids['wordpress.org/'], self::$site_ids['wordpress.org/foo/'] );
- $expected = array_diff( self::$site_ids, $excluded );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Exclude main site since we don't have control over it here.
- $excluded[] = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_site__not_in_with_multiple_ids() {
+ $excluded = array( self::$site_ids['wordpress.org/'], self::$site_ids['wordpress.org/foo/'] );
+ $expected = array_diff( self::$site_ids, $excluded );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__not_in' => $excluded,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Exclude main site since we don't have control over it here.
+ $excluded[] = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__not_in' => $excluded,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_network_id_with_order() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/'],
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_network_id_with_order() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/'],
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'DESC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $found );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array_reverse( $expected ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'DESC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_network_id_with_existing_sites() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['make.wordpress.org/'],
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array_reverse( $expected ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_network_id_with_existing_sites() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['make.wordpress.org/'],
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_network_id_with_no_existing_sites() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['www.wordpress.net/'],
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_network_id_with_no_existing_sites() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['www.wordpress.net/'],
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain' => 'www.w.org',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/'],
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain' => 'www.w.org',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/'],
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain_and_offset() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain' => 'www.w.org',
- 'offset' => 1,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain_and_offset() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain' => 'www.w.org',
+ 'offset' => 1,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain_and_number_and_offset() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain' => 'www.w.org',
- 'number' => 2,
- 'offset' => 1,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain_and_number_and_offset() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain' => 'www.w.org',
+ 'number' => 2,
+ 'offset' => 1,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain__in_with_single_domain() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__in' => array( 'make.wordpress.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain__in_with_single_domain() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__in' => array( 'make.wordpress.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain__in_with_multiple_domains() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/'],
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain__in_with_multiple_domains() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__in' => array( 'wordpress.org', 'make.wordpress.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/'],
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain__not_in_with_single_domain() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__not_in' => array( 'www.w.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- get_current_blog_id(), // Account for the initial site added by the test suite.
- self::$site_ids['wordpress.org/'],
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain__not_in_with_single_domain() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__not_in' => array( 'www.w.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ get_current_blog_id(), // Account for the initial site added by the test suite.
+ self::$site_ids['wordpress.org/'],
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_domain__not_in_with_multiple_domains() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- get_current_blog_id(), // Account for the initial site added by the test suite.
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_domain__not_in_with_multiple_domains() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain__not_in' => array( 'wordpress.org', 'www.w.org' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ get_current_blog_id(), // Account for the initial site added by the test suite.
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_path_with_expected_results() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'path' => '/foo/bar/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_path_with_expected_results() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'path' => '/foo/bar/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_path_with_no_expected_results() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'path' => '/foo/bar/foo/',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_path_with_no_expected_results() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'path' => '/foo/bar/foo/',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // archived, mature, spam, deleted, public.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_archived() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'archived' => '0',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // archived, mature, spam, deleted, public.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_archived() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'archived' => '0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_mature() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'mature' => '0',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_mature() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'mature' => '0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_spam() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'spam' => '0',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_spam() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'spam' => '0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_deleted() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'deleted' => '0',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_deleted() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'deleted' => '0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_deleted_with_no_results() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'deleted' => '1',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_deleted_with_no_results() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'deleted' => '1',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_public() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'public' => '1',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_public() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'public' => '1',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang_id_with_zero() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'lang_id' => 0,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_diff( array_values( self::$site_ids ), array( self::$site_ids['www.w.org/make/'] ) ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang_id_with_zero() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'lang_id' => 0,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang_id() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang_id' => 1,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_diff( array_values( self::$site_ids ), array( self::$site_ids['www.w.org/make/'] ) ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang_id() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang_id' => 1,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang_id_with_no_results() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang_id' => 2,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang_id_with_no_results() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang_id' => 2,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang__in() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang__in' => array( 1 ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang__in() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang__in' => array( 1 ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang__in_with_multiple_ids() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- // Exclude main site since we don't have control over it here.
- 'site__not_in' => array( 1 ),
- 'lang__in' => array( 0, 1 ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang__in_with_multiple_ids() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ // Exclude main site since we don't have control over it here.
+ 'site__not_in' => array( 1 ),
+ 'lang__in' => array( 0, 1 ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang__not_in() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang__not_in' => array( 0 ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang__not_in() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang__not_in' => array( 0 ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_lang__not_in_with_multiple_ids() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang__not_in' => array( 0, 1 ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_lang__not_in_with_multiple_ids() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang__not_in' => array( 0, 1 ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_text_in_domain() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'ke.wordp',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_text_in_domain() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'ke.wordp',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_text_in_path() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'foo',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['make.wordpress.org/foo/'],
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_text_in_path() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'foo',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_text_in_path_and_domain() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'make',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_text_in_path_and_domain() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'make',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_text_in_path_and_domain_order_by_domain_desc() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'make',
- 'order' => 'DESC',
- 'orderby' => 'domain',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_text_in_path_and_domain_order_by_domain_desc() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'make',
+ 'order' => 'DESC',
+ 'orderby' => 'domain',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_text_in_path_exclude_domain_from_search() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'make',
- 'search_columns' => array( 'path' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_text_in_path_exclude_domain_from_search() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'make',
+ 'search_columns' => array( 'path' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_text_in_domain_exclude_path_from_search() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'make',
- 'search_columns' => array( 'domain' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_text_in_domain_exclude_path_from_search() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'make',
+ 'search_columns' => array( 'domain' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_wildcard_in_text() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'm*ke',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_wildcard_in_text() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'm*ke',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_wildcard_in_text_exclude_path_from_search() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'm*ke',
- 'search_columns' => array( 'domain' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_wildcard_in_text_exclude_path_from_search() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'm*ke',
+ 'search_columns' => array( 'domain' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wp_site_query_by_search_with_wildcard_in_text_exclude_domain_from_search() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'search' => 'm*ke',
- 'search_columns' => array( 'path' ),
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_site_query_by_search_with_wildcard_in_text_exclude_domain_from_search() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'search' => 'm*ke',
+ 'search_columns' => array( 'path' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41197
- */
- public function test_wp_site_query_cache_with_different_fields_no_count() {
- $q = new WP_Site_Query();
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $expected, $found );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41197
+ */
+ public function test_wp_site_query_cache_with_different_fields_no_count() {
+ $q = new WP_Site_Query();
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41197
- */
- public function test_wp_site_query_cache_with_different_fields_active_count() {
- $q = new WP_Site_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41197
+ */
+ public function test_wp_site_query_cache_with_different_fields_active_count() {
+ $q = new WP_Site_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41197
- */
- public function test_wp_site_query_cache_with_same_fields_different_count() {
- $q = new WP_Site_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_1 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41197
+ */
+ public function test_wp_site_query_cache_with_same_fields_different_count() {
+ $q = new WP_Site_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_1 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $this->assertSame( $number_of_queries + 1, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 55462
- */
- public function test_wp_site_query_cache_with_same_fields_same_cache_fields() {
- $q = new WP_Site_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries + 1, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_1 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'update_site_cache' => true,
- 'update_site_meta_cache' => true,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55462
+ */
+ public function test_wp_site_query_cache_with_same_fields_same_cache_fields() {
+ $q = new WP_Site_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_1 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_site_cache' => true,
+ 'update_site_meta_cache' => true,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'update_site_cache' => true,
- 'update_site_meta_cache' => true,
- )
- );
- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 55462
- */
- public function test_wp_site_query_cache_with_same_fields_different_cache_fields() {
- $q = new WP_Site_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_site_cache' => true,
+ 'update_site_meta_cache' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_1 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'update_site_cache' => true,
- 'update_site_meta_cache' => true,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55462
+ */
+ public function test_wp_site_query_cache_with_same_fields_different_cache_fields() {
+ $q = new WP_Site_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $number_of_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_1 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_site_cache' => true,
+ 'update_site_meta_cache' => true,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'update_site_cache' => false,
- 'update_site_meta_cache' => false,
- )
- );
- $this->assertSame( $number_of_queries, get_num_queries() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $number_of_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 40229
- * @dataProvider data_wp_site_query_meta_query
- */
- public function test_wp_site_query_meta_query( $query, $expected, $strict ) {
- if ( ! is_site_meta_supported() ) {
- $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_site_cache' => false,
+ 'update_site_meta_cache' => false,
+ )
+ );
+ $this->assertSame( $number_of_queries, get_num_queries() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_site_meta( self::$site_ids['wordpress.org/'], 'foo', 'foo' );
- add_site_meta( self::$site_ids['wordpress.org/foo/'], 'foo', 'bar' );
- add_site_meta( self::$site_ids['wordpress.org/foo/bar/'], 'foo', 'baz' );
- add_site_meta( self::$site_ids['make.wordpress.org/'], 'bar', 'baz' );
- add_site_meta( self::$site_ids['wordpress.org/'], 'numberfoo', 1 );
- add_site_meta( self::$site_ids['wordpress.org/foo/'], 'numberfoo', 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 40229
+ * @dataProvider data_wp_site_query_meta_query
+ */
+ public function test_wp_site_query_meta_query( $query, $expected, $strict ) {
+ if ( ! is_site_meta_supported() ) {
+ $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query['fields'] = 'ids';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_site_meta( self::$site_ids['wordpress.org/'], 'foo', 'foo' );
+ add_site_meta( self::$site_ids['wordpress.org/foo/'], 'foo', 'bar' );
+ add_site_meta( self::$site_ids['wordpress.org/foo/bar/'], 'foo', 'baz' );
+ add_site_meta( self::$site_ids['make.wordpress.org/'], 'bar', 'baz' );
+ add_site_meta( self::$site_ids['wordpress.org/'], 'numberfoo', 1 );
+ add_site_meta( self::$site_ids['wordpress.org/foo/'], 'numberfoo', 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $found = $q->query( $query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query['fields'] = 'ids';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $expected as $index => $domain_path ) {
- $expected[ $index ] = self::$site_ids[ $domain_path ];
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $found = $q->query( $query );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $strict ) {
- $this->assertSame( $expected, $found );
- } else {
- $this->assertSameSets( $expected, $found );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $expected as $index => $domain_path ) {
+ $expected[ $index ] = self::$site_ids[ $domain_path ];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_wp_site_query_meta_query() {
- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $strict ) {
+ $this->assertSame( $expected, $found );
+ } else {
+ $this->assertSameSets( $expected, $found );
+ }
+ }
+
+ public function data_wp_site_query_meta_query() {
+ return array(
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_key' => 'foo',
- ),
- array(
- 'wordpress.org/',
- 'wordpress.org/foo/',
- 'wordpress.org/foo/bar/',
- ),
- false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'meta_key' => 'foo',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_key' => 'foo',
- 'meta_value' => 'bar',
- ),
- array(
- 'wordpress.org/foo/',
- ),
- false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordpress.org/',
+ 'wordpress.org/foo/',
+ 'wordpress.org/foo/bar/',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ false,
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_key' => 'foo',
- 'meta_value' => array( 'bar', 'baz' ),
- 'meta_compare' => 'IN',
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/foo/bar/',
- ),
- false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'meta_key' => 'foo',
+ 'meta_value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => 'bar',
- ),
- array(
- 'key' => 'numberfoo',
- 'value' => 2,
- 'type' => 'NUMERIC',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordpress.org/foo/',
+ ),
+ false,
+ ),
+ array(
+ array(
+ 'meta_key' => 'foo',
+ 'meta_value' => array( 'bar', 'baz' ),
+ 'meta_compare' => 'IN',
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/foo/bar/',
+ ),
+ false,
+ ),
+ array(
+ array(
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => 'bar',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'key' => 'numberfoo',
+ 'value' => 2,
+ 'type' => 'NUMERIC',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'wordpress.org/foo/',
- ),
- false,
</del><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_key' => 'foo',
- 'orderby' => 'meta_value',
- 'order' => 'ASC',
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/foo/bar/',
- 'wordpress.org/',
- ),
- true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordpress.org/foo/',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ false,
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_key' => 'foo',
- 'orderby' => 'foo',
- 'order' => 'ASC',
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/foo/bar/',
- 'wordpress.org/',
- ),
- true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'meta_key' => 'foo',
+ 'orderby' => 'meta_value',
+ 'order' => 'ASC',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_key' => 'numberfoo',
- 'orderby' => 'meta_value_num',
- 'order' => 'DESC',
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordpress.org/foo/',
+ 'wordpress.org/foo/bar/',
+ 'wordpress.org/',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ true,
+ ),
+ array(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => array( 'foo', 'bar' ),
- 'compare' => 'IN',
- ),
- array(
- 'key' => 'numberfoo',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'meta_key' => 'foo',
+ 'orderby' => 'foo',
+ 'order' => 'ASC',
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/foo/bar/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ 'meta_key' => 'numberfoo',
+ 'orderby' => 'meta_value_num',
+ 'order' => 'DESC',
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => array( 'foo', 'bar' ),
+ 'compare' => 'IN',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'orderby' => array( 'meta_value' => 'ASC' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'key' => 'numberfoo',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'orderby' => array( 'meta_value' => 'ASC' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => array( 'foo', 'bar' ),
- 'compare' => 'IN',
- ),
- array(
- 'key' => 'numberfoo',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => array( 'foo', 'bar' ),
+ 'compare' => 'IN',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'orderby' => array( 'foo' => 'ASC' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'key' => 'numberfoo',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'orderby' => array( 'foo' => 'ASC' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => array( 'foo', 'bar' ),
- 'compare' => 'IN',
- ),
- 'my_subquery' => array(
- 'key' => 'numberfoo',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => array( 'foo', 'bar' ),
+ 'compare' => 'IN',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'orderby' => array( 'my_subquery' => 'DESC' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'my_subquery' => array(
+ 'key' => 'numberfoo',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'orderby' => array( 'my_subquery' => 'DESC' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 45749
- * @ticket 47599
- */
- public function test_sites_pre_query_filter_should_bypass_database_query() {
- add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 45749
+ * @ticket 47599
+ */
+ public function test_sites_pre_query_filter_should_bypass_database_query() {
+ add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $num_queries = get_num_queries();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_queries = get_num_queries();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $results = $q->query( array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $results = $q->query( array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure no queries were executed.
- $this->assertSame( $num_queries, get_num_queries() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure no queries were executed.
+ $this->assertSame( $num_queries, get_num_queries() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We manually inserted a non-existing site and overrode the results with it.
- $this->assertSame( array( 555 ), $results );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // We manually inserted a non-existing site and overrode the results with it.
+ $this->assertSame( array( 555 ), $results );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure manually setting found_sites doesn't get overwritten.
- $this->assertSame( 1, $q->found_sites );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure manually setting found_sites doesn't get overwritten.
+ $this->assertSame( 1, $q->found_sites );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function filter_sites_pre_query( $sites, $query ) {
- $query->found_sites = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function filter_sites_pre_query( $sites, $query ) {
+ $query->found_sites = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array( 555 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return array( 555 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 51333
- */
- public function test_sites_pre_query_filter_should_set_sites_property() {
- add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query_and_set_sites' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 51333
+ */
+ public function test_sites_pre_query_filter_should_set_sites_property() {
+ add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query_and_set_sites' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q = new WP_Site_Query();
- $results = $q->query( array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q = new WP_Site_Query();
+ $results = $q->query( array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query_and_set_sites' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query_and_set_sites' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure the sites property is the same as the results.
- $this->assertSame( $results, $q->sites );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure the sites property is the same as the results.
+ $this->assertSame( $results, $q->sites );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure the site domain is `wordpress.org`.
- $this->assertSame( 'wordpress.org', $q->sites[0]->domain );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure the site domain is `wordpress.org`.
+ $this->assertSame( 'wordpress.org', $q->sites[0]->domain );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function filter_sites_pre_query_and_set_sites( $sites, $query ) {
- return array( get_site( self::$site_ids['wordpress.org/'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function filter_sites_pre_query_and_set_sites( $sites, $query ) {
+ return array( get_site( self::$site_ids['wordpress.org/'] ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 56841
- */
- public function test_wp_site_query_does_not_have_leading_whitespace() {
- $q = new WP_Site_Query();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 56841
+ */
+ public function test_wp_site_query_does_not_have_leading_whitespace() {
+ $q = new WP_Site_Query();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'update_site_cache' => true,
- 'update_site_meta_cache' => true,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'update_site_cache' => true,
+ 'update_site_meta_cache' => true,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( ltrim( $q->request ), $q->request, 'The query has leading whitespace' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( ltrim( $q->request ), $q->request, 'The query has leading whitespace' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpmuLogNewRegistrationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpmuLogNewRegistrations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpmuLogNewRegistrations.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpmuLogNewRegistrations.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,24 +1,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_wpmuLogNewRegistrations extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group multisite
- */
- class Tests_Multisite_wpmuLogNewRegistrations extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wpmu_log_new_registrations() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_wpmu_log_new_registrations() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( 1 );
+ $ip = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = new WP_User( 1 );
- $ip = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_log_new_registrations( 1, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_log_new_registrations( 1, 1 );
-
- // Currently there is no wrapper function for the registration_log.
- $reg_blog = $wpdb->get_col( $wpdb->prepare( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE %s", $ip ) );
- $this->assertSame( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Currently there is no wrapper function for the registration_log.
+ $reg_blog = $wpdb->get_col( $wpdb->prepare( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE %s", $ip ) );
+ $this->assertSame( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpmuValidateBlogSignupphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,161 +1,159 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_wpmuValidateBlogSignup extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group multisite
- */
- class Tests_Multisite_wpmuValidateBlogSignup extends WP_UnitTestCase {
- protected static $super_admin_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $super_admin_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected static $existing_user_login = 'existinguserfoo';
- protected static $existing_user_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $existing_user_login = 'existinguserfoo';
+ protected static $existing_user_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected static $existing_blog_name = 'existingsitefoo';
- protected static $existing_blog_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $existing_blog_name = 'existingsitefoo';
+ protected static $existing_blog_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $minimum_site_name_length = 4;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $minimum_site_name_length = 4;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$super_admin_id = $factory->user->create();
- grant_super_admin( self::$super_admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$super_admin_id = $factory->user->create();
+ grant_super_admin( self::$super_admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::$existing_user_id = $factory->user->create( array( 'user_login' => self::$existing_user_login ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$existing_user_id = $factory->user->create( array( 'user_login' => self::$existing_user_login ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network = get_network();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network = get_network();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_subdomain_install() ) {
- $domain = self::$existing_blog_name . '.' . preg_replace( '|^www\.|', '', $network->domain );
- $path = $network->path;
- } else {
- $domain = $network->domain;
- $path = $network->path . self::$existing_blog_name . '/';
- }
-
- self::$existing_blog_id = $factory->blog->create(
- array(
- 'domain' => $domain,
- 'path' => $path,
- 'network_id' => $network->id,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_subdomain_install() ) {
+ $domain = self::$existing_blog_name . '.' . preg_replace( '|^www\.|', '', $network->domain );
+ $path = $network->path;
+ } else {
+ $domain = $network->domain;
+ $path = $network->path . self::$existing_blog_name . '/';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- revoke_super_admin( self::$super_admin_id );
- wpmu_delete_user( self::$super_admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$existing_blog_id = $factory->blog->create(
+ array(
+ 'domain' => $domain,
+ 'path' => $path,
+ 'network_id' => $network->id,
+ )
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_user( self::$existing_user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ revoke_super_admin( self::$super_admin_id );
+ wpmu_delete_user( self::$super_admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( self::$existing_blog_id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_user( self::$existing_user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_validate_blogname
- */
- public function test_validate_blogname( $blog_name, $error_message ) {
- $result = wpmu_validate_blog_signup( $blog_name, 'Foo Site Title', get_userdata( self::$super_admin_id ) );
- $this->assertContains( 'blogname', $result['errors']->get_error_codes(), $error_message );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( self::$existing_blog_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_validate_blogname() {
- $data = array(
- array( '', 'Site names must not be empty.' ),
- array( 'foo-hello', 'Site names must not contain hyphens.' ),
- array( 'foo_hello', 'Site names must not contain underscores.' ),
- array( 'foo hello', 'Site names must not contain spaces.' ),
- array( 'FooHello', 'Site names must not contain uppercase letters.' ),
- array( '12345678', 'Site names must not consist of numbers only.' ),
- array( self::$existing_blog_name, 'Site names must not collide with an existing site name.' ),
- array( self::$existing_user_login, 'Site names must not collide with an existing user login.' ),
- array( 'foo', 'Site names must at least contain 4 characters.' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_validate_blogname
+ */
+ public function test_validate_blogname( $blog_name, $error_message ) {
+ $result = wpmu_validate_blog_signup( $blog_name, 'Foo Site Title', get_userdata( self::$super_admin_id ) );
+ $this->assertContains( 'blogname', $result['errors']->get_error_codes(), $error_message );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $illegal_names = get_site_option( 'illegal_names' );
- if ( ! empty( $illegal_names ) ) {
- $data[] = array( array_shift( $illegal_names ), 'Illegal site names are not allowed.' );
- } else {
- $data[] = array( 'www', 'Illegal site names are not allowed.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_validate_blogname() {
+ $data = array(
+ array( '', 'Site names must not be empty.' ),
+ array( 'foo-hello', 'Site names must not contain hyphens.' ),
+ array( 'foo_hello', 'Site names must not contain underscores.' ),
+ array( 'foo hello', 'Site names must not contain spaces.' ),
+ array( 'FooHello', 'Site names must not contain uppercase letters.' ),
+ array( '12345678', 'Site names must not consist of numbers only.' ),
+ array( self::$existing_blog_name, 'Site names must not collide with an existing site name.' ),
+ array( self::$existing_user_login, 'Site names must not collide with an existing user login.' ),
+ array( 'foo', 'Site names must at least contain 4 characters.' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $data;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $illegal_names = get_site_option( 'illegal_names' );
+ if ( ! empty( $illegal_names ) ) {
+ $data[] = array( array_shift( $illegal_names ), 'Illegal site names are not allowed.' );
+ } else {
+ $data[] = array( 'www', 'Illegal site names are not allowed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_validate_empty_blog_title() {
- $result = wpmu_validate_blog_signup( 'uniqueblogname1234', '', get_userdata( self::$super_admin_id ) );
- $this->assertContains( 'blog_title', $result['errors']->get_error_codes(), 'Site titles must not be empty.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $data;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_validate_blogname_from_same_existing_user() {
- $result = wpmu_validate_blog_signup( self::$existing_user_login, 'Foo Site Title', get_userdata( self::$existing_user_id ) );
- $this->assertEmpty( $result['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_validate_empty_blog_title() {
+ $result = wpmu_validate_blog_signup( 'uniqueblogname1234', '', get_userdata( self::$super_admin_id ) );
+ $this->assertContains( 'blog_title', $result['errors']->get_error_codes(), 'Site titles must not be empty.' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 39676
- *
- * @dataProvider data_filter_minimum_site_name_length
- */
- public function test_filter_minimum_site_name_length( $site_name, $minimum_length, $expect_error ) {
- $this->minimum_site_name_length = $minimum_length;
- add_filter( 'minimum_site_name_length', array( $this, 'filter_minimum_site_name_length' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_validate_blogname_from_same_existing_user() {
+ $result = wpmu_validate_blog_signup( self::$existing_user_login, 'Foo Site Title', get_userdata( self::$existing_user_id ) );
+ $this->assertEmpty( $result['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = wpmu_validate_blog_signup( $site_name, 'Site Title', get_userdata( self::$super_admin_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 39676
+ *
+ * @dataProvider data_filter_minimum_site_name_length
+ */
+ public function test_filter_minimum_site_name_length( $site_name, $minimum_length, $expect_error ) {
+ $this->minimum_site_name_length = $minimum_length;
+ add_filter( 'minimum_site_name_length', array( $this, 'filter_minimum_site_name_length' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'minimum_site_name_length', array( $this, 'filter_minimum_site_name_length' ) );
- $this->minimum_site_name_length = 4;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = wpmu_validate_blog_signup( $site_name, 'Site Title', get_userdata( self::$super_admin_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $expect_error ) {
- $this->assertContains( 'blogname', $result['errors']->get_error_codes() );
- } else {
- $this->assertEmpty( $result['errors']->get_error_codes() );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'minimum_site_name_length', array( $this, 'filter_minimum_site_name_length' ) );
+ $this->minimum_site_name_length = 4;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_filter_minimum_site_name_length() {
- return array(
- array( 'fooo', 5, true ),
- array( 'foooo', 5, false ),
- array( 'foo', 4, true ),
- array( 'fooo', 4, false ),
- array( 'fo', 3, true ),
- array( 'foo', 3, false ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $expect_error ) {
+ $this->assertContains( 'blogname', $result['errors']->get_error_codes() );
+ } else {
+ $this->assertEmpty( $result['errors']->get_error_codes() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_minimum_site_name_length() {
- return $this->minimum_site_name_length;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_filter_minimum_site_name_length() {
+ return array(
+ array( 'fooo', 5, true ),
+ array( 'foooo', 5, false ),
+ array( 'foo', 4, true ),
+ array( 'fooo', 4, false ),
+ array( 'fo', 3, true ),
+ array( 'foo', 3, false ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 43667
- */
- public function test_signup_nonce_check() {
- $original_php_self = $_SERVER['PHP_SELF'];
- $_SERVER['PHP_SELF'] = '/wp-signup.php';
- $_POST['signup_form_id'] = 'blog-signup-form';
- $_POST['_signup_form'] = wp_create_nonce( 'signup_form_' . $_POST['signup_form_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_minimum_site_name_length() {
+ return $this->minimum_site_name_length;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $valid = wpmu_validate_blog_signup( 'my-nonce-site', 'Site Title', get_userdata( self::$super_admin_id ) );
- $_SERVER['PHP_SELF'] = $original_php_self;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 43667
+ */
+ public function test_signup_nonce_check() {
+ $original_php_self = $_SERVER['PHP_SELF'];
+ $_SERVER['PHP_SELF'] = '/wp-signup.php';
+ $_POST['signup_form_id'] = 'blog-signup-form';
+ $_POST['_signup_form'] = wp_create_nonce( 'signup_form_' . $_POST['signup_form_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $valid = wpmu_validate_blog_signup( 'my-nonce-site', 'Site Title', get_userdata( self::$super_admin_id ) );
+ $_SERVER['PHP_SELF'] = $original_php_self;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 43667
- */
- public function test_signup_nonce_check_invalid() {
- $original_php_self = $_SERVER['PHP_SELF'];
- $_SERVER['PHP_SELF'] = '/wp-signup.php';
- $_POST['signup_form_id'] = 'blog-signup-form';
- $_POST['_signup_form'] = wp_create_nonce( 'invalid' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $valid = wpmu_validate_blog_signup( 'my-nonce-site', 'Site Title', get_userdata( self::$super_admin_id ) );
- $_SERVER['PHP_SELF'] = $original_php_self;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 43667
+ */
+ public function test_signup_nonce_check_invalid() {
+ $original_php_self = $_SERVER['PHP_SELF'];
+ $_SERVER['PHP_SELF'] = '/wp-signup.php';
+ $_POST['signup_form_id'] = 'blog-signup-form';
+ $_POST['_signup_form'] = wp_create_nonce( 'invalid' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $valid = wpmu_validate_blog_signup( 'my-nonce-site', 'Site Title', get_userdata( self::$super_admin_id ) );
+ $_SERVER['PHP_SELF'] = $original_php_self;
+
+ $this->assertContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpmuValidateUserSignupphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,273 +1,271 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Multisite_wpmuValidateUserSignup extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @dataProvider data_user_name
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Multisite_wpmuValidateUserSignup extends WP_UnitTestCase {
- /**
- * @dataProvider data_user_name
- */
- public function test_user_name( $user_name, $error_message ) {
- $v = wpmu_validate_user_signup( $user_name, 'foo@example.com' );
- $this->assertContains( 'user_name', $v['errors']->get_error_codes(), $error_message );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_user_name( $user_name, $error_message ) {
+ $v = wpmu_validate_user_signup( $user_name, 'foo@example.com' );
+ $this->assertContains( 'user_name', $v['errors']->get_error_codes(), $error_message );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_user_name() {
- return array(
- array( 'contains spaces', 'User names with spaces are not allowed.' ),
- array( 'ContainsCaps', 'User names with capital letters are not allowed.' ),
- array( 'contains_underscores', 'User names with underscores are not allowed.' ),
- array( 'contains%^*()junk', 'User names with non-alphanumeric characters are not allowed.' ),
- array( '', 'Empty user names are not allowed.' ),
- array( 'foo', 'User names of 3 characters are not allowed.' ),
- array( 'fo', 'User names of 2 characters are not allowed.' ),
- array( 'f', 'User names of 1 characters are not allowed.' ),
- array( 'f', 'User names of 1 characters are not allowed.' ),
- array( '12345', 'User names consisting only of numbers are not allowed.' ),
- array( 'thisusernamecontainsenoughcharacterstobelongerthan60characters', 'User names longer than 60 characters are not allowed.' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_user_name() {
+ return array(
+ array( 'contains spaces', 'User names with spaces are not allowed.' ),
+ array( 'ContainsCaps', 'User names with capital letters are not allowed.' ),
+ array( 'contains_underscores', 'User names with underscores are not allowed.' ),
+ array( 'contains%^*()junk', 'User names with non-alphanumeric characters are not allowed.' ),
+ array( '', 'Empty user names are not allowed.' ),
+ array( 'foo', 'User names of 3 characters are not allowed.' ),
+ array( 'fo', 'User names of 2 characters are not allowed.' ),
+ array( 'f', 'User names of 1 characters are not allowed.' ),
+ array( 'f', 'User names of 1 characters are not allowed.' ),
+ array( '12345', 'User names consisting only of numbers are not allowed.' ),
+ array( 'thisusernamecontainsenoughcharacterstobelongerthan60characters', 'User names longer than 60 characters are not allowed.' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_illegal_names() {
- $illegal = array( 'foo123', 'bar123' );
- update_site_option( 'illegal_names', $illegal );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_illegal_names() {
+ $illegal = array( 'foo123', 'bar123' );
+ update_site_option( 'illegal_names', $illegal );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $illegal as $i ) {
- $v = wpmu_validate_user_signup( $i, 'foo@example.com' );
- $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $illegal as $i ) {
+ $v = wpmu_validate_user_signup( $i, 'foo@example.com' );
+ $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_unsafe_email_address() {
- add_filter( 'is_email_address_unsafe', '__return_true' );
- $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
- $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
- remove_filter( 'is_email_address_unsafe', '__return_true' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_unsafe_email_address() {
+ add_filter( 'is_email_address_unsafe', '__return_true' );
+ $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
+ $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
+ remove_filter( 'is_email_address_unsafe', '__return_true' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_invalid_email_address() {
- add_filter( 'is_email', '__return_false' );
- $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
- $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
- remove_filter( 'is_email', '__return_false' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_invalid_email_address() {
+ add_filter( 'is_email', '__return_false' );
+ $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
+ $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
+ remove_filter( 'is_email', '__return_false' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_emails_from_disallowed_domains() {
- $domains = array( 'foo.com', 'bar.org' );
- update_site_option( 'limited_email_domains', $domains );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_emails_from_disallowed_domains() {
+ $domains = array( 'foo.com', 'bar.org' );
+ update_site_option( 'limited_email_domains', $domains );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
- $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
+ $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_not_fail_for_emails_from_allowed_domains_with_mixed_case() {
- $domains = array( 'foo.com', 'bar.org' );
- update_site_option( 'limited_email_domains', $domains );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_not_fail_for_emails_from_allowed_domains_with_mixed_case() {
+ $domains = array( 'foo.com', 'bar.org' );
+ update_site_option( 'limited_email_domains', $domains );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $v = wpmu_validate_user_signup( 'foo123', 'foo@BAR.org' );
- $this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $v = wpmu_validate_user_signup( 'foo123', 'foo@BAR.org' );
+ $this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_existing_user_name() {
- $u = self::factory()->user->create( array( 'user_login' => 'foo123' ) );
- $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
- $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_existing_user_name() {
+ $u = self::factory()->user->create( array( 'user_login' => 'foo123' ) );
+ $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
+ $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_existing_user_email() {
- $u = self::factory()->user->create( array( 'user_email' => 'foo@example.com' ) );
- $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
- $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_existing_user_email() {
+ $u = self::factory()->user->create( array( 'user_email' => 'foo@example.com' ) );
+ $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
+ $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_existing_signup_with_same_username() {
- // Don't send notifications.
- add_filter( 'wpmu_signup_user_notification', '__return_false' );
- wpmu_signup_user( 'foo123', 'foo@example.com' );
- remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_existing_signup_with_same_username() {
+ // Don't send notifications.
+ add_filter( 'wpmu_signup_user_notification', '__return_false' );
+ wpmu_signup_user( 'foo123', 'foo@example.com' );
+ remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
- $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
+ $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_not_fail_for_existing_signup_with_same_username_if_signup_is_old() {
- // Don't send notifications.
- add_filter( 'wpmu_signup_user_notification', '__return_false' );
- wpmu_signup_user( 'foo123', 'foo@example.com' );
- remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_not_fail_for_existing_signup_with_same_username_if_signup_is_old() {
+ // Don't send notifications.
+ add_filter( 'wpmu_signup_user_notification', '__return_false' );
+ wpmu_signup_user( 'foo123', 'foo@example.com' );
+ remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
- $date = gmdate( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
- $wpdb->update( $wpdb->signups, array( 'registered' => $date ), array( 'user_login' => 'foo123' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+ $date = gmdate( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
+ $wpdb->update( $wpdb->signups, array( 'registered' => $date ), array( 'user_login' => 'foo123' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
- $this->assertNotContains( 'user_name', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
+ $this->assertNotContains( 'user_name', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_fail_for_existing_signup_with_same_email() {
- // Don't send notifications.
- add_filter( 'wpmu_signup_user_notification', '__return_false' );
- wpmu_signup_user( 'foo123', 'foo@example.com' );
- remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_fail_for_existing_signup_with_same_email() {
+ // Don't send notifications.
+ add_filter( 'wpmu_signup_user_notification', '__return_false' );
+ wpmu_signup_user( 'foo123', 'foo@example.com' );
+ remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $v = wpmu_validate_user_signup( 'foo2', 'foo@example.com' );
- $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $v = wpmu_validate_user_signup( 'foo2', 'foo@example.com' );
+ $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_should_not_fail_for_existing_signup_with_same_email_if_signup_is_old() {
- // Don't send notifications.
- add_filter( 'wpmu_signup_user_notification', '__return_false' );
- wpmu_signup_user( 'foo123', 'foo@example.com' );
- remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_should_not_fail_for_existing_signup_with_same_email_if_signup_is_old() {
+ // Don't send notifications.
+ add_filter( 'wpmu_signup_user_notification', '__return_false' );
+ wpmu_signup_user( 'foo123', 'foo@example.com' );
+ remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
- $date = gmdate( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
- $wpdb->update( $wpdb->signups, array( 'registered' => $date ), array( 'user_login' => 'foo123' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+ $date = gmdate( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
+ $wpdb->update( $wpdb->signups, array( 'registered' => $date ), array( 'user_login' => 'foo123' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $v = wpmu_validate_user_signup( 'foo2', 'foo2@example.com' );
- $this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $v = wpmu_validate_user_signup( 'foo2', 'foo2@example.com' );
+ $this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 43232
- */
- public function test_should_not_fail_for_data_used_by_a_deleted_user() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 43232
+ */
+ public function test_should_not_fail_for_data_used_by_a_deleted_user() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Don't send notifications.
- add_filter( 'wpmu_signup_user_notification', '__return_false' );
- add_filter( 'wpmu_welcome_user_notification', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Don't send notifications.
+ add_filter( 'wpmu_signup_user_notification', '__return_false' );
+ add_filter( 'wpmu_welcome_user_notification', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Signup, activate and delete new user.
- wpmu_signup_user( 'foo123', 'foo@example.com' );
- $key = $wpdb->get_var( "SELECT activation_key FROM $wpdb->signups WHERE user_login = 'foo123'" );
- $user = wpmu_activate_signup( $key );
- wpmu_delete_user( $user['user_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Signup, activate and delete new user.
+ wpmu_signup_user( 'foo123', 'foo@example.com' );
+ $key = $wpdb->get_var( "SELECT activation_key FROM $wpdb->signups WHERE user_login = 'foo123'" );
+ $user = wpmu_activate_signup( $key );
+ wpmu_delete_user( $user['user_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $valid = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $valid = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'wpmu_signup_user_notification', '__return_false' );
- remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'wpmu_signup_user_notification', '__return_false' );
+ remove_filter( 'wpmu_signup_user_notification', '__return_false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotContains( 'user_name', $valid['errors']->get_error_codes() );
- $this->assertNotContains( 'user_email', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotContains( 'user_name', $valid['errors']->get_error_codes() );
+ $this->assertNotContains( 'user_email', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_invalid_email_address_with_no_banned_domains_results_in_error() {
- $valid = wpmu_validate_user_signup( 'validusername', 'invalid-email' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_invalid_email_address_with_no_banned_domains_results_in_error() {
+ $valid = wpmu_validate_user_signup( 'validusername', 'invalid-email' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_invalid_email_address_with_banned_domains_results_in_error() {
- update_site_option( 'banned_email_domains', 'bar.com' );
- $valid = wpmu_validate_user_signup( 'validusername', 'invalid-email' );
- delete_site_option( 'banned_email_domains' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_invalid_email_address_with_banned_domains_results_in_error() {
+ update_site_option( 'banned_email_domains', 'bar.com' );
+ $valid = wpmu_validate_user_signup( 'validusername', 'invalid-email' );
+ delete_site_option( 'banned_email_domains' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_incomplete_email_address_with_no_banned_domains_results_in_error() {
- $valid = wpmu_validate_user_signup( 'validusername', 'incomplete@email' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_incomplete_email_address_with_no_banned_domains_results_in_error() {
+ $valid = wpmu_validate_user_signup( 'validusername', 'incomplete@email' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_valid_email_address_matching_banned_domain_results_in_error() {
- update_site_option( 'banned_email_domains', 'bar.com' );
- $valid = wpmu_validate_user_signup( 'validusername', 'email@bar.com' );
- delete_site_option( 'banned_email_domains' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_valid_email_address_matching_banned_domain_results_in_error() {
+ update_site_option( 'banned_email_domains', 'bar.com' );
+ $valid = wpmu_validate_user_signup( 'validusername', 'email@bar.com' );
+ delete_site_option( 'banned_email_domains' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( 'user_email', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_valid_email_address_not_matching_banned_domain_returns_in_success() {
- update_site_option( 'banned_email_domains', 'bar.com' );
- $valid = wpmu_validate_user_signup( 'validusername', 'email@example.com' );
- delete_site_option( 'banned_email_domains' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_valid_email_address_not_matching_banned_domain_returns_in_success() {
+ update_site_option( 'banned_email_domains', 'bar.com' );
+ $valid = wpmu_validate_user_signup( 'validusername', 'email@example.com' );
+ delete_site_option( 'banned_email_domains' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotContains( 'user_email', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotContains( 'user_email', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 43667
- */
- public function test_signup_nonce_check() {
- $original_php_self = $_SERVER['PHP_SELF'];
- $_SERVER['PHP_SELF'] = '/wp-signup.php';
- $_POST['signup_form_id'] = 'user-signup-form';
- $_POST['_signup_form'] = wp_create_nonce( 'signup_form_' . $_POST['signup_form_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 43667
+ */
+ public function test_signup_nonce_check() {
+ $original_php_self = $_SERVER['PHP_SELF'];
+ $_SERVER['PHP_SELF'] = '/wp-signup.php';
+ $_POST['signup_form_id'] = 'user-signup-form';
+ $_POST['_signup_form'] = wp_create_nonce( 'signup_form_' . $_POST['signup_form_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $valid = wpmu_validate_user_signup( 'validusername', 'email@example.com' );
- $_SERVER['PHP_SELF'] = $original_php_self;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $valid = wpmu_validate_user_signup( 'validusername', 'email@example.com' );
+ $_SERVER['PHP_SELF'] = $original_php_self;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 43667
- */
- public function test_signup_nonce_check_invalid() {
- $original_php_self = $_SERVER['PHP_SELF'];
- $_SERVER['PHP_SELF'] = '/wp-signup.php';
- $_POST['signup_form_id'] = 'user-signup-form';
- $_POST['_signup_form'] = wp_create_nonce( 'invalid' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 43667
+ */
+ public function test_signup_nonce_check_invalid() {
+ $original_php_self = $_SERVER['PHP_SELF'];
+ $_SERVER['PHP_SELF'] = '/wp-signup.php';
+ $_POST['signup_form_id'] = 'user-signup-form';
+ $_POST['_signup_form'] = wp_create_nonce( 'invalid' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $valid = wpmu_validate_user_signup( 'validusername', 'email@example.com' );
- $_SERVER['PHP_SELF'] = $original_php_self;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $valid = wpmu_validate_user_signup( 'validusername', 'email@example.com' );
+ $_SERVER['PHP_SELF'] = $original_php_self;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( 'invalid_nonce', $valid['errors']->get_error_codes() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Ensure that wp_ensure_editable_role does not throw an exception when the role is editable.
- *
- * @ticket 43251
- *
- * @covers ::wp_ensure_editable_role
- */
- public function test_wp_ensure_editable_role_allows_editable_roles() {
- $role = get_role( 'editor' );
- $this->assertInstanceOf( 'WP_Role', $role, 'The editor role should exist.' );
- $this->assertNull( wp_ensure_editable_role( 'editor' ), 'The editor role should be editable.' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Ensure that wp_ensure_editable_role does not throw an exception when the role is editable.
+ *
+ * @ticket 43251
+ *
+ * @covers ::wp_ensure_editable_role
+ */
+ public function test_wp_ensure_editable_role_allows_editable_roles() {
+ $role = get_role( 'editor' );
+ $this->assertInstanceOf( 'WP_Role', $role, 'The editor role should exist.' );
+ $this->assertNull( wp_ensure_editable_role( 'editor' ), 'The editor role should be editable.' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Ensure that wp_ensure_editable_role throws an exception for non-existent roles.
- *
- * @ticket 43251
- *
- * @covers ::wp_ensure_editable_role
- */
- public function test_wp_ensure_editable_role_does_not_allow_non_existent_role() {
- $this->expectException( 'WPDieException' );
- $role = get_role( 'non-existent-role' );
- $this->assertNotInstanceOf( 'WP_Role', $role, 'The non-existent-role role should not exist.' );
- wp_ensure_editable_role( 'non-existent-role' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Ensure that wp_ensure_editable_role throws an exception for non-existent roles.
+ *
+ * @ticket 43251
+ *
+ * @covers ::wp_ensure_editable_role
+ */
+ public function test_wp_ensure_editable_role_does_not_allow_non_existent_role() {
+ $this->expectException( 'WPDieException' );
+ $role = get_role( 'non-existent-role' );
+ $this->assertNotInstanceOf( 'WP_Role', $role, 'The non-existent-role role should not exist.' );
+ wp_ensure_editable_role( 'non-existent-role' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Ensure that wp_ensure_editable_role throws an exception for roles that are not editable.
- *
- * @ticket 43251
- *
- * @covers ::wp_ensure_editable_role
- */
- public function test_wp_ensure_editable_role_does_not_allow_uneditable_roles() {
- add_filter(
- 'editable_roles',
- function ( $roles ) {
- unset( $roles['editor'] );
- return $roles;
- }
- );
- $this->expectException( 'WPDieException' );
- $role = get_role( 'editor' );
- $this->assertInstanceOf( 'WP_Role', $role, 'The editor role should exist.' );
- wp_ensure_editable_role( 'editor' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Ensure that wp_ensure_editable_role throws an exception for roles that are not editable.
+ *
+ * @ticket 43251
+ *
+ * @covers ::wp_ensure_editable_role
+ */
+ public function test_wp_ensure_editable_role_does_not_allow_uneditable_roles() {
+ add_filter(
+ 'editable_roles',
+ function ( $roles ) {
+ unset( $roles['editor'] );
+ return $roles;
+ }
+ );
+ $this->expectException( 'WPDieException' );
+ $role = get_role( 'editor' );
+ $this->assertInstanceOf( 'WP_Role', $role, 'The editor role should exist.' );
+ wp_ensure_editable_role( 'editor' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsoptionmultisitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/option/multisite.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/option/multisite.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/option/multisite.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,259 +1,256 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to network and site options in Multisite.
+ *
+ * @group option
+ * @group ms-option
+ * @group ms-required
+ * @group multisite
+ */
+class Tests_Option_Multisite extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Tests specific to network and site options in Multisite.
- *
- * @group option
- * @group ms-option
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @covers ::get_blog_option
+ * @covers ::get_option
+ * @covers ::add_blog_option
+ * @covers ::update_blog_option
+ * @covers ::delete_blog_option
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Option_Multisite extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_from_same_site() {
+ $key = __FUNCTION__ . '_1';
+ $key2 = __FUNCTION__ . '_2';
+ $value = __FUNCTION__ . '_val1';
+ $value2 = __FUNCTION__ . '_val2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @covers ::get_blog_option
- * @covers ::get_option
- * @covers ::add_blog_option
- * @covers ::update_blog_option
- * @covers ::delete_blog_option
- */
- public function test_from_same_site() {
- $key = __FUNCTION__ . '_1';
- $key2 = __FUNCTION__ . '_2';
- $value = __FUNCTION__ . '_val1';
- $value2 = __FUNCTION__ . '_val2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( get_blog_option( 1, 'doesnotexist' ) );
+ $this->assertFalse( get_option( 'doesnotexist' ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( get_blog_option( 1, 'doesnotexist' ) );
- $this->assertFalse( get_option( 'doesnotexist' ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( add_blog_option( 1, $key, $value ) );
+ // Assert all values of $blog_id that means the current or main blog (the same here).
+ $this->assertSame( $value, get_blog_option( 1, $key ) );
+ $this->assertSame( $value, get_blog_option( null, $key ) );
+ $this->assertSame( $value, get_blog_option( '1', $key ) );
+ $this->assertSame( $value, get_option( $key ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( add_blog_option( 1, $key, $value ) );
- // Assert all values of $blog_id that means the current or main blog (the same here).
- $this->assertSame( $value, get_blog_option( 1, $key ) );
- $this->assertSame( $value, get_blog_option( null, $key ) );
- $this->assertSame( $value, get_blog_option( '1', $key ) );
- $this->assertSame( $value, get_option( $key ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( add_blog_option( 1, $key, $value ) ); // Already exists.
+ $this->assertFalse( update_blog_option( 1, $key, $value ) ); // Value is the same.
+ $this->assertTrue( update_blog_option( 1, $key, $value2 ) );
+ $this->assertSame( $value2, get_blog_option( 1, $key ) );
+ $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
+ $this->assertFalse( add_blog_option( 1, $key, $value ) );
+ $this->assertSame( $value2, get_blog_option( 1, $key ) );
+ $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( add_blog_option( 1, $key, $value ) ); // Already exists.
- $this->assertFalse( update_blog_option( 1, $key, $value ) ); // Value is the same.
- $this->assertTrue( update_blog_option( 1, $key, $value2 ) );
- $this->assertSame( $value2, get_blog_option( 1, $key ) );
- $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
- $this->assertFalse( add_blog_option( 1, $key, $value ) );
- $this->assertSame( $value2, get_blog_option( 1, $key ) );
- $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( delete_blog_option( 1, $key ) );
+ $this->assertFalse( get_blog_option( 1, $key ) );
+ $this->assertFalse( get_option( $key ) ); // Check get_option().
+ $this->assertFalse( delete_blog_option( 1, $key ) );
+ $this->assertTrue( update_blog_option( 1, $key2, $value2 ) );
+ $this->assertSame( $value2, get_blog_option( 1, $key2 ) );
+ $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option().
+ $this->assertTrue( delete_blog_option( 1, $key2 ) );
+ $this->assertFalse( get_blog_option( 1, $key2 ) );
+ $this->assertFalse( get_option( $key2 ) ); // Check get_option().
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( delete_blog_option( 1, $key ) );
- $this->assertFalse( get_blog_option( 1, $key ) );
- $this->assertFalse( get_option( $key ) ); // Check get_option().
- $this->assertFalse( delete_blog_option( 1, $key ) );
- $this->assertTrue( update_blog_option( 1, $key2, $value2 ) );
- $this->assertSame( $value2, get_blog_option( 1, $key2 ) );
- $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option().
- $this->assertTrue( delete_blog_option( 1, $key2 ) );
- $this->assertFalse( get_blog_option( 1, $key2 ) );
- $this->assertFalse( get_option( $key2 ) ); // Check get_option().
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @covers ::get_blog_option
+ * @covers ::get_option
+ * @covers ::add_blog_option
+ * @covers ::update_blog_option
+ * @covers ::delete_blog_option
+ */
+ public function test_from_same_site_with_null_blog_id() {
+ $key = __FUNCTION__ . '_1';
+ $key2 = __FUNCTION__ . '_2';
+ $value = __FUNCTION__ . '_val1';
+ $value2 = __FUNCTION__ . '_val2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @covers ::get_blog_option
- * @covers ::get_option
- * @covers ::add_blog_option
- * @covers ::update_blog_option
- * @covers ::delete_blog_option
- */
- public function test_from_same_site_with_null_blog_id() {
- $key = __FUNCTION__ . '_1';
- $key2 = __FUNCTION__ . '_2';
- $value = __FUNCTION__ . '_val1';
- $value2 = __FUNCTION__ . '_val2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( get_blog_option( null, 'doesnotexist' ) );
+ $this->assertFalse( get_option( 'doesnotexist' ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( get_blog_option( null, 'doesnotexist' ) );
- $this->assertFalse( get_option( 'doesnotexist' ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( add_blog_option( null, $key, $value ) );
+ // Assert all values of $blog_id that means the current or main blog (the same here).
+ $this->assertSame( $value, get_blog_option( null, $key ) );
+ $this->assertSame( $value, get_blog_option( null, $key ) );
+ $this->assertSame( $value, get_option( $key ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( add_blog_option( null, $key, $value ) );
- // Assert all values of $blog_id that means the current or main blog (the same here).
- $this->assertSame( $value, get_blog_option( null, $key ) );
- $this->assertSame( $value, get_blog_option( null, $key ) );
- $this->assertSame( $value, get_option( $key ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( add_blog_option( null, $key, $value ) ); // Already exists.
+ $this->assertFalse( update_blog_option( null, $key, $value ) ); // Value is the same.
+ $this->assertTrue( update_blog_option( null, $key, $value2 ) );
+ $this->assertSame( $value2, get_blog_option( null, $key ) );
+ $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
+ $this->assertFalse( add_blog_option( null, $key, $value ) );
+ $this->assertSame( $value2, get_blog_option( null, $key ) );
+ $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( add_blog_option( null, $key, $value ) ); // Already exists.
- $this->assertFalse( update_blog_option( null, $key, $value ) ); // Value is the same.
- $this->assertTrue( update_blog_option( null, $key, $value2 ) );
- $this->assertSame( $value2, get_blog_option( null, $key ) );
- $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
- $this->assertFalse( add_blog_option( null, $key, $value ) );
- $this->assertSame( $value2, get_blog_option( null, $key ) );
- $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( delete_blog_option( null, $key ) );
+ $this->assertFalse( get_blog_option( null, $key ) );
+ $this->assertFalse( get_option( $key ) ); // Check get_option().
+ $this->assertFalse( delete_blog_option( null, $key ) );
+ $this->assertTrue( update_blog_option( null, $key2, $value2 ) );
+ $this->assertSame( $value2, get_blog_option( null, $key2 ) );
+ $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option().
+ $this->assertTrue( delete_blog_option( null, $key2 ) );
+ $this->assertFalse( get_blog_option( null, $key2 ) );
+ $this->assertFalse( get_option( $key2 ) ); // Check get_option().
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( delete_blog_option( null, $key ) );
- $this->assertFalse( get_blog_option( null, $key ) );
- $this->assertFalse( get_option( $key ) ); // Check get_option().
- $this->assertFalse( delete_blog_option( null, $key ) );
- $this->assertTrue( update_blog_option( null, $key2, $value2 ) );
- $this->assertSame( $value2, get_blog_option( null, $key2 ) );
- $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option().
- $this->assertTrue( delete_blog_option( null, $key2 ) );
- $this->assertFalse( get_blog_option( null, $key2 ) );
- $this->assertFalse( get_option( $key2 ) ); // Check get_option().
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @covers ::get_blog_option
+ * @covers ::get_option
+ * @covers ::add_blog_option
+ * @covers ::update_blog_option
+ * @covers ::delete_blog_option
+ */
+ public function test_with_another_site() {
+ $user_id = self::factory()->user->create();
+ $this->assertIsInt( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @covers ::get_blog_option
- * @covers ::get_option
- * @covers ::add_blog_option
- * @covers ::update_blog_option
- * @covers ::delete_blog_option
- */
- public function test_with_another_site() {
- $user_id = self::factory()->user->create();
- $this->assertIsInt( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create(
+ array(
+ 'user_id' => $user_id,
+ 'public' => 1,
+ )
+ );
+ $this->assertIsInt( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create(
- array(
- 'user_id' => $user_id,
- 'public' => 1,
- )
- );
- $this->assertIsInt( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key = __FUNCTION__ . '_key1';
+ $key2 = __FUNCTION__ . '_key2';
+ $value = __FUNCTION__ . '_val1';
+ $value2 = __FUNCTION__ . '_val2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key = __FUNCTION__ . '_key1';
- $key2 = __FUNCTION__ . '_key2';
- $value = __FUNCTION__ . '_val1';
- $value2 = __FUNCTION__ . '_val2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( get_blog_option( $blog_id, 'doesnotexist' ) );
+ // $this->assertFalse( get_option( 'doesnotexist' ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( get_blog_option( $blog_id, 'doesnotexist' ) );
- // $this->assertFalse( get_option( 'doesnotexist' ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( add_blog_option( $blog_id, $key, $value ) );
+ // Assert all values of $blog_id that means the current or main blog (the same here).
+ $this->assertSame( $value, get_blog_option( $blog_id, $key ) );
+ $this->assertSame( $value, get_blog_option( (string) $blog_id, $key ) );
+ // $this->assertSame( $value, get_option( $key ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( add_blog_option( $blog_id, $key, $value ) );
- // Assert all values of $blog_id that means the current or main blog (the same here).
- $this->assertSame( $value, get_blog_option( $blog_id, $key ) );
- $this->assertSame( $value, get_blog_option( (string) $blog_id, $key ) );
- // $this->assertSame( $value, get_option( $key ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); // Already exists.
+ $this->assertFalse( update_blog_option( $blog_id, $key, $value ) ); // Value is the same.
+ $this->assertTrue( update_blog_option( $blog_id, $key, $value2 ) );
+ $this->assertSame( $value2, get_blog_option( $blog_id, $key ) );
+ // $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
+ $this->assertFalse( add_blog_option( $blog_id, $key, $value ) );
+ $this->assertSame( $value2, get_blog_option( $blog_id, $key ) );
+ // $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); // Already exists.
- $this->assertFalse( update_blog_option( $blog_id, $key, $value ) ); // Value is the same.
- $this->assertTrue( update_blog_option( $blog_id, $key, $value2 ) );
- $this->assertSame( $value2, get_blog_option( $blog_id, $key ) );
- // $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
- $this->assertFalse( add_blog_option( $blog_id, $key, $value ) );
- $this->assertSame( $value2, get_blog_option( $blog_id, $key ) );
- // $this->assertSame( $value2, get_option( $key ) ); // Check get_option().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( delete_blog_option( $blog_id, $key ) );
+ $this->assertFalse( get_blog_option( $blog_id, $key ) );
+ // $this->assertFalse( get_option( $key ) ); // Check get_option().
+ $this->assertFalse( delete_blog_option( $blog_id, $key ) );
+ $this->assertTrue( update_blog_option( $blog_id, $key2, $value2 ) );
+ $this->assertSame( $value2, get_blog_option( $blog_id, $key2 ) );
+ // $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option().
+ $this->assertTrue( delete_blog_option( $blog_id, $key2 ) );
+ $this->assertFalse( get_blog_option( $blog_id, $key2 ) );
+ // $this->assertFalse( get_option( $key2 ) ); // Check get_option().
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( delete_blog_option( $blog_id, $key ) );
- $this->assertFalse( get_blog_option( $blog_id, $key ) );
- // $this->assertFalse( get_option( $key ) ); // Check get_option().
- $this->assertFalse( delete_blog_option( $blog_id, $key ) );
- $this->assertTrue( update_blog_option( $blog_id, $key2, $value2 ) );
- $this->assertSame( $value2, get_blog_option( $blog_id, $key2 ) );
- // $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option().
- $this->assertTrue( delete_blog_option( $blog_id, $key2 ) );
- $this->assertFalse( get_blog_option( $blog_id, $key2 ) );
- // $this->assertFalse( get_option( $key2 ) ); // Check get_option().
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @group multisite
+ *
+ * @covers ::get_site_option
+ */
+ public function test_site_notoptions() {
+ $network_id = get_current_network_id();
+ $notoptions_key = "{$network_id}:notoptions";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @group multisite
- *
- * @covers ::get_site_option
- */
- public function test_site_notoptions() {
- $network_id = get_current_network_id();
- $notoptions_key = "{$network_id}:notoptions";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_notoptions = wp_cache_get( 'notoptions', 'site-options' );
+ $this->assertEmpty( $_notoptions );
+ $_notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
+ $this->assertEmpty( $_notoptions1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_notoptions = wp_cache_get( 'notoptions', 'site-options' );
- $this->assertEmpty( $_notoptions );
- $_notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
- $this->assertEmpty( $_notoptions1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_site_option( 'burrito' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_site_option( 'burrito' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notoptions = wp_cache_get( 'notoptions', 'site-options' );
+ $this->assertEmpty( $notoptions );
+ $notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
+ $this->assertNotEmpty( $notoptions1 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notoptions = wp_cache_get( 'notoptions', 'site-options' );
- $this->assertEmpty( $notoptions );
- $notoptions1 = wp_cache_get( $notoptions_key, 'site-options' );
- $this->assertNotEmpty( $notoptions1 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @covers ::users_can_register_signup_filter
+ * @covers ::get_site_option
+ */
+ public function test_users_can_register_signup_filter() {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @covers ::users_can_register_signup_filter
- * @covers ::get_site_option
- */
- public function test_users_can_register_signup_filter() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ get_site_option( 'registration' );
+ $this->assertFalse( users_can_register_signup_filter() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_site_option( 'registration' );
- $this->assertFalse( users_can_register_signup_filter() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_option( 'registration', 'all' );
+ $this->assertTrue( users_can_register_signup_filter() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_option( 'registration', 'all' );
- $this->assertTrue( users_can_register_signup_filter() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_option( 'registration', 'user' );
+ $this->assertTrue( users_can_register_signup_filter() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_option( 'registration', 'user' );
- $this->assertTrue( users_can_register_signup_filter() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_site_option( 'registration', 'none' );
+ $this->assertFalse( users_can_register_signup_filter() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_site_option( 'registration', 'none' );
- $this->assertFalse( users_can_register_signup_filter() );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_illegal_names
+ *
+ * @covers ::update_site_option
+ * @covers ::get_site_option
+ */
+ public function test_sanitize_network_option_illegal_names( $option_value, $sanitized_option_value ) {
+ update_site_option( 'illegal_names', $option_value );
+ $this->assertSame( $sanitized_option_value, get_site_option( 'illegal_names' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_illegal_names
- *
- * @covers ::update_site_option
- * @covers ::get_site_option
- */
- public function test_sanitize_network_option_illegal_names( $option_value, $sanitized_option_value ) {
- update_site_option( 'illegal_names', $option_value );
- $this->assertSame( $sanitized_option_value, get_site_option( 'illegal_names' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_illegal_names() {
+ return array(
+ array( array( '', 'Woo', '' ), array( 'Woo' ) ),
+ array( 'foo bar', array( 'foo', 'bar' ) ),
+ array( array(), '' ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function data_illegal_names() {
- return array(
- array( array( '', 'Woo', '' ), array( 'Woo' ) ),
- array( 'foo bar', array( 'foo', 'bar' ) ),
- array( array(), '' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_email_domains
+ *
+ * @param $option_value
+ * @param $sanitized_option_value
+ *
+ * @covers ::update_site_option
+ * @covers ::get_site_option
+ */
+ public function test_sanitize_network_option_limited_email_domains( $option_value, $sanitized_option_value ) {
+ update_site_option( 'limited_email_domains', $option_value );
+ $this->assertSame( $sanitized_option_value, get_site_option( 'limited_email_domains' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_email_domains
- *
- * @param $option_value
- * @param $sanitized_option_value
- *
- * @covers ::update_site_option
- * @covers ::get_site_option
- */
- public function test_sanitize_network_option_limited_email_domains( $option_value, $sanitized_option_value ) {
- update_site_option( 'limited_email_domains', $option_value );
- $this->assertSame( $sanitized_option_value, get_site_option( 'limited_email_domains' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @dataProvider data_email_domains
+ *
+ * @param $option_value
+ * @param $sanitized_option_value
+ *
+ * @covers ::update_site_option
+ * @covers ::get_site_option
+ */
+ public function test_sanitize_network_option_banned_email_domains( $option_value, $sanitized_option_value ) {
+ update_site_option( 'banned_email_domains', $option_value );
+ $this->assertSame( $sanitized_option_value, get_site_option( 'banned_email_domains' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @dataProvider data_email_domains
- *
- * @param $option_value
- * @param $sanitized_option_value
- *
- * @covers ::update_site_option
- * @covers ::get_site_option
- */
- public function test_sanitize_network_option_banned_email_domains( $option_value, $sanitized_option_value ) {
- update_site_option( 'banned_email_domains', $option_value );
- $this->assertSame( $sanitized_option_value, get_site_option( 'banned_email_domains' ) );
- }
-
- public function data_email_domains() {
- return array(
- array( array( 'woo', '', 'boo.com', 'foo.net.biz..' ), array( 'woo', 'boo.com' ) ),
- array( "foo\nbar", array( 'foo', 'bar' ) ),
- array( "foo\n\nbar", array( 'foo', 'bar' ) ),
- array( "\nfoo\nbar\n", array( 'foo', 'bar' ) ),
- array( "foo\nfoo.net.biz..", array( 'foo' ) ),
- array( "foo\nfoo.net.biz..\nbar.com", array( 'foo', 'bar.com' ) ),
- array( 'foo.', array( 'foo.' ) ),
- array( '.foo', array( '.foo' ) ),
- array( 'foo^net', '' ),
- array( array(), '' ),
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_email_domains() {
+ return array(
+ array( array( 'woo', '', 'boo.com', 'foo.net.biz..' ), array( 'woo', 'boo.com' ) ),
+ array( "foo\nbar", array( 'foo', 'bar' ) ),
+ array( "foo\n\nbar", array( 'foo', 'bar' ) ),
+ array( "\nfoo\nbar\n", array( 'foo', 'bar' ) ),
+ array( "foo\nfoo.net.biz..", array( 'foo' ) ),
+ array( "foo\nfoo.net.biz..\nbar.com", array( 'foo', 'bar.com' ) ),
+ array( 'foo.', array( 'foo.' ) ),
+ array( '.foo', array( '.foo' ) ),
+ array( 'foo^net', '' ),
+ array( array(), '' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemeGetAllowedFiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,99 +1,99 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Tests specific to the filtering of `WP_Theme::get_allowed()` and related functions.
+ *
+ * @group ms-required
+ * @group multisite
+ * @group themes
+ */
+class Tests_Theme_wpThemeGetAllowedFilters extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Tests specific to the filtering of `WP_Theme::get_allowed()` and related functions.
- *
- * @group themes
- * @group multisite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array List of themes allowed before filters are applied.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- class Tests_Theme_wpThemeGetAllowedFilters extends WP_UnitTestCase {
- /**
- * @var array List of themes allowed before filters are applied.
- */
- protected $default_allowed;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $default_allowed;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $filter_network_allowed_themes_args;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $filter_network_allowed_themes_args;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_network_allowed_themes_filter_sends_blog_id() {
- $blog_id = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_network_allowed_themes_filter_sends_blog_id() {
+ $blog_id = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10, 2 );
- WP_Theme::get_allowed( $blog_id );
- remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10, 2 );
+ WP_Theme::get_allowed( $blog_id );
+ remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertCount( 2, $this->filter_network_allowed_themes_args );
- $this->assertSame( $blog_id, $this->filter_network_allowed_themes_args[1] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertCount( 2, $this->filter_network_allowed_themes_args );
+ $this->assertSame( $blog_id, $this->filter_network_allowed_themes_args[1] );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the `allowed_themes` filter, which filters themes allowed on a network.
- */
- public function test_wp_theme_get_allowed_with_allowed_themes_filter() {
- $blog_id = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the `allowed_themes` filter, which filters themes allowed on a network.
+ */
+ public function test_wp_theme_get_allowed_with_allowed_themes_filter() {
+ $blog_id = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->default_allowed = WP_Theme::get_allowed( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->default_allowed = WP_Theme::get_allowed( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'allowed_themes', array( $this, 'filter_allowed_themes' ), 10 );
- $allowed = WP_Theme::get_allowed( $blog_id );
- remove_filter( 'allowed_themes', array( $this, 'filter_allowed_themes' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'allowed_themes', array( $this, 'filter_allowed_themes' ), 10 );
+ $allowed = WP_Theme::get_allowed( $blog_id );
+ remove_filter( 'allowed_themes', array( $this, 'filter_allowed_themes' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = $this->default_allowed + array( 'allow-on-network' => true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = $this->default_allowed + array( 'allow-on-network' => true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $allowed );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $allowed );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the `network_allowed_themes` filter, which filters allowed themes on the network and provides `$blog_id`.
- */
- public function test_wp_theme_get_allowed_with_network_allowed_themes_filter() {
- $blog_id = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the `network_allowed_themes` filter, which filters allowed themes on the network and provides `$blog_id`.
+ */
+ public function test_wp_theme_get_allowed_with_network_allowed_themes_filter() {
+ $blog_id = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->default_allowed = WP_Theme::get_allowed( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->default_allowed = WP_Theme::get_allowed( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10, 2 );
- $allowed = WP_Theme::get_allowed( $blog_id );
- remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10, 2 );
+ $allowed = WP_Theme::get_allowed( $blog_id );
+ remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = $this->default_allowed + array( 'network-allowed-theme' => true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = $this->default_allowed + array( 'network-allowed-theme' => true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $allowed );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $allowed );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the `site_allowed_themes` filter, which filters allowed themes for a site and provides `$blog_id`.
- */
- public function test_wp_theme_get_allowed_with_site_allowed_themes_filter() {
- $blog_id = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the `site_allowed_themes` filter, which filters allowed themes for a site and provides `$blog_id`.
+ */
+ public function test_wp_theme_get_allowed_with_site_allowed_themes_filter() {
+ $blog_id = 1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->default_allowed = WP_Theme::get_allowed( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->default_allowed = WP_Theme::get_allowed( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'site_allowed_themes', array( $this, 'filter_site_allowed_themes' ), 10, 2 );
- $allowed = WP_Theme::get_allowed( $blog_id );
- remove_filter( 'site_allowed_themes', array( $this, 'filter_site_allowed_themes' ), 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'site_allowed_themes', array( $this, 'filter_site_allowed_themes' ), 10, 2 );
+ $allowed = WP_Theme::get_allowed( $blog_id );
+ remove_filter( 'site_allowed_themes', array( $this, 'filter_site_allowed_themes' ), 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = $this->default_allowed + array( 'site-allowed-theme' => true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = $this->default_allowed + array( 'site-allowed-theme' => true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $allowed );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $expected, $allowed );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_allowed_themes( $allowed_themes ) {
- $allowed_themes['allow-on-network'] = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_allowed_themes( $allowed_themes ) {
+ $allowed_themes['allow-on-network'] = true;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $allowed_themes;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $allowed_themes;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_network_allowed_themes( $allowed_themes, $blog_id ) {
- $this->filter_network_allowed_themes_args = func_get_args();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_network_allowed_themes( $allowed_themes, $blog_id ) {
+ $this->filter_network_allowed_themes_args = func_get_args();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $allowed_themes['network-allowed-theme'] = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $allowed_themes['network-allowed-theme'] = true;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $allowed_themes;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $allowed_themes;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function filter_site_allowed_themes( $allowed_themes, $blog_id ) {
- $allowed_themes['site-allowed-theme'] = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_site_allowed_themes( $allowed_themes, $blog_id ) {
+ $allowed_themes['site-allowed-theme'] = true;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $allowed_themes;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $allowed_themes;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsusergetActiveBlogForUserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/getActiveBlogForUser.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/getActiveBlogForUser.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/user/getActiveBlogForUser.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,101 +1,99 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to users in multisite.
+ *
+ * @group user
+ * @group ms-required
+ * @group ms-user
+ * @group multisite
+ */
+class Tests_User_GetActiveBlogForUser extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to users in multisite.
- *
- * @group user
- * @group ms-user
- * @group multisite
- */
- class Tests_User_GetActiveBlogForUser extends WP_UnitTestCase {
- public static $user_id = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static $user_id = false;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
- self::$user_id = $factory->user->create();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id = $factory->user->create();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function wpTearDownAfterClass() {
- wpmu_delete_user( self::$user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ wpmu_delete_user( self::$user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wp_rewrite;
- $wp_rewrite->init();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wp_rewrite;
+ $wp_rewrite->init();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38355
- */
- public function test_get_active_blog_for_user_with_no_sites() {
- $current_site_id = get_current_blog_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38355
+ */
+ public function test_get_active_blog_for_user_with_no_sites() {
+ $current_site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_user_from_blog( self::$user_id, $current_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_user_from_blog( self::$user_id, $current_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_active_blog_for_user( self::$user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_active_blog_for_user( self::$user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNull( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38355
- */
- public function test_get_active_blog_for_user_with_primary_site() {
- $site_id_one = self::factory()->blog->create( array( 'user_id' => self::$user_id ) );
- $site_id_two = self::factory()->blog->create( array( 'user_id' => self::$user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38355
+ */
+ public function test_get_active_blog_for_user_with_primary_site() {
+ $site_id_one = self::factory()->blog->create( array( 'user_id' => self::$user_id ) );
+ $site_id_two = self::factory()->blog->create( array( 'user_id' => self::$user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sites = get_blogs_of_user( self::$user_id );
- $site_ids = array_keys( $sites );
- $primary_site_id = $site_ids[1];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sites = get_blogs_of_user( self::$user_id );
+ $site_ids = array_keys( $sites );
+ $primary_site_id = $site_ids[1];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( self::$user_id, 'primary_blog', $primary_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( self::$user_id, 'primary_blog', $primary_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_active_blog_for_user( self::$user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_active_blog_for_user( self::$user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $site_id_one );
- wp_delete_site( $site_id_two );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $site_id_one );
+ wp_delete_site( $site_id_two );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $primary_site_id, $result->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $primary_site_id, $result->id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38355
- */
- public function test_get_active_blog_for_user_without_primary_site() {
- $sites = get_blogs_of_user( self::$user_id );
- $site_ids = array_keys( $sites );
- $primary_site_id = $site_ids[0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38355
+ */
+ public function test_get_active_blog_for_user_without_primary_site() {
+ $sites = get_blogs_of_user( self::$user_id );
+ $site_ids = array_keys( $sites );
+ $primary_site_id = $site_ids[0];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_user_meta( self::$user_id, 'primary_blog' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_user_meta( self::$user_id, 'primary_blog' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_active_blog_for_user( self::$user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_active_blog_for_user( self::$user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $primary_site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $primary_site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $primary_site_id, $result->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $primary_site_id, $result->id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38355
- */
- public function test_get_active_blog_for_user_with_spam_site() {
- $current_site_id = get_current_blog_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38355
+ */
+ public function test_get_active_blog_for_user_with_spam_site() {
+ $current_site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_id = self::factory()->blog->create(
- array(
- 'user_id' => self::$user_id,
- 'spam' => 1,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = self::factory()->blog->create(
+ array(
+ 'user_id' => self::$user_id,
+ 'spam' => 1,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_user_to_blog( $site_id, self::$user_id, 'subscriber' );
- update_user_meta( self::$user_id, 'primary_blog', $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_user_to_blog( $site_id, self::$user_id, 'subscriber' );
+ update_user_meta( self::$user_id, 'primary_blog', $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = get_active_blog_for_user( self::$user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = get_active_blog_for_user( self::$user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $current_site_id, $result->id );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $current_site_id, $result->id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsusermultisitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/multisite.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/multisite.php 2025-04-08 18:02:14 UTC (rev 60147)
+++ trunk/tests/phpunit/tests/user/multisite.php 2025-04-09 13:29:39 UTC (rev 60148)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,453 +1,450 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( is_multisite() ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Tests specific to users in multisite.
+ *
+ * @group user
+ * @group ms-required
+ * @group ms-user
+ * @group multisite
+ */
+class Tests_User_Multisite extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Tests specific to users in multisite.
- *
- * @group user
- * @group ms-user
- * @group multisite
- */
- class Tests_User_Multisite extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_remove_user_from_blog() {
+ $user1 = self::factory()->user->create_and_get();
+ $user2 = self::factory()->user->create_and_get();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_remove_user_from_blog() {
- $user1 = self::factory()->user->create_and_get();
- $user2 = self::factory()->user->create_and_get();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = self::factory()->post->create( array( 'post_author' => $user1->ID ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_author' => $user1->ID ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_user_from_blog( $user1->ID, 1, $user2->ID );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_user_from_blog( $user1->ID, 1, $user2->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( $user1->ID, $post->post_author );
+ $this->assertEquals( $user2->ID, $post->post_author );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $user1->ID, $post->post_author );
- $this->assertEquals( $user2->ID, $post->post_author );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Test the returned data from get_blogs_of_user()
+ */
+ public function test_get_blogs_of_user() {
+ $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Test the returned data from get_blogs_of_user()
- */
- public function test_get_blogs_of_user() {
- $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Maintain a list of 6 total sites and include the primary network site.
+ $blog_ids = self::factory()->blog->create_many( 5, array( 'user_id' => $user1_id ) );
+ $blog_ids = array_merge( array( 1 ), $blog_ids );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Maintain a list of 6 total sites and include the primary network site.
- $blog_ids = self::factory()->blog->create_many( 5, array( 'user_id' => $user1_id ) );
- $blog_ids = array_merge( array( 1 ), $blog_ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // All sites are new and not marked as spam, archived, or deleted.
+ $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // All sites are new and not marked as spam, archived, or deleted.
- $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // User should be a member of the created sites and the network's initial site.
+ $this->assertSame( $blog_ids, $blog_ids_of_user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // User should be a member of the created sites and the network's initial site.
- $this->assertSame( $blog_ids, $blog_ids_of_user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[0] ) );
+ $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[2] ) );
+ $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[4] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[0] ) );
- $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[2] ) );
- $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[4] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $blog_ids[0] );
+ unset( $blog_ids[2] );
+ unset( $blog_ids[4] );
+ sort( $blog_ids );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $blog_ids[0] );
- unset( $blog_ids[2] );
- unset( $blog_ids[4] );
- sort( $blog_ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blogs_of_user = get_blogs_of_user( $user1_id, false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blogs_of_user = get_blogs_of_user( $user1_id, false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The user should still be a member of all remaining sites.
+ $blog_ids_of_user = array_keys( $blogs_of_user );
+ $this->assertSame( $blog_ids, $blog_ids_of_user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The user should still be a member of all remaining sites.
- $blog_ids_of_user = array_keys( $blogs_of_user );
- $this->assertSame( $blog_ids, $blog_ids_of_user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Each site retrieved should match the expected structure.
+ foreach ( $blogs_of_user as $blog_id => $blog ) {
+ $this->assertSame( $blog_id, $blog->userblog_id );
+ $this->assertObjectHasProperty( 'userblog_id', $blog );
+ $this->assertObjectHasProperty( 'blogname', $blog );
+ $this->assertObjectHasProperty( 'domain', $blog );
+ $this->assertObjectHasProperty( 'path', $blog );
+ $this->assertObjectHasProperty( 'site_id', $blog );
+ $this->assertObjectHasProperty( 'siteurl', $blog );
+ $this->assertObjectHasProperty( 'archived', $blog );
+ $this->assertObjectHasProperty( 'spam', $blog );
+ $this->assertObjectHasProperty( 'deleted', $blog );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Each site retrieved should match the expected structure.
- foreach ( $blogs_of_user as $blog_id => $blog ) {
- $this->assertSame( $blog_id, $blog->userblog_id );
- $this->assertObjectHasProperty( 'userblog_id', $blog );
- $this->assertObjectHasProperty( 'blogname', $blog );
- $this->assertObjectHasProperty( 'domain', $blog );
- $this->assertObjectHasProperty( 'path', $blog );
- $this->assertObjectHasProperty( 'site_id', $blog );
- $this->assertObjectHasProperty( 'siteurl', $blog );
- $this->assertObjectHasProperty( 'archived', $blog );
- $this->assertObjectHasProperty( 'spam', $blog );
- $this->assertObjectHasProperty( 'deleted', $blog );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Mark each remaining site as spam, archived, and deleted.
+ update_blog_details( $blog_ids[0], array( 'spam' => 1 ) );
+ update_blog_details( $blog_ids[1], array( 'archived' => 1 ) );
+ update_blog_details( $blog_ids[2], array( 'deleted' => 1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Mark each remaining site as spam, archived, and deleted.
- update_blog_details( $blog_ids[0], array( 'spam' => 1 ) );
- update_blog_details( $blog_ids[1], array( 'archived' => 1 ) );
- update_blog_details( $blog_ids[2], array( 'deleted' => 1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Passing true as the second parameter should retrieve ALL sites, even if marked.
+ $blogs_of_user = get_blogs_of_user( $user1_id, true );
+ $blog_ids_of_user = array_keys( $blogs_of_user );
+ $this->assertSame( $blog_ids, $blog_ids_of_user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Passing true as the second parameter should retrieve ALL sites, even if marked.
- $blogs_of_user = get_blogs_of_user( $user1_id, true );
- $blog_ids_of_user = array_keys( $blogs_of_user );
- $this->assertSame( $blog_ids, $blog_ids_of_user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check if sites are flagged as expected.
+ $this->assertEquals( 1, $blogs_of_user[ $blog_ids[0] ]->spam );
+ $this->assertEquals( 1, $blogs_of_user[ $blog_ids[1] ]->archived );
+ $this->assertEquals( 1, $blogs_of_user[ $blog_ids[2] ]->deleted );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check if sites are flagged as expected.
- $this->assertEquals( 1, $blogs_of_user[ $blog_ids[0] ]->spam );
- $this->assertEquals( 1, $blogs_of_user[ $blog_ids[1] ]->archived );
- $this->assertEquals( 1, $blogs_of_user[ $blog_ids[2] ]->deleted );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $blog_ids[0] );
+ unset( $blog_ids[1] );
+ unset( $blog_ids[2] );
+ sort( $blog_ids );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $blog_ids[0] );
- unset( $blog_ids[1] );
- unset( $blog_ids[2] );
- sort( $blog_ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Passing false (the default) as the second parameter should retrieve only good sites.
+ $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id, false ) );
+ $this->assertSame( $blog_ids, $blog_ids_of_user );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Passing false (the default) as the second parameter should retrieve only good sites.
- $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id, false ) );
- $this->assertSame( $blog_ids, $blog_ids_of_user );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @expectedDeprecated is_blog_user
+ */
+ public function test_is_blog_user() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @expectedDeprecated is_blog_user
- */
- public function test_is_blog_user() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $old_current = get_current_user_id();
+ wp_set_current_user( $user1_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $old_current = get_current_user_id();
- wp_set_current_user( $user1_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_blog_user() );
+ $this->assertTrue( is_blog_user( get_current_blog_id() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_blog_user() );
- $this->assertTrue( is_blog_user( get_current_blog_id() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( $blog_id );
+ $this->assertTrue( is_blog_user( $blog_id ) );
+ $this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
+ $this->assertFalse( is_blog_user( $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsInt( $blog_id );
- $this->assertTrue( is_blog_user( $blog_id ) );
- $this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
- $this->assertFalse( is_blog_user( $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( $old_current );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $old_current );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_is_user_member_of_blog() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_is_user_member_of_blog() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ $user2_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
- $user2_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $old_current = get_current_user_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $old_current = get_current_user_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 0, $old_current );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 0, $old_current );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Test for "get current user" when not logged in.
+ $this->assertFalse( is_user_member_of_blog() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Test for "get current user" when not logged in.
- $this->assertFalse( is_user_member_of_blog() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( $user1_id );
+ $site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $user1_id );
- $site_id = get_current_blog_id();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_user_member_of_blog() );
+ $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
+ $this->assertTrue( is_user_member_of_blog( 0, $site_id ) );
+ $this->assertTrue( is_user_member_of_blog( $user1_id ) );
+ $this->assertTrue( is_user_member_of_blog( $user1_id, $site_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_user_member_of_blog() );
- $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
- $this->assertTrue( is_user_member_of_blog( 0, $site_id ) );
- $this->assertTrue( is_user_member_of_blog( $user1_id ) );
- $this->assertTrue( is_user_member_of_blog( $user1_id, $site_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsInt( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Current user gets added to new blogs.
+ $this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
+ // Other users should not.
+ $this->assertFalse( is_user_member_of_blog( $user2_id, $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Current user gets added to new blogs.
- $this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
- // Other users should not.
- $this->assertFalse( is_user_member_of_blog( $user2_id, $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_user_member_of_blog( $user1_id ) );
+ $this->assertFalse( is_user_member_of_blog( $user2_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_user_member_of_blog( $user1_id ) );
- $this->assertFalse( is_user_member_of_blog( $user2_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Remove user 1 from blog.
+ $this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Remove user 1 from blog.
- $this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add user 2 to blog.
+ $this->assertTrue( add_user_to_blog( $blog_id, $user2_id, 'subscriber' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Add user 2 to blog.
- $this->assertTrue( add_user_to_blog( $blog_id, $user2_id, 'subscriber' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( is_user_member_of_blog( $user1_id ) );
+ $this->assertTrue( is_user_member_of_blog( $user2_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( is_user_member_of_blog( $user1_id ) );
- $this->assertTrue( is_user_member_of_blog( $user2_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
+ $this->assertTrue( is_user_member_of_blog( $user2_id, $blog_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
- $this->assertTrue( is_user_member_of_blog( $user2_id, $blog_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_user( $user1_id );
+ $user = new WP_User( $user1_id );
+ $this->assertFalse( $user->exists() );
+ $this->assertFalse( is_user_member_of_blog( $user1_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_user( $user1_id );
- $user = new WP_User( $user1_id );
- $this->assertFalse( $user->exists() );
- $this->assertFalse( is_user_member_of_blog( $user1_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( $old_current );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $old_current );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 23192
+ */
+ public function test_is_user_spammy() {
+ $user_id = self::factory()->user->create(
+ array(
+ 'role' => 'author',
+ 'user_login' => 'testuser1',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 23192
- */
- public function test_is_user_spammy() {
- $user_id = self::factory()->user->create(
- array(
- 'role' => 'author',
- 'user_login' => 'testuser1',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $spam_username = (string) $user_id;
+ $spam_user_id = self::factory()->user->create(
+ array(
+ 'role' => 'author',
+ 'user_login' => $spam_username,
+ )
+ );
+ wp_update_user(
+ array(
+ 'ID' => $spam_user_id,
+ 'spam' => '1',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $spam_username = (string) $user_id;
- $spam_user_id = self::factory()->user->create(
- array(
- 'role' => 'author',
- 'user_login' => $spam_username,
- )
- );
- wp_update_user(
- array(
- 'ID' => $spam_user_id,
- 'spam' => '1',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_user_spammy( $spam_username ) );
+ $this->assertFalse( is_user_spammy( 'testuser1' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_user_spammy( $spam_username ) );
- $this->assertFalse( is_user_spammy( 'testuser1' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 20601
+ */
+ public function test_user_member_of_blog() {
+ global $wp_rewrite;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 20601
- */
- public function test_user_member_of_blog() {
- global $wp_rewrite;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::factory()->blog->create();
+ $user_id = self::factory()->user->create();
+ self::factory()->blog->create( array( 'user_id' => $user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::factory()->blog->create();
- $user_id = self::factory()->user->create();
- self::factory()->blog->create( array( 'user_id' => $user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blogs = get_blogs_of_user( $user_id );
+ $this->assertCount( 2, $blogs );
+ $first = reset( $blogs )->userblog_id;
+ remove_user_from_blog( $user_id, $first );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blogs = get_blogs_of_user( $user_id );
- $this->assertCount( 2, $blogs );
- $first = reset( $blogs )->userblog_id;
- remove_user_from_blog( $user_id, $first );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blogs = get_blogs_of_user( $user_id );
+ $second = reset( $blogs )->userblog_id;
+ $this->assertCount( 1, $blogs );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blogs = get_blogs_of_user( $user_id );
- $second = reset( $blogs )->userblog_id;
- $this->assertCount( 1, $blogs );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $first );
+ $wp_rewrite->init();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $first );
- $wp_rewrite->init();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->go_to( get_author_posts_url( $user_id ) );
+ $this->assertQueryTrue( 'is_404' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->go_to( get_author_posts_url( $user_id ) );
- $this->assertQueryTrue( 'is_404' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $second );
+ $wp_rewrite->init();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $second );
- $wp_rewrite->init();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->go_to( get_author_posts_url( $user_id ) );
+ $this->assertQueryTrue( 'is_author', 'is_archive' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->go_to( get_author_posts_url( $user_id ) );
- $this->assertQueryTrue( 'is_author', 'is_archive' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_user_to_blog( $first, $user_id, 'administrator' );
+ $blogs = get_blogs_of_user( $user_id );
+ $this->assertCount( 2, $blogs );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_user_to_blog( $first, $user_id, 'administrator' );
- $blogs = get_blogs_of_user( $user_id );
- $this->assertCount( 2, $blogs );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $first );
+ $wp_rewrite->init();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $first );
- $wp_rewrite->init();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->go_to( get_author_posts_url( $user_id ) );
+ $this->assertQueryTrue( 'is_author', 'is_archive' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->go_to( get_author_posts_url( $user_id ) );
- $this->assertQueryTrue( 'is_author', 'is_archive' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_revoked_super_admin_can_be_deleted() {
+ if ( isset( $GLOBALS['super_admins'] ) ) {
+ $old_global = $GLOBALS['super_admins'];
+ unset( $GLOBALS['super_admins'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_revoked_super_admin_can_be_deleted() {
- if ( isset( $GLOBALS['super_admins'] ) ) {
- $old_global = $GLOBALS['super_admins'];
- unset( $GLOBALS['super_admins'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create();
+ grant_super_admin( $user_id );
+ revoke_super_admin( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create();
- grant_super_admin( $user_id );
- revoke_super_admin( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( wpmu_delete_user( $user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( wpmu_delete_user( $user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $old_global ) ) {
+ $GLOBALS['super_admins'] = $old_global;
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $old_global ) ) {
- $GLOBALS['super_admins'] = $old_global;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_revoked_super_admin_is_deleted() {
+ if ( isset( $GLOBALS['super_admins'] ) ) {
+ $old_global = $GLOBALS['super_admins'];
+ unset( $GLOBALS['super_admins'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_revoked_super_admin_is_deleted() {
- if ( isset( $GLOBALS['super_admins'] ) ) {
- $old_global = $GLOBALS['super_admins'];
- unset( $GLOBALS['super_admins'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create();
+ grant_super_admin( $user_id );
+ revoke_super_admin( $user_id );
+ wpmu_delete_user( $user_id );
+ $user = new WP_User( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create();
- grant_super_admin( $user_id );
- revoke_super_admin( $user_id );
- wpmu_delete_user( $user_id );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $user->exists(), 'WP_User->exists' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $user->exists(), 'WP_User->exists' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $old_global ) ) {
+ $GLOBALS['super_admins'] = $old_global;
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $old_global ) ) {
- $GLOBALS['super_admins'] = $old_global;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_super_admin_cannot_be_deleted() {
+ if ( isset( $GLOBALS['super_admins'] ) ) {
+ $old_global = $GLOBALS['super_admins'];
+ unset( $GLOBALS['super_admins'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_super_admin_cannot_be_deleted() {
- if ( isset( $GLOBALS['super_admins'] ) ) {
- $old_global = $GLOBALS['super_admins'];
- unset( $GLOBALS['super_admins'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create();
+ grant_super_admin( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create();
- grant_super_admin( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( wpmu_delete_user( $user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( wpmu_delete_user( $user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $old_global ) ) {
+ $GLOBALS['super_admins'] = $old_global;
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $old_global ) ) {
- $GLOBALS['super_admins'] = $old_global;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 27205
+ */
+ public function test_granting_super_admins() {
+ if ( isset( $GLOBALS['super_admins'] ) ) {
+ $old_global = $GLOBALS['super_admins'];
+ unset( $GLOBALS['super_admins'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 27205
- */
- public function test_granting_super_admins() {
- if ( isset( $GLOBALS['super_admins'] ) ) {
- $old_global = $GLOBALS['super_admins'];
- unset( $GLOBALS['super_admins'] );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( is_super_admin( $user_id ) );
+ $this->assertFalse( revoke_super_admin( $user_id ) );
+ $this->assertTrue( grant_super_admin( $user_id ) );
+ $this->assertTrue( is_super_admin( $user_id ) );
+ $this->assertFalse( grant_super_admin( $user_id ) );
+ $this->assertTrue( revoke_super_admin( $user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( is_super_admin( $user_id ) );
- $this->assertFalse( revoke_super_admin( $user_id ) );
- $this->assertTrue( grant_super_admin( $user_id ) );
- $this->assertTrue( is_super_admin( $user_id ) );
- $this->assertFalse( grant_super_admin( $user_id ) );
- $this->assertTrue( revoke_super_admin( $user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // None of these operations should set the $super_admins global.
+ $this->assertFalse( isset( $GLOBALS['super_admins'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // None of these operations should set the $super_admins global.
- $this->assertFalse( isset( $GLOBALS['super_admins'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Try with two users.
+ $second_user = self::factory()->user->create();
+ $this->assertTrue( grant_super_admin( $user_id ) );
+ $this->assertTrue( grant_super_admin( $second_user ) );
+ $this->assertTrue( is_super_admin( $second_user ) );
+ $this->assertTrue( is_super_admin( $user_id ) );
+ $this->assertTrue( revoke_super_admin( $user_id ) );
+ $this->assertTrue( revoke_super_admin( $second_user ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Try with two users.
- $second_user = self::factory()->user->create();
- $this->assertTrue( grant_super_admin( $user_id ) );
- $this->assertTrue( grant_super_admin( $second_user ) );
- $this->assertTrue( is_super_admin( $second_user ) );
- $this->assertTrue( is_super_admin( $user_id ) );
- $this->assertTrue( revoke_super_admin( $user_id ) );
- $this->assertTrue( revoke_super_admin( $second_user ) );
-
- if ( isset( $old_global ) ) {
- $GLOBALS['super_admins'] = $old_global;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $old_global ) ) {
+ $GLOBALS['super_admins'] = $old_global;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_numeric_string_user_id() {
- $u = self::factory()->user->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_numeric_string_user_id() {
+ $u = self::factory()->user->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $u_string = (string) $u;
- $this->assertTrue( wpmu_delete_user( $u_string ) );
- $this->assertFalse( get_user_by( 'id', $u ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $u_string = (string) $u;
+ $this->assertTrue( wpmu_delete_user( $u_string ) );
+ $this->assertFalse( get_user_by( 'id', $u ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 33800
- */
- public function test_should_return_false_for_non_numeric_string_user_id() {
- $this->assertFalse( wpmu_delete_user( 'abcde' ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 33800
+ */
+ public function test_should_return_false_for_non_numeric_string_user_id() {
+ $this->assertFalse( wpmu_delete_user( 'abcde' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 33800
- */
- public function test_should_return_false_for_object_user_id() {
- $u_obj = self::factory()->user->create_and_get();
- $this->assertFalse( wpmu_delete_user( $u_obj ) );
- $this->assertSame( $u_obj->ID, username_exists( $u_obj->user_login ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 33800
+ */
+ public function test_should_return_false_for_object_user_id() {
+ $u_obj = self::factory()->user->create_and_get();
+ $this->assertFalse( wpmu_delete_user( $u_obj ) );
+ $this->assertSame( $u_obj->ID, username_exists( $u_obj->user_login ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38356
- */
- public function test_add_user_to_blog_subscriber() {
- $site_id = self::factory()->blog->create();
- $user_id = self::factory()->user->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38356
+ */
+ public function test_add_user_to_blog_subscriber() {
+ $site_id = self::factory()->blog->create();
+ $user_id = self::factory()->user->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_user_to_blog( $site_id, $user_id, 'subscriber' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_user_to_blog( $site_id, $user_id, 'subscriber' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $site_id );
- $user = get_user_by( 'id', $user_id );
- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $site_id );
+ $user = get_user_by( 'id', $user_id );
+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $site_id );
- wpmu_delete_user( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $site_id );
+ wpmu_delete_user( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertContains( 'subscriber', $user->roles );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertContains( 'subscriber', $user->roles );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 38356
- */
- public function test_add_user_to_blog_invalid_user() {
- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 38356
+ */
+ public function test_add_user_to_blog_invalid_user() {
+ global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $suppress = $wpdb->suppress_errors();
- $result = add_user_to_blog( 73622, $site_id, 'subscriber' );
- $wpdb->suppress_errors( $suppress );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $suppress = $wpdb->suppress_errors();
+ $result = add_user_to_blog( 73622, $site_id, 'subscriber' );
+ $wpdb->suppress_errors( $suppress );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_site( $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_site( $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertWPError( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertWPError( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41101
- */
- public function test_should_fail_can_add_user_to_blog_filter() {
- $site_id = self::factory()->blog->create();
- $user_id = self::factory()->user->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41101
+ */
+ public function test_should_fail_can_add_user_to_blog_filter() {
+ $site_id = self::factory()->blog->create();
+ $user_id = self::factory()->user->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'can_add_user_to_blog', '__return_false' );
- $result = add_user_to_blog( $site_id, $user_id, 'subscriber' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'can_add_user_to_blog', '__return_false' );
+ $result = add_user_to_blog( $site_id, $user_id, 'subscriber' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertWPError( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertWPError( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 41101
- */
- public function test_should_succeed_can_add_user_to_blog_filter() {
- $site_id = self::factory()->blog->create();
- $user_id = self::factory()->user->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 41101
+ */
+ public function test_should_succeed_can_add_user_to_blog_filter() {
+ $site_id = self::factory()->blog->create();
+ $user_id = self::factory()->user->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'can_add_user_to_blog', '__return_true' );
- $result = add_user_to_blog( $site_id, $user_id, 'subscriber' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'can_add_user_to_blog', '__return_true' );
+ $result = add_user_to_blog( $site_id, $user_id, 'subscriber' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $result );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $result );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * @ticket 23016
- */
- public function test_wp_roles_global_is_reset() {
- global $wp_roles;
- $role = 'test_global_is_reset';
- $role_name = 'Test Global Is Reset';
- $blog_id = self::factory()->blog->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 23016
+ */
+ public function test_wp_roles_global_is_reset() {
+ global $wp_roles;
+ $role = 'test_global_is_reset';
+ $role_name = 'Test Global Is Reset';
+ $blog_id = self::factory()->blog->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_roles->add_role( $role, $role_name, array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_roles->add_role( $role, $role_name, array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( $wp_roles->get_role( $role ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( $wp_roles->get_role( $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch_to_blog( $blog_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch_to_blog( $blog_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( $wp_roles->get_role( $role ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( $wp_roles->get_role( $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_roles->add_role( $role, $role_name, array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_roles->add_role( $role, $role_name, array() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( $wp_roles->get_role( $role ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( $wp_roles->get_role( $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- restore_current_blog();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ restore_current_blog();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEmpty( $wp_roles->get_role( $role ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEmpty( $wp_roles->get_role( $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_roles->remove_role( $role );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_roles->remove_role( $role );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre>
</div>
</div>
</body>
</html>