<!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>[51860] trunk/tests/phpunit/tests/multisite: Tests: Rename classes in `phpunit/tests/multisite/` per the naming conventions.</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/51860">51860</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/51860","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>2021-09-24 00:45:43 +0000 (Fri, 24 Sep 2021)</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: Rename classes in `phpunit/tests/multisite/` per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization
Follow-up to <a href="https://core.trac.wordpress.org/changeset/47780">[47780]</a>, <a href="https://core.trac.wordpress.org/changeset/48911">[48911]</a>, <a href="https://core.trac.wordpress.org/changeset/49327">[49327]</a>, <a href="https://core.trac.wordpress.org/changeset/50291">[50291]</a>, <a href="https://core.trac.wordpress.org/changeset/50292">[50292]</a>, <a href="https://core.trac.wordpress.org/changeset/50342">[50342]</a>, <a href="https://core.trac.wordpress.org/changeset/50452">[50452]</a>, <a href="https://core.trac.wordpress.org/changeset/50453">[50453]</a>, <a href="https://core.trac.wordpress.org/changeset/50456">[50456]</a>, <a href="https://core.trac.wordpress.org/changeset/50967">[50967]</a>, <a href="https://core.trac.wordpress.org/changeset/50968">[50968]</a>, <a href="https://core.trac.wordpress.org/changeset/50969">[50969]</a>, <a href="https://core.trac.wordpress.org/changeset/51491">[51491]</a>, <a href="https://core.trac.wordpress.org/changeset/51492">[514
92]</a>, <a href="https://core.trac.wordpress.org/changeset/51493">[51493]</a>, <a href="https://core.trac.wordpress.org/changeset/51623">[51623]</a>, <a href="https://core.trac.wordpress.org/changeset/51639">[51639]</a>, <a href="https://core.trac.wordpress.org/changeset/51646">[51646]</a>, <a href="https://core.trac.wordpress.org/changeset/51650">[51650]</a>, <a href="https://core.trac.wordpress.org/changeset/51651">[51651]</a>.
See <a href="https://core.trac.wordpress.org/ticket/53363">#53363</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsmultisitecleanDirsizeCachephp">trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.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="#trunktestsphpunittestsmultisiteisUploadSpaceAvailablephp">trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.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="#trunktestsphpunittestsmultisiteuploadIsUserOverQuotaphp">trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.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="#trunktestsphpunittestsmultisitewpmuValidateBlogSignupphp">trunk/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpmuValidateUserSignupphp">trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsmultisitemsFilesRewritingphp">trunk/tests/phpunit/tests/multisite/msFilesRewriting.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpMsSitesListTablephp">trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.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>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsmultisitemsfilesrewritingphp">trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitenetworkQueryphp">trunk/tests/phpunit/tests/multisite/networkQuery.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesiteQueryphp">trunk/tests/phpunit/tests/multisite/siteQuery.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitewpMSSitesListTablephp">trunk/tests/phpunit/tests/multisite/wpMSSitesListTable.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,7 +8,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 19879
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Dirsize_Cache extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_CleanDirsizeCache extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $suppress = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function set_up() {
</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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/getBlogDetails.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Get_Blog_Details extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_GetBlogDetails extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $network_ids;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $site_ids;
</span><span class="cx" style="display: block; padding: 0 10px">
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/getIdFromBlogname.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,7 +8,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Get_Id_From_Blogname extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_GetIdFromBlogname extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $network_ids;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $site_ids;
</span><span class="cx" style="display: block; padding: 0 10px">
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/getMainSiteId.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,7 +8,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Get_Main_Site_ID extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_GetMainSiteId extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $network_ids;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $site_ids;
</span><span class="cx" style="display: block; padding: 0 10px">
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/getSite.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Get_Site extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_GetSite extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $site_ids;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Get_Space_Allowed extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_GetSpaceAllowed extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $suppress = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_up() {
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/getSpaceUsed.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,7 +6,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_space_used
</span><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_Get_Space_Used extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_GetSpaceUsed extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $suppress = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function set_up() {
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,7 +10,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Is_Upload_Space_Available extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_IsUploadSpaceAvailable extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $suppress = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_up() {
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitemsfilesrewritingphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,90 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-if ( is_multisite() ) :
-
- /**
- * 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_MS_Files_Rewriting extends WP_UnitTestCase {
- protected $suppress = false;
-
- function set_up() {
- global $wpdb;
- parent::set_up();
- $this->suppress = $wpdb->suppress_errors();
-
- update_site_option( 'ms_files_rewriting', 1 );
- ms_upload_constants();
- }
-
- function tear_down() {
- global $wpdb;
-
- $wpdb->suppress_errors( $this->suppress );
-
- parent::tear_down();
- }
-
- function test_switch_upload_dir() {
- $this->assertTrue( is_main_site() );
-
- $site = get_current_site();
- $date = date_format( date_create( 'now' ), 'Y/m' );
-
- $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'] );
-
- 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();
- }
-
- /**
- * 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.
- */
- function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
- $filename = __FUNCTION__ . '.jpg';
- $contents = __FUNCTION__ . '_contents';
-
- // Upload a file to the main site on the network.
- $file1 = wp_upload_bits( $filename, null, $contents );
-
- $blog_id = self::factory()->blog->create();
-
- switch_to_blog( $blog_id );
- $file2 = wp_upload_bits( $filename, null, $contents );
- restore_current_blog();
-
- wpmu_delete_blog( $blog_id, true );
-
- // 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'] );
-
- wpmu_delete_blog( $blog_id, true );
-
- // 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'] );
- }
- }
-
-endif;
</del></span></pre></div>
<a id="trunktestsphpunittestsmultisitemsFilesRewritingphpfromrev51859trunktestsphpunittestsmultisitemsfilesrewritingphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/multisite/msFilesRewriting.php (from rev 51859, trunk/tests/phpunit/tests/multisite/ms-files-rewriting.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/msFilesRewriting.php (rev 0)
+++ trunk/tests/phpunit/tests/multisite/msFilesRewriting.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,90 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+if ( is_multisite() ) :
+
+ /**
+ * 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 {
+ protected $suppress = false;
+
+ function set_up() {
+ global $wpdb;
+ parent::set_up();
+ $this->suppress = $wpdb->suppress_errors();
+
+ update_site_option( 'ms_files_rewriting', 1 );
+ ms_upload_constants();
+ }
+
+ function tear_down() {
+ global $wpdb;
+
+ $wpdb->suppress_errors( $this->suppress );
+
+ parent::tear_down();
+ }
+
+ function test_switch_upload_dir() {
+ $this->assertTrue( is_main_site() );
+
+ $site = get_current_site();
+ $date = date_format( date_create( 'now' ), 'Y/m' );
+
+ $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'] );
+
+ 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();
+ }
+
+ /**
+ * 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.
+ */
+ function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
+ $filename = __FUNCTION__ . '.jpg';
+ $contents = __FUNCTION__ . '_contents';
+
+ // Upload a file to the main site on the network.
+ $file1 = wp_upload_bits( $filename, null, $contents );
+
+ $blog_id = self::factory()->blog->create();
+
+ switch_to_blog( $blog_id );
+ $file2 = wp_upload_bits( $filename, null, $contents );
+ restore_current_blog();
+
+ wpmu_delete_blog( $blog_id, true );
+
+ // 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'] );
+
+ wpmu_delete_blog( $blog_id, true );
+
+ // 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'] );
+ }
+ }
+
+endif;
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitenetworkQueryphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/multisite/networkQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/networkQuery.php 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/networkQuery.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,581 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-if ( is_multisite() ) :
-
- /**
- * Test network query functionality in multisite.
- *
- * @group ms-network
- * @group ms-network-query
- * @group multisite
- */
- class Tests_Multisite_Network_Query extends WP_UnitTestCase {
- protected static $network_ids;
-
- protected $suppress = false;
-
- function set_up() {
- global $wpdb;
- parent::set_up();
- $this->suppress = $wpdb->suppress_errors();
- }
-
- function tear_down() {
- global $wpdb;
- $wpdb->suppress_errors( $this->suppress );
- parent::tear_down();
- }
-
- 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 );
- }
-
- public static function wpTearDownAfterClass() {
- global $wpdb;
-
- 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 ) );
- }
- }
-
- public function test_wp_network_query_by_number() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- )
- );
-
- $this->assertCount( 3, $found );
- }
-
- public function test_wp_network_query_by_network__in_with_order() {
- $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
-
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- 'order' => 'ASC',
- )
- );
-
- $this->assertSame( $expected, $found );
-
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- 'order' => 'DESC',
- )
- );
-
- $this->assertSame( array_reverse( $expected ), $found );
- }
-
- public function test_wp_network_query_by_network__in_with_single_id() {
- $expected = array( self::$network_ids['wordpress.org/'] );
-
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/'] );
-
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__in' => $expected,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/'] );
-
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'count' => true,
- 'network__in' => $expected,
- )
- );
-
- $this->assertSame( 2, $found );
- }
-
- 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 );
-
- // Exclude main network since we don't have control over it here.
- $excluded[] = 1;
-
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__not_in' => $excluded,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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 );
-
- // Exclude main network since we don't have control over it here.
- $excluded[] = 1;
-
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network__not_in' => $excluded,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- public function test_wp_network_query_by_domain() {
- $q = new WP_Network_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain' => 'www.w.org',
- )
- );
-
- $expected = array(
- self::$network_ids['www.w.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$network_ids['make.wordpress.org/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$network_ids['wordpress.org/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$network_ids['make.wordpress.org/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- get_current_site()->id, // Account for the initial network added by the test suite.
- self::$network_ids['make.wordpress.org/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$network_ids['make.wordpress.org/'],
- self::$network_ids['www.wordpress.net/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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.
- )
- );
-
- $expected = array(
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- self::$network_ids['www.wordpress.net/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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.
- )
- );
-
- $expected = array(
- self::$network_ids['www.wordpress.net/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/',
- )
- );
-
- $this->assertEmpty( $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$network_ids['www.wordpress.net/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$network_ids['www.w.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$network_ids['www.wordpress.net/'],
- self::$network_ids['wordpress.org/'],
- self::$network_ids['make.wordpress.org/'],
- );
-
- $this->assertSame( $expected, $found );
- }
-
- /**
- * @ticket 41347
- */
- public function test_wp_network_query_cache_with_different_fields_no_count() {
- global $wpdb;
-
- $q = new WP_Network_Query();
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
- $number_of_queries = $wpdb->num_queries;
-
- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
-
- $this->assertSame( $number_of_queries, $wpdb->num_queries );
- }
-
- /**
- * @ticket 41347
- */
- public function test_wp_network_query_cache_with_different_fields_active_count() {
- global $wpdb;
-
- $q = new WP_Network_Query();
-
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $number_of_queries = $wpdb->num_queries;
-
- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $this->assertSame( $number_of_queries, $wpdb->num_queries );
- }
-
- /**
- * @ticket 41347
- */
- public function test_wp_network_query_cache_with_same_fields_different_count() {
- global $wpdb;
-
- $q = new WP_Network_Query();
-
- $query_1 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
-
- $number_of_queries = $wpdb->num_queries;
-
- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
- }
-
- /**
- * @ticket 45749
- * @ticket 47599
- */
- public function test_networks_pre_query_filter_should_bypass_database_query() {
- global $wpdb;
-
- add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
-
- $num_queries = $wpdb->num_queries;
-
- $q = new WP_Network_Query();
- $results = $q->query( array() );
-
- remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
-
- // Make sure no queries were executed.
- $this->assertSame( $num_queries, $wpdb->num_queries );
-
- // We manually inserted a non-existing site and overrode the results with it.
- $this->assertSame( array( 555 ), $results );
-
- // Make sure manually setting found_networks doesn't get overwritten.
- $this->assertSame( 1, $q->found_networks );
- }
-
- public static function filter_networks_pre_query( $networks, $query ) {
- $query->found_networks = 1;
-
- return array( 555 );
- }
-
- /**
- * @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 );
-
- $q = new WP_Network_Query();
- $results = $q->query( array() );
-
- remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query_and_set_networks' ), 10 );
-
- // Make sure the networks property is the same as the results.
- $this->assertSame( $results, $q->networks );
-
- // Make sure the network domain is `wordpress.org`.
- $this->assertSame( 'wordpress.org', $q->networks[0]->domain );
- }
-
- public static function filter_networks_pre_query_and_set_networks( $networks, $query ) {
- return array( get_network( self::$network_ids['wordpress.org/'] ) );
- }
- }
-
-endif;
</del></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/siteDetails.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Site_Details extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_SiteDetails extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @dataProvider data_allowed_options
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/siteMeta.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,7 +8,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group meta
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 37923
</span><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_Site_Meta extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_SiteMeta extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $site_id;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $site_id2;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $flag_was_set;
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitesiteQueryphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/multisite/siteQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/siteQuery.php 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/siteQuery.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,1122 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-if ( is_multisite() ) :
-
- /**
- * Test site query functionality in multisite.
- *
- * @group ms-site
- * @group multisite
- */
- class Tests_Multisite_Site_Query extends WP_UnitTestCase {
- protected static $network_ids;
- protected static $site_ids;
-
- protected $suppress = false;
-
- function set_up() {
- global $wpdb;
- parent::set_up();
- $this->suppress = $wpdb->suppress_errors();
- }
-
- function tear_down() {
- global $wpdb;
- $wpdb->suppress_errors( $this->suppress );
- parent::tear_down();
- }
-
- 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' => '/',
- ),
- );
-
- foreach ( self::$network_ids as &$id ) {
- $id = $factory->network->create( $id );
- }
- unset( $id );
-
- 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 );
- }
-
- public static function wpTearDownAfterClass() {
- global $wpdb;
-
- 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();
- }
-
- 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/'],
- )
- );
-
- $this->assertSameSets( array( self::$site_ids['www.w.org/'] ), $found );
- }
-
- public function test_wp_site_query_by_number() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'number' => 3,
- )
- );
-
- $this->assertCount( 3, $found );
- }
-
- public function test_wp_site_query_by_site__in_with_single_id() {
- $expected = array( self::$site_ids['wordpress.org/foo/'] );
-
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__in' => $expected,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/'] );
-
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__in' => $expected,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- /**
- * 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/'] );
-
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'count' => true,
- 'site__in' => $expected,
- )
- );
-
- $this->assertSame( 2, $found );
- }
-
- 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 );
-
- // Exclude main site since we don't have control over it here.
- $excluded[] = 1;
-
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__not_in' => $excluded,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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 );
-
- // Exclude main site since we don't have control over it here.
- $excluded[] = 1;
-
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'site__not_in' => $excluded,
- )
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$site_ids['wordpress.org/'],
- self::$site_ids['wordpress.org/foo/'],
- self::$site_ids['wordpress.org/foo/bar/'],
- );
-
- $this->assertSame( $expected, $found );
-
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'DESC',
- )
- );
-
- $this->assertSame( array_reverse( $expected ), $found );
- }
-
- 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/'],
- )
- );
-
- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/'],
- )
- );
-
- $this->assertEmpty( $found );
- }
-
- public function test_wp_site_query_by_domain() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'domain' => 'www.w.org',
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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,
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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,
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/foo/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/',
- )
- );
-
- $expected = array(
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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/',
- )
- );
-
- $this->assertEmpty( $found );
- }
-
- // archived, mature, spam, deleted, public.
-
- 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',
- )
- );
-
- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
-
- 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',
- )
- );
-
- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
-
- 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',
- )
- );
-
- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
-
- 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',
- )
- );
-
- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
-
- public function test_wp_site_query_by_deleted_with_no_results() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'deleted' => '1',
- )
- );
-
- $this->assertEmpty( $found );
- }
-
- 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',
- )
- );
-
- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
-
- 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,
- )
- );
-
- $this->assertSameSets( array_diff( array_values( self::$site_ids ), array( self::$site_ids['www.w.org/make/'] ) ), $found );
- }
-
- public function test_wp_site_query_by_lang_id() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang_id' => 1,
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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,
- )
- );
-
- $this->assertEmpty( $found );
- }
-
- public function test_wp_site_query_by_lang__in() {
- $q = new WP_Site_Query();
- $found = $q->query(
- array(
- 'fields' => 'ids',
- 'lang__in' => array( 1 ),
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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 ),
- )
- );
-
- $this->assertSameSets( array_values( self::$site_ids ), $found );
- }
-
- 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 ),
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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 ),
- )
- );
-
- $this->assertEmpty( $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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',
- )
- );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSame( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSame( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSame( $expected, $found );
- }
-
- 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',
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$site_ids['make.wordpress.org/'],
- self::$site_ids['make.wordpress.org/foo/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- 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' ),
- )
- );
-
- $expected = array(
- self::$site_ids['www.w.org/make/'],
- );
-
- $this->assertSameSets( $expected, $found );
- }
-
- /**
- * @ticket 41197
- */
- public function test_wp_site_query_cache_with_different_fields_no_count() {
- global $wpdb;
- $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 = $wpdb->num_queries;
-
- $query_2 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
-
- $this->assertSame( $number_of_queries, $wpdb->num_queries );
- }
-
- /**
- * @ticket 41197
- */
- public function test_wp_site_query_cache_with_different_fields_active_count() {
- global $wpdb;
- $q = new WP_Site_Query();
-
- $query_1 = $q->query(
- array(
- 'fields' => 'all',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- 'count' => true,
- )
- );
- $number_of_queries = $wpdb->num_queries;
-
- $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, $wpdb->num_queries );
- }
-
- /**
- * @ticket 41197
- */
- public function test_wp_site_query_cache_with_same_fields_different_count() {
- global $wpdb;
- $q = new WP_Site_Query();
-
- $query_1 = $q->query(
- array(
- 'fields' => 'ids',
- 'network_id' => self::$network_ids['wordpress.org/'],
- 'number' => 3,
- 'order' => 'ASC',
- )
- );
-
- $number_of_queries = $wpdb->num_queries;
-
- $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, $wpdb->num_queries );
- }
-
- /**
- * @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.' );
- }
-
- 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 );
-
- $query['fields'] = 'ids';
-
- $q = new WP_Site_Query();
- $found = $q->query( $query );
-
- foreach ( $expected as $index => $domain_path ) {
- $expected[ $index ] = self::$site_ids[ $domain_path ];
- }
-
- if ( $strict ) {
- $this->assertSame( $expected, $found );
- } else {
- $this->assertSameSets( $expected, $found );
- }
- }
-
- public function data_wp_site_query_meta_query() {
- return array(
- array(
- array(
- 'meta_key' => 'foo',
- ),
- array(
- 'wordpress.org/',
- 'wordpress.org/foo/',
- 'wordpress.org/foo/bar/',
- ),
- false,
- ),
- array(
- array(
- 'meta_key' => 'foo',
- 'meta_value' => 'bar',
- ),
- array(
- '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',
- ),
- array(
- 'key' => 'numberfoo',
- 'value' => 2,
- 'type' => 'NUMERIC',
- ),
- ),
- ),
- array(
- 'wordpress.org/foo/',
- ),
- false,
- ),
- array(
- array(
- 'meta_key' => 'foo',
- 'orderby' => 'meta_value',
- 'order' => 'ASC',
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/foo/bar/',
- 'wordpress.org/',
- ),
- true,
- ),
- array(
- array(
- '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',
- ),
- array(
- 'key' => 'numberfoo',
- ),
- ),
- 'orderby' => array( 'meta_value' => 'ASC' ),
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
- ),
- array(
- array(
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => array( 'foo', 'bar' ),
- 'compare' => 'IN',
- ),
- array(
- 'key' => 'numberfoo',
- ),
- ),
- 'orderby' => array( 'foo' => 'ASC' ),
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
- ),
- array(
- array(
- 'meta_query' => array(
- array(
- 'key' => 'foo',
- 'value' => array( 'foo', 'bar' ),
- 'compare' => 'IN',
- ),
- 'my_subquery' => array(
- 'key' => 'numberfoo',
- ),
- ),
- 'orderby' => array( 'my_subquery' => 'DESC' ),
- ),
- array(
- 'wordpress.org/foo/',
- 'wordpress.org/',
- ),
- true,
- ),
- );
- }
-
- /**
- * @ticket 45749
- * @ticket 47599
- */
- public function test_sites_pre_query_filter_should_bypass_database_query() {
- global $wpdb;
-
- add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
-
- $num_queries = $wpdb->num_queries;
-
- $q = new WP_Site_Query();
- $results = $q->query( array() );
-
- remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
-
- // Make sure no queries were executed.
- $this->assertSame( $num_queries, $wpdb->num_queries );
-
- // We manually inserted a non-existing site and overrode the results with it.
- $this->assertSame( array( 555 ), $results );
-
- // Make sure manually setting found_sites doesn't get overwritten.
- $this->assertSame( 1, $q->found_sites );
- }
-
- public static function filter_sites_pre_query( $sites, $query ) {
- $query->found_sites = 1;
-
- return array( 555 );
- }
-
- /**
- * @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 );
-
- $q = new WP_Site_Query();
- $results = $q->query( array() );
-
- remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query_and_set_sites' ), 10 );
-
- // Make sure the sites property is the same as the results.
- $this->assertSame( $results, $q->sites );
-
- // Make sure the site domain is `wordpress.org`.
- $this->assertSame( 'wordpress.org', $q->sites[0]->domain );
- }
-
- public static function filter_sites_pre_query_and_set_sites( $sites, $query ) {
- return array( get_site( self::$site_ids['wordpress.org/'] ) );
- }
- }
-
-endif;
</del></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/updateBlogDetails.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,7 +6,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Update_Blog_Details extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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"> * If `update_blog_details()` is called with any kind of empty arguments, it
</span><span class="cx" style="display: block; padding: 0 10px"> * should return false.
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,7 +10,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Upload_Is_User_Over_Quota extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_UploadIsUserOverQuota extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $suppress = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_up() {
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/wpGetSites.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_WP_Get_Sites extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_wpGetSites extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $site_ids;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/wpInstallDefaults.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,7 +8,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group ms-site
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_Install_Defaults extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_wpInstallDefaults extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40036
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpMSSitesListTablephp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: 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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/wpMSSitesListTable.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,234 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-if ( is_multisite() ) :
-
- /**
- * @group admin
- * @group network-admin
- */
- class Tests_WP_MS_Sites_List_Table extends WP_UnitTestCase {
- protected static $site_ids;
-
- /**
- * @var WP_MS_Sites_List_Table
- */
- public $table = false;
-
- function set_up() {
- parent::set_up();
- $this->table = _get_list_table( 'WP_MS_Sites_List_Table', array( 'screen' => 'ms-sites' ) );
- }
-
- 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 );
- }
-
- public static function wpTearDownAfterClass() {
- foreach ( self::$site_ids as $site_id ) {
- wp_delete_site( $site_id );
- }
- }
-
- public function test_ms_sites_list_table_default_items() {
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- $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.' );
- }
-
- $_REQUEST['s'] = 'foo';
-
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- unset( $_REQUEST['s'] );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $items );
- }
-
- 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.' );
- }
-
- $_REQUEST['s'] = 'foo/bar';
-
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- unset( $_REQUEST['s'] );
-
- $expected = array(
- self::$site_ids['wordpress.org/foo/bar/'],
- self::$site_ids['www.w.org/foo/bar/'],
- );
-
- $this->assertSameSets( $expected, $items );
- }
-
- public function test_ms_sites_list_table_invalid_path_search_items() {
- $_REQUEST['s'] = 'foobar';
-
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- unset( $_REQUEST['s'] );
-
- $this->assertEmpty( $items );
- }
-
- 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.' );
- }
-
- $_REQUEST['s'] = 'test';
-
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- unset( $_REQUEST['s'] );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $items );
- }
-
- 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.' );
- }
-
- $_REQUEST['s'] = 'test*';
-
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- unset( $_REQUEST['s'] );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $items );
- }
-
- 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.' );
- }
-
- $_REQUEST['s'] = 'fo*';
-
- $this->table->prepare_items();
-
- $items = wp_list_pluck( $this->table->items, 'blog_id' );
- $items = array_map( 'intval', $items );
-
- unset( $_REQUEST['s'] );
-
- $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/'],
- );
-
- $this->assertSameSets( $expected, $items );
- }
- }
-endif;
</del></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpMsSitesListTablephpfromrev51859trunktestsphpunittestsmultisitewpMSSitesListTablephp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.php (from rev 51859, 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 (rev 0)
+++ trunk/tests/phpunit/tests/multisite/wpMsSitesListTable.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,234 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+if ( is_multisite() ) :
+
+ /**
+ * @group admin
+ * @group network-admin
+ */
+ class Tests_Multisite_wpMsSitesListTable extends WP_UnitTestCase {
+ protected static $site_ids;
+
+ /**
+ * @var WP_MS_Sites_List_Table
+ */
+ public $table = false;
+
+ function set_up() {
+ parent::set_up();
+ $this->table = _get_list_table( 'WP_MS_Sites_List_Table', array( 'screen' => 'ms-sites' ) );
+ }
+
+ 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 );
+ }
+
+ public static function wpTearDownAfterClass() {
+ foreach ( self::$site_ids as $site_id ) {
+ wp_delete_site( $site_id );
+ }
+ }
+
+ public function test_ms_sites_list_table_default_items() {
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ $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.' );
+ }
+
+ $_REQUEST['s'] = 'foo';
+
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ unset( $_REQUEST['s'] );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $items );
+ }
+
+ 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.' );
+ }
+
+ $_REQUEST['s'] = 'foo/bar';
+
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ unset( $_REQUEST['s'] );
+
+ $expected = array(
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
+
+ $this->assertSameSets( $expected, $items );
+ }
+
+ public function test_ms_sites_list_table_invalid_path_search_items() {
+ $_REQUEST['s'] = 'foobar';
+
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ unset( $_REQUEST['s'] );
+
+ $this->assertEmpty( $items );
+ }
+
+ 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.' );
+ }
+
+ $_REQUEST['s'] = 'test';
+
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ unset( $_REQUEST['s'] );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $items );
+ }
+
+ 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.' );
+ }
+
+ $_REQUEST['s'] = 'test*';
+
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ unset( $_REQUEST['s'] );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $items );
+ }
+
+ 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.' );
+ }
+
+ $_REQUEST['s'] = 'fo*';
+
+ $this->table->prepare_items();
+
+ $items = wp_list_pluck( $this->table->items, 'blog_id' );
+ $items = array_map( 'intval', $items );
+
+ unset( $_REQUEST['s'] );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $items );
+ }
+ }
+endif;
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpNetworkQueryphpfromrev51859trunktestsphpunittestsmultisitenetworkQueryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php (from rev 51859, trunk/tests/phpunit/tests/multisite/networkQuery.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php (rev 0)
+++ trunk/tests/phpunit/tests/multisite/wpNetworkQuery.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,581 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+if ( is_multisite() ) :
+
+ /**
+ * 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;
+
+ protected $suppress = false;
+
+ function set_up() {
+ global $wpdb;
+ parent::set_up();
+ $this->suppress = $wpdb->suppress_errors();
+ }
+
+ function tear_down() {
+ global $wpdb;
+ $wpdb->suppress_errors( $this->suppress );
+ parent::tear_down();
+ }
+
+ 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 );
+ }
+
+ public static function wpTearDownAfterClass() {
+ global $wpdb;
+
+ 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 ) );
+ }
+ }
+
+ public function test_wp_network_query_by_number() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ )
+ );
+
+ $this->assertCount( 3, $found );
+ }
+
+ public function test_wp_network_query_by_network__in_with_order() {
+ $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
+
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ 'order' => 'ASC',
+ )
+ );
+
+ $this->assertSame( $expected, $found );
+
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ 'order' => 'DESC',
+ )
+ );
+
+ $this->assertSame( array_reverse( $expected ), $found );
+ }
+
+ public function test_wp_network_query_by_network__in_with_single_id() {
+ $expected = array( self::$network_ids['wordpress.org/'] );
+
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/'] );
+
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__in' => $expected,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/'] );
+
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'count' => true,
+ 'network__in' => $expected,
+ )
+ );
+
+ $this->assertSame( 2, $found );
+ }
+
+ 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 );
+
+ // Exclude main network since we don't have control over it here.
+ $excluded[] = 1;
+
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__not_in' => $excluded,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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 );
+
+ // Exclude main network since we don't have control over it here.
+ $excluded[] = 1;
+
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network__not_in' => $excluded,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ public function test_wp_network_query_by_domain() {
+ $q = new WP_Network_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain' => 'www.w.org',
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['www.w.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['make.wordpress.org/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['wordpress.org/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['make.wordpress.org/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ get_current_site()->id, // Account for the initial network added by the test suite.
+ self::$network_ids['make.wordpress.org/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['make.wordpress.org/'],
+ self::$network_ids['www.wordpress.net/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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.
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ self::$network_ids['www.wordpress.net/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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.
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['www.wordpress.net/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/',
+ )
+ );
+
+ $this->assertEmpty( $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['www.wordpress.net/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['www.w.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$network_ids['www.wordpress.net/'],
+ self::$network_ids['wordpress.org/'],
+ self::$network_ids['make.wordpress.org/'],
+ );
+
+ $this->assertSame( $expected, $found );
+ }
+
+ /**
+ * @ticket 41347
+ */
+ public function test_wp_network_query_cache_with_different_fields_no_count() {
+ global $wpdb;
+
+ $q = new WP_Network_Query();
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+ $number_of_queries = $wpdb->num_queries;
+
+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+
+ $this->assertSame( $number_of_queries, $wpdb->num_queries );
+ }
+
+ /**
+ * @ticket 41347
+ */
+ public function test_wp_network_query_cache_with_different_fields_active_count() {
+ global $wpdb;
+
+ $q = new WP_Network_Query();
+
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $number_of_queries = $wpdb->num_queries;
+
+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries, $wpdb->num_queries );
+ }
+
+ /**
+ * @ticket 41347
+ */
+ public function test_wp_network_query_cache_with_same_fields_different_count() {
+ global $wpdb;
+
+ $q = new WP_Network_Query();
+
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+
+ $number_of_queries = $wpdb->num_queries;
+
+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
+ }
+
+ /**
+ * @ticket 45749
+ * @ticket 47599
+ */
+ public function test_networks_pre_query_filter_should_bypass_database_query() {
+ global $wpdb;
+
+ add_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
+
+ $num_queries = $wpdb->num_queries;
+
+ $q = new WP_Network_Query();
+ $results = $q->query( array() );
+
+ remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query' ), 10, 2 );
+
+ // Make sure no queries were executed.
+ $this->assertSame( $num_queries, $wpdb->num_queries );
+
+ // We manually inserted a non-existing site and overrode the results with it.
+ $this->assertSame( array( 555 ), $results );
+
+ // Make sure manually setting found_networks doesn't get overwritten.
+ $this->assertSame( 1, $q->found_networks );
+ }
+
+ public static function filter_networks_pre_query( $networks, $query ) {
+ $query->found_networks = 1;
+
+ return array( 555 );
+ }
+
+ /**
+ * @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 );
+
+ $q = new WP_Network_Query();
+ $results = $q->query( array() );
+
+ remove_filter( 'networks_pre_query', array( __CLASS__, 'filter_networks_pre_query_and_set_networks' ), 10 );
+
+ // Make sure the networks property is the same as the results.
+ $this->assertSame( $results, $q->networks );
+
+ // Make sure the network domain is `wordpress.org`.
+ $this->assertSame( 'wordpress.org', $q->networks[0]->domain );
+ }
+
+ public static function filter_networks_pre_query_and_set_networks( $networks, $query ) {
+ return array( get_network( self::$network_ids['wordpress.org/'] ) );
+ }
+ }
+
+endif;
</ins></span></pre></div>
<a id="trunktestsphpunittestsmultisitewpSiteQueryphpfromrev51859trunktestsphpunittestsmultisitesiteQueryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/multisite/wpSiteQuery.php (from rev 51859, trunk/tests/phpunit/tests/multisite/siteQuery.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/wpSiteQuery.php (rev 0)
+++ trunk/tests/phpunit/tests/multisite/wpSiteQuery.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,1122 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+if ( is_multisite() ) :
+
+ /**
+ * 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;
+
+ protected $suppress = false;
+
+ function set_up() {
+ global $wpdb;
+ parent::set_up();
+ $this->suppress = $wpdb->suppress_errors();
+ }
+
+ function tear_down() {
+ global $wpdb;
+ $wpdb->suppress_errors( $this->suppress );
+ parent::tear_down();
+ }
+
+ 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' => '/',
+ ),
+ );
+
+ foreach ( self::$network_ids as &$id ) {
+ $id = $factory->network->create( $id );
+ }
+ unset( $id );
+
+ 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 );
+ }
+
+ public static function wpTearDownAfterClass() {
+ global $wpdb;
+
+ 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();
+ }
+
+ 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/'],
+ )
+ );
+
+ $this->assertSameSets( array( self::$site_ids['www.w.org/'] ), $found );
+ }
+
+ public function test_wp_site_query_by_number() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 3,
+ )
+ );
+
+ $this->assertCount( 3, $found );
+ }
+
+ public function test_wp_site_query_by_site__in_with_single_id() {
+ $expected = array( self::$site_ids['wordpress.org/foo/'] );
+
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__in' => $expected,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/'] );
+
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__in' => $expected,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ /**
+ * 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/'] );
+
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'count' => true,
+ 'site__in' => $expected,
+ )
+ );
+
+ $this->assertSame( 2, $found );
+ }
+
+ 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 );
+
+ // Exclude main site since we don't have control over it here.
+ $excluded[] = 1;
+
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__not_in' => $excluded,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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 );
+
+ // Exclude main site since we don't have control over it here.
+ $excluded[] = 1;
+
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'site__not_in' => $excluded,
+ )
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['wordpress.org/'],
+ self::$site_ids['wordpress.org/foo/'],
+ self::$site_ids['wordpress.org/foo/bar/'],
+ );
+
+ $this->assertSame( $expected, $found );
+
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'DESC',
+ )
+ );
+
+ $this->assertSame( array_reverse( $expected ), $found );
+ }
+
+ 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/'],
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/'],
+ )
+ );
+
+ $this->assertEmpty( $found );
+ }
+
+ public function test_wp_site_query_by_domain() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'domain' => 'www.w.org',
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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,
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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,
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/foo/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/',
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['wordpress.org/foo/bar/'],
+ self::$site_ids['www.w.org/foo/bar/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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/',
+ )
+ );
+
+ $this->assertEmpty( $found );
+ }
+
+ // archived, mature, spam, deleted, public.
+
+ 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',
+ )
+ );
+
+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
+
+ 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',
+ )
+ );
+
+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
+
+ 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',
+ )
+ );
+
+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
+
+ 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',
+ )
+ );
+
+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
+
+ public function test_wp_site_query_by_deleted_with_no_results() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'deleted' => '1',
+ )
+ );
+
+ $this->assertEmpty( $found );
+ }
+
+ 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',
+ )
+ );
+
+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
+
+ 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,
+ )
+ );
+
+ $this->assertSameSets( array_diff( array_values( self::$site_ids ), array( self::$site_ids['www.w.org/make/'] ) ), $found );
+ }
+
+ public function test_wp_site_query_by_lang_id() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang_id' => 1,
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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,
+ )
+ );
+
+ $this->assertEmpty( $found );
+ }
+
+ public function test_wp_site_query_by_lang__in() {
+ $q = new WP_Site_Query();
+ $found = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'lang__in' => array( 1 ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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 ),
+ )
+ );
+
+ $this->assertSameSets( array_values( self::$site_ids ), $found );
+ }
+
+ 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 ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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 ),
+ )
+ );
+
+ $this->assertEmpty( $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $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/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSame( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSame( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSame( $expected, $found );
+ }
+
+ 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',
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['make.wordpress.org/'],
+ self::$site_ids['make.wordpress.org/foo/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ 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' ),
+ )
+ );
+
+ $expected = array(
+ self::$site_ids['www.w.org/make/'],
+ );
+
+ $this->assertSameSets( $expected, $found );
+ }
+
+ /**
+ * @ticket 41197
+ */
+ public function test_wp_site_query_cache_with_different_fields_no_count() {
+ global $wpdb;
+ $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 = $wpdb->num_queries;
+
+ $query_2 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+
+ $this->assertSame( $number_of_queries, $wpdb->num_queries );
+ }
+
+ /**
+ * @ticket 41197
+ */
+ public function test_wp_site_query_cache_with_different_fields_active_count() {
+ global $wpdb;
+ $q = new WP_Site_Query();
+
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'all',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ 'count' => true,
+ )
+ );
+ $number_of_queries = $wpdb->num_queries;
+
+ $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, $wpdb->num_queries );
+ }
+
+ /**
+ * @ticket 41197
+ */
+ public function test_wp_site_query_cache_with_same_fields_different_count() {
+ global $wpdb;
+ $q = new WP_Site_Query();
+
+ $query_1 = $q->query(
+ array(
+ 'fields' => 'ids',
+ 'network_id' => self::$network_ids['wordpress.org/'],
+ 'number' => 3,
+ 'order' => 'ASC',
+ )
+ );
+
+ $number_of_queries = $wpdb->num_queries;
+
+ $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, $wpdb->num_queries );
+ }
+
+ /**
+ * @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.' );
+ }
+
+ 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 );
+
+ $query['fields'] = 'ids';
+
+ $q = new WP_Site_Query();
+ $found = $q->query( $query );
+
+ foreach ( $expected as $index => $domain_path ) {
+ $expected[ $index ] = self::$site_ids[ $domain_path ];
+ }
+
+ if ( $strict ) {
+ $this->assertSame( $expected, $found );
+ } else {
+ $this->assertSameSets( $expected, $found );
+ }
+ }
+
+ public function data_wp_site_query_meta_query() {
+ return array(
+ array(
+ array(
+ 'meta_key' => 'foo',
+ ),
+ array(
+ 'wordpress.org/',
+ 'wordpress.org/foo/',
+ 'wordpress.org/foo/bar/',
+ ),
+ false,
+ ),
+ array(
+ array(
+ 'meta_key' => 'foo',
+ 'meta_value' => 'bar',
+ ),
+ array(
+ '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',
+ ),
+ array(
+ 'key' => 'numberfoo',
+ 'value' => 2,
+ 'type' => 'NUMERIC',
+ ),
+ ),
+ ),
+ array(
+ 'wordpress.org/foo/',
+ ),
+ false,
+ ),
+ array(
+ array(
+ 'meta_key' => 'foo',
+ 'orderby' => 'meta_value',
+ 'order' => 'ASC',
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/foo/bar/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ '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',
+ ),
+ array(
+ 'key' => 'numberfoo',
+ ),
+ ),
+ 'orderby' => array( 'meta_value' => 'ASC' ),
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => array( 'foo', 'bar' ),
+ 'compare' => 'IN',
+ ),
+ array(
+ 'key' => 'numberfoo',
+ ),
+ ),
+ 'orderby' => array( 'foo' => 'ASC' ),
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ array(
+ array(
+ 'meta_query' => array(
+ array(
+ 'key' => 'foo',
+ 'value' => array( 'foo', 'bar' ),
+ 'compare' => 'IN',
+ ),
+ 'my_subquery' => array(
+ 'key' => 'numberfoo',
+ ),
+ ),
+ 'orderby' => array( 'my_subquery' => 'DESC' ),
+ ),
+ array(
+ 'wordpress.org/foo/',
+ 'wordpress.org/',
+ ),
+ true,
+ ),
+ );
+ }
+
+ /**
+ * @ticket 45749
+ * @ticket 47599
+ */
+ public function test_sites_pre_query_filter_should_bypass_database_query() {
+ global $wpdb;
+
+ add_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
+
+ $num_queries = $wpdb->num_queries;
+
+ $q = new WP_Site_Query();
+ $results = $q->query( array() );
+
+ remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query' ), 10, 2 );
+
+ // Make sure no queries were executed.
+ $this->assertSame( $num_queries, $wpdb->num_queries );
+
+ // We manually inserted a non-existing site and overrode the results with it.
+ $this->assertSame( array( 555 ), $results );
+
+ // Make sure manually setting found_sites doesn't get overwritten.
+ $this->assertSame( 1, $q->found_sites );
+ }
+
+ public static function filter_sites_pre_query( $sites, $query ) {
+ $query->found_sites = 1;
+
+ return array( 555 );
+ }
+
+ /**
+ * @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 );
+
+ $q = new WP_Site_Query();
+ $results = $q->query( array() );
+
+ remove_filter( 'sites_pre_query', array( __CLASS__, 'filter_sites_pre_query_and_set_sites' ), 10 );
+
+ // Make sure the sites property is the same as the results.
+ $this->assertSame( $results, $q->sites );
+
+ // Make sure the site domain is `wordpress.org`.
+ $this->assertSame( 'wordpress.org', $q->sites[0]->domain );
+ }
+
+ public static function filter_sites_pre_query_and_set_sites( $sites, $query ) {
+ return array( get_site( self::$site_ids['wordpress.org/'] ) );
+ }
+ }
+
+endif;
</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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/wpmuValidateBlogSignup.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,7 +5,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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_WpmuValidateBlogSignup extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ class Tests_Multisite_wpmuValidateBlogSignup extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $super_admin_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $existing_user_login = 'existinguserfoo';
</span></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 2021-09-24 00:29:46 UTC (rev 51859)
+++ trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php 2021-09-24 00:45:43 UTC (rev 51860)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,7 +5,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @group multisite
</span><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 {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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"> * @dataProvider data_user_name
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre>
</div>
</div>
</body>
</html>