From 40ac5de838be0d75ec4f24bf400f04516745a736 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 4 Nov 2021 15:22:47 +0000 Subject: [PATCH] Coding Standards: Add visibility to methods in `tests/phpunit/tests/`. Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/actions.php | 56 ++-- tests/phpunit/tests/actions/callbacks.php | 2 +- tests/phpunit/tests/actions/closures.php | 2 +- tests/phpunit/tests/admin/includesFile.php | 2 +- tests/phpunit/tests/admin/includesPlugin.php | 24 +- tests/phpunit/tests/admin/includesPost.php | 10 +- tests/phpunit/tests/admin/includesSchema.php | 6 +- tests/phpunit/tests/admin/includesScreen.php | 22 +- tests/phpunit/tests/admin/includesTheme.php | 30 +- tests/phpunit/tests/adminbar.php | 4 +- tests/phpunit/tests/ajax/CustomizeManager.php | 10 +- tests/phpunit/tests/ajax/CustomizeMenus.php | 28 +- tests/phpunit/tests/ajax/EditComment.php | 2 +- tests/phpunit/tests/ajax/ManageThemes.php | 6 +- tests/phpunit/tests/ajax/ReplytoComment.php | 2 +- tests/phpunit/tests/attachment/slashes.php | 4 +- tests/phpunit/tests/auth.php | 34 +- tests/phpunit/tests/basic.php | 12 +- tests/phpunit/tests/block-template-utils.php | 6 +- tests/phpunit/tests/block-template.php | 6 +- tests/phpunit/tests/blocks/context.php | 6 +- tests/phpunit/tests/blocks/editor.php | 36 +-- tests/phpunit/tests/blocks/register.php | 50 +-- tests/phpunit/tests/blocks/render.php | 6 +- tests/phpunit/tests/blocks/serialize.php | 6 +- tests/phpunit/tests/blocks/wpBlock.php | 30 +- tests/phpunit/tests/blocks/wpBlockList.php | 6 +- tests/phpunit/tests/blocks/wpBlockType.php | 2 +- tests/phpunit/tests/cache.php | 44 +-- tests/phpunit/tests/canonical.php | 4 +- tests/phpunit/tests/canonical/customRules.php | 6 +- tests/phpunit/tests/canonical/https.php | 2 +- tests/phpunit/tests/canonical/noRewrite.php | 4 +- tests/phpunit/tests/canonical/pageOnFront.php | 6 +- tests/phpunit/tests/canonical/paged.php | 2 +- tests/phpunit/tests/canonical/postStatus.php | 6 +- tests/phpunit/tests/category.php | 14 +- tests/phpunit/tests/comment-submission.php | 2 +- tests/phpunit/tests/comment.php | 6 +- .../tests/comment/getCommentsPagesCount.php | 14 +- tests/phpunit/tests/comment/query.php | 24 +- tests/phpunit/tests/comment/slashes.php | 10 +- tests/phpunit/tests/comment/template.php | 18 +- tests/phpunit/tests/comment/walker.php | 4 +- tests/phpunit/tests/cron.php | 68 ++-- tests/phpunit/tests/customize/control.php | 8 +- .../tests/customize/custom-css-setting.php | 26 +- tests/phpunit/tests/customize/manager.php | 184 +++++------ .../tests/customize/nav-menu-item-setting.php | 48 +-- .../tests/customize/nav-menu-setting.php | 32 +- tests/phpunit/tests/customize/nav-menus.php | 64 ++-- tests/phpunit/tests/customize/panel.php | 28 +- tests/phpunit/tests/customize/partial.php | 34 +- tests/phpunit/tests/customize/section.php | 28 +- .../customize/selective-refresh-ajax.php | 36 +-- .../tests/customize/selective-refresh.php | 26 +- tests/phpunit/tests/customize/setting.php | 38 +-- tests/phpunit/tests/customize/widgets.php | 68 ++-- tests/phpunit/tests/date/getFeedBuildDate.php | 2 +- tests/phpunit/tests/date/getPermalink.php | 2 +- tests/phpunit/tests/date/mysql2date.php | 14 +- tests/phpunit/tests/date/theDate.php | 4 +- tests/phpunit/tests/date/xmlrpc.php | 2 +- tests/phpunit/tests/db.php | 126 ++++---- tests/phpunit/tests/db/charset.php | 52 +-- tests/phpunit/tests/db/realEscape.php | 2 +- tests/phpunit/tests/dbdelta.php | 42 +-- tests/phpunit/tests/dependencies.php | 14 +- tests/phpunit/tests/dependencies/jquery.php | 8 +- tests/phpunit/tests/dependencies/scripts.php | 48 +-- tests/phpunit/tests/dependencies/styles.php | 28 +- .../wpSanitizeScriptAttributes.php | 12 +- .../tests/dependencies/wpScriptTag.php | 6 +- tests/phpunit/tests/external-http/basic.php | 2 +- tests/phpunit/tests/feed/atom.php | 8 +- tests/phpunit/tests/feed/rss2.php | 24 +- tests/phpunit/tests/file.php | 32 +- tests/phpunit/tests/filesystem/base.php | 10 +- tests/phpunit/tests/filesystem/findFolder.php | 8 +- tests/phpunit/tests/filters.php | 43 ++- .../phpunit/tests/formatting/balanceTags.php | 48 +-- .../tests/formatting/capitalPDangit.php | 2 +- tests/phpunit/tests/formatting/cleanPre.php | 8 +- .../formatting/convertInvalidEntries.php | 6 +- .../tests/formatting/convertSmilies.php | 6 +- tests/phpunit/tests/formatting/date.php | 18 +- tests/phpunit/tests/formatting/ent2ncr.php | 4 +- tests/phpunit/tests/formatting/escAttr.php | 4 +- tests/phpunit/tests/formatting/escHtml.php | 8 +- tests/phpunit/tests/formatting/escJs.php | 14 +- .../phpunit/tests/formatting/escTextarea.php | 16 +- tests/phpunit/tests/formatting/escUrl.php | 38 +-- .../tests/formatting/excerptRemoveBlocks.php | 10 +- .../phpunit/tests/formatting/getBloginfo.php | 6 +- .../tests/formatting/getUrlInContent.php | 2 +- .../tests/formatting/humanTimeDiff.php | 4 +- tests/phpunit/tests/formatting/isEmail.php | 4 +- tests/phpunit/tests/formatting/likeEscape.php | 2 +- .../tests/formatting/linksAddTarget.php | 2 +- .../tests/formatting/makeClickable.php | 38 +-- .../tests/formatting/normalizeWhitespace.php | 2 +- tests/phpunit/tests/formatting/redirect.php | 20 +- .../tests/formatting/removeAccents.php | 24 +- .../tests/formatting/sanitizeFileName.php | 24 +- .../tests/formatting/sanitizeMimeType.php | 2 +- .../tests/formatting/sanitizeOrderby.php | 8 +- .../phpunit/tests/formatting/sanitizePost.php | 2 +- .../tests/formatting/sanitizeTextField.php | 4 +- .../tests/formatting/sanitizeTitle.php | 4 +- .../formatting/sanitizeTitleWithDashes.php | 40 +-- .../formatting/sanitizeTrackbackUrls.php | 4 +- .../phpunit/tests/formatting/sanitizeUser.php | 6 +- tests/phpunit/tests/formatting/seemsUtf8.php | 8 +- tests/phpunit/tests/formatting/slashit.php | 18 +- .../tests/formatting/stripslashesDeep.php | 6 +- tests/phpunit/tests/formatting/urlShorten.php | 2 +- .../tests/formatting/utf8UriEncode.php | 6 +- tests/phpunit/tests/formatting/wpAutop.php | 26 +- tests/phpunit/tests/formatting/wpBasename.php | 8 +- .../tests/formatting/wpHtmlExcerpt.php | 6 +- .../phpunit/tests/formatting/wpHtmlSplit.php | 8 +- .../tests/formatting/wpHtmleditPre.php | 16 +- .../tests/formatting/wpIsoDescrambler.php | 2 +- .../tests/formatting/wpMakeLinkRelative.php | 2 +- .../tests/formatting/wpReplaceInHtmlTags.php | 4 +- .../tests/formatting/wpRicheditPre.php | 16 +- tests/phpunit/tests/formatting/wpSlash.php | 6 +- .../tests/formatting/wpSpecialchars.php | 16 +- .../tests/formatting/wpStripAllTags.php | 2 +- .../phpunit/tests/formatting/wpTexturize.php | 144 ++++----- .../phpunit/tests/formatting/wpTrimWords.php | 18 +- tests/phpunit/tests/formatting/zeroise.php | 4 +- tests/phpunit/tests/functions.php | 134 ++++---- .../tests/functions/addMagicQuotes.php | 2 +- .../tests/functions/allowedProtocols.php | 8 +- .../tests/functions/canonicalCharset.php | 2 +- .../tests/functions/pluginBasename.php | 4 +- tests/phpunit/tests/functions/wpAuthCheck.php | 6 +- .../phpunit/tests/functions/wpGetArchives.php | 20 +- .../tests/functions/wpValidateBoolean.php | 2 +- tests/phpunit/tests/general/paginateLinks.php | 22 +- tests/phpunit/tests/general/template.php | 116 +++---- tests/phpunit/tests/general/wpGetArchives.php | 4 +- .../tests/general/wpGetDocumentTitle.php | 70 ++-- .../phpunit/tests/general/wpResourceHints.php | 68 ++-- tests/phpunit/tests/http/base.php | 52 +-- tests/phpunit/tests/http/functions.php | 20 +- tests/phpunit/tests/http/http.php | 22 +- .../tests/http/wpRemoteRetrieveHeaders.php | 6 +- tests/phpunit/tests/image/dimensions.php | 24 +- tests/phpunit/tests/image/functions.php | 16 +- tests/phpunit/tests/image/header.php | 18 +- .../phpunit/tests/image/intermediateSize.php | 24 +- tests/phpunit/tests/image/meta.php | 14 +- tests/phpunit/tests/image/resize.php | 22 +- tests/phpunit/tests/image/siteIcon.php | 42 +-- tests/phpunit/tests/image/size.php | 26 +- tests/phpunit/tests/import/import.php | 8 +- tests/phpunit/tests/import/parser.php | 14 +- tests/phpunit/tests/import/postmeta.php | 10 +- tests/phpunit/tests/includes/factory.php | 10 +- tests/phpunit/tests/includes/helpers.php | 8 +- tests/phpunit/tests/kses.php | 78 ++--- tests/phpunit/tests/l10n.php | 48 +-- tests/phpunit/tests/l10n/loadTextdomain.php | 18 +- .../l10n/translateSettingsUsingI18nSchema.php | 4 +- tests/phpunit/tests/link.php | 14 +- tests/phpunit/tests/link/getAdjacentPost.php | 2 +- .../phpunit/tests/load/wpConvertHrToBytes.php | 4 +- .../tests/load/wpIsIniValueChangeable.php | 4 +- tests/phpunit/tests/mail.php | 26 +- tests/phpunit/tests/media.php | 300 +++++++++--------- .../tests/media/getAdjacentImageLink.php | 2 +- .../phpunit/tests/media/getNextImageLink.php | 2 +- .../tests/media/getPreviousImageLink.php | 2 +- tests/phpunit/tests/media/nextImageLink.php | 2 +- .../phpunit/tests/media/previousImageLink.php | 2 +- tests/phpunit/tests/menu/nav-menu.php | 20 +- .../tests/menu/walker-nav-menu-edit.php | 6 +- tests/phpunit/tests/meta.php | 34 +- tests/phpunit/tests/meta/slashes.php | 16 +- tests/phpunit/tests/multisite.php | 4 +- tests/phpunit/tests/multisite/bootstrap.php | 4 +- .../tests/multisite/cleanDirsizeCache.php | 32 +- .../phpunit/tests/multisite/getSpaceUsed.php | 12 +- .../multisite/isUploadSpaceAvailable.php | 34 +- .../tests/multisite/msFilesRewriting.php | 6 +- tests/phpunit/tests/multisite/network.php | 44 +-- tests/phpunit/tests/multisite/site.php | 162 +++++----- .../tests/multisite/updateBlogDetails.php | 12 +- .../tests/multisite/wpMsSitesListTable.php | 2 +- tests/phpunit/tests/oembed/controller.php | 34 +- tests/phpunit/tests/oembed/discovery.php | 12 +- tests/phpunit/tests/oembed/filterResult.php | 22 +- .../phpunit/tests/oembed/getResponseData.php | 30 +- tests/phpunit/tests/oembed/headers.php | 2 +- tests/phpunit/tests/oembed/postEmbedUrl.php | 14 +- tests/phpunit/tests/oembed/template.php | 34 +- tests/phpunit/tests/option/multisite.php | 20 +- tests/phpunit/tests/option/networkOption.php | 12 +- tests/phpunit/tests/option/option.php | 16 +- tests/phpunit/tests/option/siteOption.php | 40 +-- tests/phpunit/tests/option/siteTransient.php | 4 +- tests/phpunit/tests/option/slashes.php | 6 +- tests/phpunit/tests/option/themeMods.php | 16 +- tests/phpunit/tests/option/transient.php | 12 +- tests/phpunit/tests/option/userSettings.php | 15 +- .../phpunit/tests/option/wpLoadAllOptions.php | 16 +- tests/phpunit/tests/pomo/mo.php | 20 +- tests/phpunit/tests/pomo/noopTranslations.php | 14 +- tests/phpunit/tests/pomo/po.php | 22 +- tests/phpunit/tests/pomo/translationEntry.php | 4 +- tests/phpunit/tests/pomo/translations.php | 8 +- tests/phpunit/tests/post.php | 152 ++++----- tests/phpunit/tests/post/attachments.php | 18 +- tests/phpunit/tests/post/filtering.php | 14 +- tests/phpunit/tests/post/formats.php | 8 +- tests/phpunit/tests/post/getPageUri.php | 10 +- tests/phpunit/tests/post/getPages.php | 20 +- .../tests/post/isPostStatusViewable.php | 4 +- tests/phpunit/tests/post/meta.php | 18 +- tests/phpunit/tests/post/nav-menu.php | 94 +++--- tests/phpunit/tests/post/objects.php | 20 +- tests/phpunit/tests/post/output.php | 22 +- tests/phpunit/tests/post/query.php | 20 +- tests/phpunit/tests/post/revisions.php | 26 +- tests/phpunit/tests/post/slashes.php | 10 +- tests/phpunit/tests/post/template.php | 4 +- tests/phpunit/tests/post/thumbnails.php | 40 +-- tests/phpunit/tests/post/types.php | 32 +- .../phpunit/tests/post/wpAfterInsertPost.php | 2 +- tests/phpunit/tests/post/wpInsertPost.php | 28 +- tests/phpunit/tests/post/wpListPages.php | 32 +- tests/phpunit/tests/post/wpPublishPost.php | 10 +- tests/phpunit/tests/post/wpUniquePostSlug.php | 2 +- tests/phpunit/tests/query.php | 18 +- tests/phpunit/tests/query/conditionals.php | 132 ++++---- tests/phpunit/tests/query/isTerm.php | 26 +- tests/phpunit/tests/query/results.php | 68 ++-- tests/phpunit/tests/query/search.php | 20 +- tests/phpunit/tests/query/setupPostdata.php | 2 +- .../tests/query/verboseRewriteRules.php | 2 +- tests/phpunit/tests/rest-api.php | 50 +-- .../tests/rest-api/rest-users-controller.php | 2 +- tests/phpunit/tests/rewrite.php | 44 +-- tests/phpunit/tests/shortcode.php | 203 ++++++------ tests/phpunit/tests/site-health.php | 6 +- tests/phpunit/tests/sitemaps/functions.php | 4 +- tests/phpunit/tests/taxonomy.php | 50 +-- tests/phpunit/tests/term.php | 22 +- tests/phpunit/tests/term/cache.php | 18 +- tests/phpunit/tests/term/getTermBy.php | 16 +- tests/phpunit/tests/term/getTermField.php | 2 +- tests/phpunit/tests/term/getTerms.php | 28 +- tests/phpunit/tests/term/getTheTerms.php | 6 +- tests/phpunit/tests/term/slashes.php | 6 +- tests/phpunit/tests/term/termCounts.php | 26 +- tests/phpunit/tests/term/termExists.php | 4 +- .../phpunit/tests/term/wpGenerateTagCloud.php | 14 +- tests/phpunit/tests/term/wpGetObjectTerms.php | 2 +- tests/phpunit/tests/term/wpSetObjectTerms.php | 12 +- tests/phpunit/tests/term/wpUpdateTerm.php | 2 +- tests/phpunit/tests/theme.php | 40 +-- tests/phpunit/tests/theme/customHeader.php | 104 +++--- .../tests/theme/getThemeStarterContent.php | 8 +- tests/phpunit/tests/theme/support.php | 20 +- tests/phpunit/tests/theme/themeDir.php | 32 +- tests/phpunit/tests/upload.php | 18 +- tests/phpunit/tests/url.php | 24 +- tests/phpunit/tests/user.php | 126 ++++---- tests/phpunit/tests/user/author.php | 12 +- tests/phpunit/tests/user/capabilities.php | 146 ++++----- tests/phpunit/tests/user/countUsers.php | 2 +- tests/phpunit/tests/user/listAuthors.php | 26 +- tests/phpunit/tests/user/mapMetaCap.php | 26 +- tests/phpunit/tests/user/multisite.php | 20 +- tests/phpunit/tests/user/query.php | 8 +- tests/phpunit/tests/user/session.php | 8 +- tests/phpunit/tests/user/slashes.php | 10 +- .../tests/user/wpAuthenticateSpamCheck.php | 6 +- tests/phpunit/tests/user/wpDeleteUser.php | 8 +- tests/phpunit/tests/walker.php | 38 +-- tests/phpunit/tests/widgets.php | 82 ++--- .../tests/widgets/wpWidgetCustomHtml.php | 4 +- tests/phpunit/tests/widgets/wpWidgetMedia.php | 36 +-- .../tests/widgets/wpWidgetMediaAudio.php | 18 +- .../tests/widgets/wpWidgetMediaImage.php | 16 +- .../tests/widgets/wpWidgetMediaVideo.php | 18 +- tests/phpunit/tests/widgets/wpWidgetText.php | 40 +-- tests/phpunit/tests/xmlrpc/basic.php | 12 +- tests/phpunit/tests/xmlrpc/client.php | 4 +- .../tests/xmlrpc/mt/getRecentPostTitles.php | 8 +- tests/phpunit/tests/xmlrpc/mw/editPost.php | 36 +-- tests/phpunit/tests/xmlrpc/mw/getPost.php | 12 +- .../tests/xmlrpc/mw/getRecentPosts.php | 12 +- tests/phpunit/tests/xmlrpc/mw/newPost.php | 110 +------ tests/phpunit/tests/xmlrpc/wp/deletePost.php | 8 +- tests/phpunit/tests/xmlrpc/wp/deleteTerm.php | 14 +- tests/phpunit/tests/xmlrpc/wp/editComment.php | 6 +- tests/phpunit/tests/xmlrpc/wp/editPost.php | 58 ++-- tests/phpunit/tests/xmlrpc/wp/editProfile.php | 8 +- tests/phpunit/tests/xmlrpc/wp/editTerm.php | 28 +- tests/phpunit/tests/xmlrpc/wp/getComment.php | 10 +- tests/phpunit/tests/xmlrpc/wp/getComments.php | 16 +- .../phpunit/tests/xmlrpc/wp/getMediaItem.php | 8 +- tests/phpunit/tests/xmlrpc/wp/getOptions.php | 10 +- tests/phpunit/tests/xmlrpc/wp/getPage.php | 8 +- tests/phpunit/tests/xmlrpc/wp/getPageList.php | 6 +- tests/phpunit/tests/xmlrpc/wp/getPages.php | 10 +- tests/phpunit/tests/xmlrpc/wp/getPost.php | 14 +- tests/phpunit/tests/xmlrpc/wp/getPostType.php | 12 +- .../phpunit/tests/xmlrpc/wp/getPostTypes.php | 8 +- tests/phpunit/tests/xmlrpc/wp/getPosts.php | 14 +- tests/phpunit/tests/xmlrpc/wp/getProfile.php | 8 +- .../phpunit/tests/xmlrpc/wp/getRevisions.php | 20 +- .../phpunit/tests/xmlrpc/wp/getTaxonomies.php | 4 +- tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php | 14 +- tests/phpunit/tests/xmlrpc/wp/getTerm.php | 14 +- tests/phpunit/tests/xmlrpc/wp/getTerms.php | 16 +- tests/phpunit/tests/xmlrpc/wp/getUser.php | 18 +- tests/phpunit/tests/xmlrpc/wp/getUsers.php | 14 +- tests/phpunit/tests/xmlrpc/wp/newComment.php | 18 +- tests/phpunit/tests/xmlrpc/wp/newPost.php | 250 ++------------- tests/phpunit/tests/xmlrpc/wp/newTerm.php | 22 +- .../tests/xmlrpc/wp/restoreRevision.php | 10 +- tests/phpunit/tests/xmlrpc/wp/setOptions.php | 2 +- tests/phpunit/tests/xmlrpc/wp/uploadFile.php | 2 +- 327 files changed, 3656 insertions(+), 3969 deletions(-) diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index ceacc72d7c..51225f12dd 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -10,7 +10,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::do_action */ - function test_simple_action() { + public function test_simple_action() { $a = new MockAction(); $tag = __FUNCTION__; @@ -30,7 +30,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::remove_action */ - function test_remove_action() { + public function test_remove_action() { $a = new MockAction(); $tag = __FUNCTION__; @@ -52,7 +52,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::has_action */ - function test_has_action() { + public function test_has_action() { $tag = __FUNCTION__; $func = __FUNCTION__ . '_func'; @@ -71,7 +71,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_multiple_actions() { + public function test_multiple_actions() { $a1 = new MockAction(); $a2 = new MockAction(); $tag = __FUNCTION__; @@ -92,7 +92,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_action_args_1() { + public function test_action_args_1() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -112,7 +112,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_action_args_2() { + public function test_action_args_2() { $a1 = new MockAction(); $a2 = new MockAction(); $tag = __FUNCTION__; @@ -146,7 +146,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_action_args_3() { + public function test_action_args_3() { $a1 = new MockAction(); $a2 = new MockAction(); $a3 = new MockAction(); @@ -185,7 +185,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_action_args_with_php4_syntax() { + public function test_action_args_with_php4_syntax() { $a = new MockAction(); $tag = __FUNCTION__; $val = new stdClass(); @@ -199,7 +199,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertSame( array( $val ), array_pop( $argsvar ) ); } - function test_action_priority() { + public function test_action_priority() { $a = new MockAction(); $tag = __FUNCTION__; @@ -231,7 +231,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::did_action */ - function test_did_action() { + public function test_did_action() { $tag1 = 'action1'; $tag2 = 'action2'; @@ -255,7 +255,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::do_action */ - function test_all_action() { + public function test_all_action() { $a = new MockAction(); $tag1 = __FUNCTION__ . '_1'; $tag2 = __FUNCTION__ . '_2'; @@ -282,7 +282,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::remove_action */ - function test_remove_all_action() { + public function test_remove_all_action() { $a = new MockAction(); $tag = __FUNCTION__; @@ -305,7 +305,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::do_action_ref_array */ - function test_action_ref_array() { + public function test_action_ref_array() { $obj = new stdClass(); $a = new MockAction(); $tag = __FUNCTION__; @@ -326,7 +326,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_action_keyed_array() { + public function test_action_keyed_array() { $a = new MockAction(); $tag = __FUNCTION__; @@ -353,13 +353,13 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::remove_action */ - function test_action_self_removal() { + public function test_action_self_removal() { add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) ); do_action( 'test_action_self_removal' ); $this->assertSame( 1, did_action( 'test_action_self_removal' ) ); } - function action_self_removal() { + public function action_self_removal() { remove_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) ); } @@ -368,7 +368,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::do_action */ - function test_action_recursion() { + public function test_action_recursion() { $tag = __FUNCTION__; $a = new MockAction(); $b = new MockAction(); @@ -385,7 +385,7 @@ class Tests_Actions extends WP_UnitTestCase { /** * @covers ::do_action */ - function action_that_causes_recursion( $tag ) { + public function action_that_causes_recursion( $tag ) { static $recursing = false; if ( ! $recursing ) { $recursing = true; @@ -401,7 +401,7 @@ class Tests_Actions extends WP_UnitTestCase { * @covers ::remove_action * @covers ::add_action */ - function test_action_callback_manipulation_while_running() { + public function test_action_callback_manipulation_while_running() { $tag = __FUNCTION__; $a = new MockAction(); $b = new MockAction(); @@ -423,7 +423,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertSame( 1, $e->get_call_count(), 'callback added by later priority callback should not get called' ); } - function action_that_manipulates_a_running_hook( $tag, $mocks ) { + public function action_that_manipulates_a_running_hook( $tag, $mocks ) { remove_action( $tag, array( $mocks[1], 'action' ), 12, 2 ); add_action( $tag, array( $mocks[2], 'action' ), 12, 2 ); add_action( $tag, array( $mocks[3], 'action' ), 13, 2 ); @@ -438,7 +438,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::remove_filter */ - function test_remove_anonymous_callback() { + public function test_remove_anonymous_callback() { $tag = __FUNCTION__; $a = new MockAction(); add_action( $tag, array( $a, 'action' ), 12, 1 ); @@ -475,7 +475,7 @@ class Tests_Actions extends WP_UnitTestCase { * @covers WP_Hook::offsetSet * @covers WP_Hook::offsetUnset */ - function test_array_access_of_wp_filter_global() { + public function test_array_access_of_wp_filter_global() { global $wp_filter; $tag = __FUNCTION__; @@ -503,7 +503,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::current_action */ - function test_current_action() { + public function test_current_action() { global $wp_current_filter; $wp_current_filter[] = 'first'; $wp_current_filter[] = 'second'; // Let's say a second action was invoked. @@ -516,7 +516,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::doing_filter */ - function test_doing_filter() { + public function test_doing_filter() { global $wp_current_filter; $wp_current_filter = array(); // Set to an empty array first. @@ -537,7 +537,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::doing_filter */ - function test_doing_action() { + public function test_doing_action() { global $wp_current_filter; $wp_current_filter = array(); // Set to an empty array first. @@ -558,7 +558,7 @@ class Tests_Actions extends WP_UnitTestCase { * * @covers ::doing_filter */ - function test_doing_filter_real() { + public function test_doing_filter_real() { $this->assertFalse( doing_filter() ); // No filter is passed in, and no filter is being processed. $this->assertFalse( doing_filter( 'testing' ) ); // Filter is passed in but not being processed. @@ -575,7 +575,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertFalse( doing_filter( 'testing' ) ); // No longer doing this filter. } - function apply_testing_filter() { + public function apply_testing_filter() { $this->apply_testing_filter = true; $this->assertTrue( doing_filter() ); @@ -596,7 +596,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertFalse( doing_filter( 'testing_nested' ) ); } - function apply_testing_nested_filter() { + public function apply_testing_nested_filter() { $this->apply_testing_nested_filter = true; $this->assertTrue( doing_filter() ); $this->assertTrue( doing_filter( 'testing' ) ); diff --git a/tests/phpunit/tests/actions/callbacks.php b/tests/phpunit/tests/actions/callbacks.php index 32d1c733d9..e311044994 100644 --- a/tests/phpunit/tests/actions/callbacks.php +++ b/tests/phpunit/tests/actions/callbacks.php @@ -10,7 +10,7 @@ class Tests_Actions_Callbacks extends WP_UnitTestCase { * * @covers ::add_action */ - function test_callback_representations() { + public function test_callback_representations() { $tag = __FUNCTION__; $this->assertFalse( has_action( $tag ) ); diff --git a/tests/phpunit/tests/actions/closures.php b/tests/phpunit/tests/actions/closures.php index 833367714b..b9016e860c 100644 --- a/tests/phpunit/tests/actions/closures.php +++ b/tests/phpunit/tests/actions/closures.php @@ -14,7 +14,7 @@ class Tests_Actions_Closures extends WP_UnitTestCase { * @covers ::has_action * @covers ::do_action */ - function test_action_closure() { + public function test_action_closure() { $tag = 'test_action_closure'; $closure = static function( $a, $b ) { $GLOBALS[ $a ] = $b; diff --git a/tests/phpunit/tests/admin/includesFile.php b/tests/phpunit/tests/admin/includesFile.php index 6a47bc0abd..9ac46ad333 100644 --- a/tests/phpunit/tests/admin/includesFile.php +++ b/tests/phpunit/tests/admin/includesFile.php @@ -11,7 +11,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { * * @covers ::get_home_path */ - function test_get_home_path() { + public function test_get_home_path() { $home = get_option( 'home' ); $siteurl = get_option( 'siteurl' ); $sfn = $_SERVER['SCRIPT_FILENAME']; diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index 7542db6b59..9a3b4e5cd9 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -12,7 +12,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { self::_restore_mu_plugins(); } - function test_get_plugin_data() { + public function test_get_plugin_data() { $data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' ); $default_headers = array( @@ -35,7 +35,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { } } - function test_menu_page_url() { + public function test_menu_page_url() { $current_user = get_current_user_id(); wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); update_option( 'siteurl', 'http://example.com' ); @@ -77,7 +77,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { * * @dataProvider data_submenu_position */ - function test_submenu_position( $position, $expected_position ) { + public function test_submenu_position( $position, $expected_position ) { global $submenu; global $menu; $current_user = get_current_user_id(); @@ -125,7 +125,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { * * @dataProvider data_submenu_position */ - function test_submenu_helpers_position( $position, $expected_position ) { + public function test_submenu_helpers_position( $position, $expected_position ) { global $submenu; global $menu; @@ -227,7 +227,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { * } * } */ - function submenus_to_add() { + private function submenus_to_add() { return array( array( 'Submenu Position', 'Submenu Position', 'manage_options', 'sub-page', '' ), array( 'Submenu Position 2', 'Submenu Position 2', 'manage_options', 'sub-page2', '' ), @@ -249,7 +249,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { * } * } */ - function data_submenu_position() { + public function data_submenu_position() { $menu_count = count( $this->submenus_to_add() ); return array( array( null, $menu_count ), // Insert at the end of the menu if null is passed. Default behavior. @@ -268,7 +268,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { * * @ticket 48599 */ - function test_position_when_parent_slug_child_slug_are_the_same() { + public function test_position_when_parent_slug_child_slug_are_the_same() { global $submenu, $menu; // Reset menus. @@ -300,7 +300,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { * * @ticket 48599 */ - function test_passing_string_as_position_fires_doing_it_wrong() { + public function test_passing_string_as_position_fires_doing_it_wrong() { $this->setExpectedIncorrectUsage( 'add_submenu_page' ); global $submenu, $menu; @@ -324,7 +324,7 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { $this->assertSame( 'submenu_page_1', $submenu['main_slug'][1][2] ); } - function test_is_plugin_active_true() { + public function test_is_plugin_active_true() { activate_plugin( 'hello.php' ); $test = is_plugin_active( 'hello.php' ); $this->assertTrue( $test ); @@ -332,19 +332,19 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { deactivate_plugins( 'hello.php' ); } - function test_is_plugin_active_false() { + public function test_is_plugin_active_false() { deactivate_plugins( 'hello.php' ); $test = is_plugin_active( 'hello.php' ); $this->assertFalse( $test ); } - function test_is_plugin_inactive_true() { + public function test_is_plugin_inactive_true() { deactivate_plugins( 'hello.php' ); $test = is_plugin_inactive( 'hello.php' ); $this->assertTrue( $test ); } - function test_is_plugin_inactive_false() { + public function test_is_plugin_inactive_false() { activate_plugin( 'hello.php' ); $test = is_plugin_inactive( 'hello.php' ); $this->assertFalse( $test ); diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php index 02c40d9071..5f3ec7451d 100644 --- a/tests/phpunit/tests/admin/includesPost.php +++ b/tests/phpunit/tests/admin/includesPost.php @@ -26,7 +26,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase { self::$post_id = $factory->post->create(); } - function test__wp_translate_postdata_cap_checks_contributor() { + public function test__wp_translate_postdata_cap_checks_contributor() { wp_set_current_user( self::$contributor_id ); // Create new draft post. @@ -76,7 +76,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase { $this->assertSame( 'Sorry, you are not allowed to edit posts as this user.', $_results->get_error_message() ); } - function test__wp_translate_postdata_cap_checks_editor() { + public function test__wp_translate_postdata_cap_checks_editor() { wp_set_current_user( self::$editor_id ); // Create new draft post. @@ -131,7 +131,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase { * * @ticket 25272 */ - function test_edit_post_auto_draft() { + public function test_edit_post_auto_draft() { wp_set_current_user( self::$editor_id ); $post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); $this->assertSame( 'auto-draft', $post->post_status ); @@ -789,7 +789,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase { $this->assertSame( $p, post_exists( $title, $content, $date ) ); } - function test_use_block_editor_for_post() { + public function test_use_block_editor_for_post() { $this->assertFalse( use_block_editor_for_post( -1 ) ); $bogus_post_id = $this->factory()->post->create( array( @@ -822,7 +822,7 @@ class Tests_Admin_IncludesPost extends WP_UnitTestCase { remove_filter( 'use_block_editor_for_post', '__return_true' ); } - function test_get_block_editor_server_block_settings() { + public function test_get_block_editor_server_block_settings() { $name = 'core/test'; $settings = array( 'icon' => 'text', diff --git a/tests/phpunit/tests/admin/includesSchema.php b/tests/phpunit/tests/admin/includesSchema.php index fb19c716b4..ea392e41c3 100644 --- a/tests/phpunit/tests/admin/includesSchema.php +++ b/tests/phpunit/tests/admin/includesSchema.php @@ -91,7 +91,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase { * @ticket 44893 * @dataProvider data_populate_options */ - function test_populate_options( $options, $expected ) { + public function test_populate_options( $options, $expected ) { global $wpdb; $orig_options = $wpdb->options; @@ -183,7 +183,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase { * @group ms-required * @dataProvider data_populate_site_meta */ - function test_populate_site_meta( $meta, $expected ) { + public function test_populate_site_meta( $meta, $expected ) { global $wpdb; $orig_blogmeta = $wpdb->blogmeta; @@ -227,7 +227,7 @@ class Tests_Admin_IncludesSchema extends WP_UnitTestCase { * @group multisite * @dataProvider data_populate_network_meta */ - function test_populate_network_meta( $meta, $expected ) { + public function test_populate_network_meta( $meta, $expected ) { global $wpdb; $orig_sitemeta = $wpdb->sitemeta; diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index c52e6f1597..a5750fd5bd 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -155,12 +155,12 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { ), ); - function tear_down() { + public function tear_down() { unset( $GLOBALS['wp_taxonomies']['old-or-new'] ); parent::tear_down(); } - function test_set_current_screen_with_hook_suffix() { + public function test_set_current_screen_with_hook_suffix() { global $current_screen; foreach ( $this->core_screens as $hook_name => $screen ) { @@ -228,7 +228,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { } } - function test_post_type_as_hookname() { + public function test_post_type_as_hookname() { $screen = convert_to_screen( 'page' ); $this->assertSame( $screen->post_type, 'page' ); $this->assertSame( $screen->base, 'post' ); @@ -236,7 +236,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { $this->assertTrue( $screen->is_block_editor ); } - function test_post_type_with_special_suffix_as_hookname() { + public function test_post_type_with_special_suffix_as_hookname() { register_post_type( 'value-add' ); $screen = convert_to_screen( 'value-add' ); // The '-add' part is key. $this->assertSame( $screen->post_type, 'value-add' ); @@ -251,7 +251,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { $this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default. } - function test_taxonomy_with_special_suffix_as_hookname() { + public function test_taxonomy_with_special_suffix_as_hookname() { register_taxonomy( 'old-or-new', 'post' ); $screen = convert_to_screen( 'edit-old-or-new' ); // The '-new' part is key. $this->assertSame( $screen->taxonomy, 'old-or-new' ); @@ -260,7 +260,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { $this->assertFalse( $screen->is_block_editor ); } - function test_post_type_with_edit_prefix() { + public function test_post_type_with_edit_prefix() { register_post_type( 'edit-some-thing' ); $screen = convert_to_screen( 'edit-some-thing' ); $this->assertSame( $screen->post_type, 'edit-some-thing' ); @@ -275,7 +275,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { $this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default. } - function test_post_type_edit_collisions() { + public function test_post_type_edit_collisions() { register_post_type( 'comments' ); register_post_type( 'tags' ); @@ -295,7 +295,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { $this->assertSame( $screen->base, 'post' ); } - function test_help_tabs() { + public function test_help_tabs() { $tab = __FUNCTION__; $tab_args = array( 'title' => 'Help!', @@ -331,7 +331,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { /** * @ticket 19828 */ - function test_help_tabs_priority() { + public function test_help_tabs_priority() { $tab_1 = 'tab1'; $tab_1_args = array( 'title' => 'Help!', @@ -427,7 +427,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { /** * @ticket 25799 */ - function test_options() { + public function test_options() { $option = __FUNCTION__; $option_args = array( 'label' => 'Option', @@ -451,7 +451,7 @@ class Tests_Admin_IncludesScreen extends WP_UnitTestCase { $this->assertSame( $screen->get_options(), array() ); } - function test_in_admin() { + public function test_in_admin() { set_current_screen( 'edit.php' ); $this->assertTrue( get_current_screen()->in_admin() ); $this->assertTrue( get_current_screen()->in_admin( 'site' ) ); diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 1cb39e6832..8208d3fcfa 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -4,27 +4,27 @@ */ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); $this->theme_root = DIR_TESTDATA . '/themedir1'; $this->orig_theme_dir = $GLOBALS['wp_theme_directories']; $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root ); - add_filter( 'theme_root', array( $this, '_theme_root' ) ); - add_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); - add_filter( 'template_root', array( $this, '_theme_root' ) ); + add_filter( 'theme_root', array( $this, 'filter_theme_root' ) ); + add_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) ); + add_filter( 'template_root', array( $this, 'filter_theme_root' ) ); // Clear caches. wp_clean_themes_cache(); unset( $GLOBALS['wp_themes'] ); } - function tear_down() { + public function tear_down() { $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir; - remove_filter( 'theme_root', array( $this, '_theme_root' ) ); - remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) ); - remove_filter( 'template_root', array( $this, '_theme_root' ) ); + remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) ); + remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) ); + remove_filter( 'template_root', array( $this, 'filter_theme_root' ) ); wp_clean_themes_cache(); unset( $GLOBALS['wp_themes'] ); @@ -32,7 +32,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { } // Replace the normal theme root directory with our premade test directory. - function _theme_root( $dir ) { + public function filter_theme_root( $dir ) { return $this->theme_root; } @@ -42,7 +42,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { * @expectedDeprecated get_theme * @expectedDeprecated get_themes */ - function test_page_templates() { + public function test_page_templates() { $theme = get_theme( 'Page Template Theme' ); $this->assertNotEmpty( $theme ); @@ -75,7 +75,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { /** * @ticket 18375 */ - function test_page_templates_different_post_types() { + public function test_page_templates_different_post_types() { $theme = wp_get_theme( 'page-templates' ); $this->assertNotEmpty( $theme ); @@ -101,7 +101,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { /** * @ticket 38766 */ - function test_page_templates_for_post_types_with_trailing_periods() { + public function test_page_templates_for_post_types_with_trailing_periods() { $theme = wp_get_theme( 'page-templates' ); $this->assertNotEmpty( $theme ); @@ -133,7 +133,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { /** * @ticket 38696 */ - function test_page_templates_child_theme() { + public function test_page_templates_child_theme() { $theme = wp_get_theme( 'page-templates-child' ); $this->assertNotEmpty( $theme ); @@ -216,7 +216,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { * @group external-http * @ticket 28121 */ - function test_get_theme_featured_list_api() { + public function test_get_theme_featured_list_api() { wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); $featured_list_api = get_theme_feature_list( true ); $this->assertNonEmptyMultidimensionalArray( $featured_list_api ); @@ -230,7 +230,7 @@ class Tests_Admin_IncludesTheme extends WP_UnitTestCase { * @group external-http * @ticket 28121 */ - function test_get_theme_featured_list_hardcoded() { + public function test_get_theme_featured_list_hardcoded() { $featured_list_hardcoded = get_theme_feature_list( false ); $this->assertNonEmptyMultidimensionalArray( $featured_list_hardcoded ); } diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index 539a7a9f76..24ace35da4 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -32,7 +32,7 @@ class Tests_AdminBar extends WP_UnitTestCase { /** * @ticket 21117 */ - function test_content_post_type() { + public function test_content_post_type() { wp_set_current_user( self::$editor_id ); register_post_type( 'content', array( 'show_in_admin_bar' => true ) ); @@ -51,7 +51,7 @@ class Tests_AdminBar extends WP_UnitTestCase { /** * @ticket 21117 */ - function test_merging_existing_meta_values() { + public function test_merging_existing_meta_values() { wp_set_current_user( self::$editor_id ); $admin_bar = new WP_Admin_Bar; diff --git a/tests/phpunit/tests/ajax/CustomizeManager.php b/tests/phpunit/tests/ajax/CustomizeManager.php index cc36aaeff7..16a029c4f4 100644 --- a/tests/phpunit/tests/ajax/CustomizeManager.php +++ b/tests/phpunit/tests/ajax/CustomizeManager.php @@ -94,7 +94,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { * @param array $allcaps An array of all the user's capabilities. * @return array All caps. */ - function filter_user_has_cap( $allcaps ) { + public function filter_user_has_cap( $allcaps ) { $allcaps = array_merge( $allcaps, $this->overridden_caps ); return $allcaps; } @@ -105,7 +105,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::save */ - function test_save_failures() { + public function test_save_failures() { global $wp_customize; $wp_customize = new WP_Customize_Manager(); $wp_customize->register_controls(); @@ -272,7 +272,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::save */ - function test_save_success_publish_create() { + public function test_save_success_publish_create() { $wp_customize = $this->set_up_valid_state(); $_POST['customize_changeset_status'] = 'publish'; @@ -301,7 +301,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::save */ - function test_save_success_publish_edit() { + public function test_save_success_publish_edit() { $uuid = wp_generate_uuid4(); $post_id = $this->factory()->post->create( @@ -340,7 +340,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { * @ticket 38943 * @covers WP_Customize_Manager::save */ - function test_success_save_post_date() { + public function test_success_save_post_date() { $uuid = wp_generate_uuid4(); $post_id = $this->factory()->post->create( array( diff --git a/tests/phpunit/tests/ajax/CustomizeMenus.php b/tests/phpunit/tests/ajax/CustomizeMenus.php index 677ee423a9..7acc29ae80 100644 --- a/tests/phpunit/tests/ajax/CustomizeMenus.php +++ b/tests/phpunit/tests/ajax/CustomizeMenus.php @@ -80,7 +80,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * @param string $role The role we're checking caps against. * @param array $expected_results Expected results. */ - function test_ajax_load_available_items_cap_check( $role, $expected_results ) { + public function test_ajax_load_available_items_cap_check( $role, $expected_results ) { if ( 'administrator' !== $role ) { // If we're not an admin, we should get a wp_die( -1 ). @@ -122,7 +122,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * } * } */ - function data_ajax_load_available_items_cap_check() { + public function data_ajax_load_available_items_cap_check() { return array( array( 'subscriber', @@ -158,7 +158,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * @param array $post_args POST args. * @param mixed $expected_results Expected results. */ - function test_ajax_load_available_items_error_messages( $post_args, $expected_results ) { + public function test_ajax_load_available_items_error_messages( $post_args, $expected_results ) { $_POST = array_merge( array( @@ -192,7 +192,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * } * } */ - function data_ajax_load_available_items_error_messages() { + public function data_ajax_load_available_items_error_messages() { return array( // Testing empty obj_type and type. array( @@ -268,7 +268,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * @param array $post_args POST args. * @param array $success_status Success status. */ - function test_ajax_load_available_items_success_status( $post_args, $success_status ) { + public function test_ajax_load_available_items_success_status( $post_args, $success_status ) { $_POST = array_merge( array( @@ -302,7 +302,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * } * } */ - function data_ajax_load_available_items_success_status() { + public function data_ajax_load_available_items_success_status() { return array( array( array( @@ -358,7 +358,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * * @param array $post_args POST args. */ - function test2_ajax_load_available_items_structure( $post_args ) { + public function test2_ajax_load_available_items_structure( $post_args ) { do_action( 'customize_register', $this->wp_customize ); $expected_keys = array( @@ -436,7 +436,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * } * } */ - function data_ajax_load_available_items_structure() { + public function data_ajax_load_available_items_structure() { return array( array( array( @@ -467,7 +467,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * @param string $role Role. * @param array $expected_results Expected results. */ - function test_ajax_search_available_items_caps_check( $role, $expected_results ) { + public function test_ajax_search_available_items_caps_check( $role, $expected_results ) { if ( 'administrator' !== $role ) { // If we're not an admin, we should get a wp_die( -1 ). @@ -510,7 +510,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * } * } */ - function data_ajax_search_available_items_caps_check() { + public function data_ajax_search_available_items_caps_check() { return array( array( 'subscriber', @@ -546,7 +546,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * @param array $post_args POST args. * @param array $expected_results Expected results. */ - function test_ajax_search_available_items_results( $post_args, $expected_results ) { + public function test_ajax_search_available_items_results( $post_args, $expected_results ) { do_action( 'customize_register', $this->wp_customize ); self::factory()->post->create_many( 5, array( 'post_title' => 'Test Post' ) ); @@ -602,7 +602,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * } * } */ - function data_ajax_search_available_items_results() { + public function data_ajax_search_available_items_results() { return array( array( array(), @@ -639,7 +639,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * * @covers WP_Customize_Nav_Menus::ajax_insert_auto_draft_post */ - function test_ajax_insert_auto_draft_post_success() { + public function test_ajax_insert_auto_draft_post_success() { $_POST = wp_slash( array( 'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ), @@ -669,7 +669,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { * * @covers WP_Customize_Nav_Menus::ajax_insert_auto_draft_post */ - function test_ajax_insert_auto_draft_failures() { + public function test_ajax_insert_auto_draft_failures() { // No nonce. $_POST = array(); $this->_last_response = ''; diff --git a/tests/phpunit/tests/ajax/EditComment.php b/tests/phpunit/tests/ajax/EditComment.php index 727372b0e4..d5b569d388 100644 --- a/tests/phpunit/tests/ajax/EditComment.php +++ b/tests/phpunit/tests/ajax/EditComment.php @@ -80,7 +80,7 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { /** * @ticket 33154 */ - function test_editor_can_edit_orphan_comments() { + public function test_editor_can_edit_orphan_comments() { global $wpdb; // Become an editor. diff --git a/tests/phpunit/tests/ajax/ManageThemes.php b/tests/phpunit/tests/ajax/ManageThemes.php index 89f2a9f978..015c140d83 100644 --- a/tests/phpunit/tests/ajax/ManageThemes.php +++ b/tests/phpunit/tests/ajax/ManageThemes.php @@ -13,7 +13,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase { private $orig_theme_dir; private $theme_root; - function set_up() { + public function set_up() { parent::set_up(); $this->theme_root = DIR_TESTDATA . '/themedir1'; @@ -30,7 +30,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase { unset( $GLOBALS['wp_themes'] ); } - function tear_down() { + public function tear_down() { $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir; remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) ); remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) ); @@ -144,7 +144,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase { /** * @group ms-excluded */ - function test_uppercase_theme_slug() { + public function test_uppercase_theme_slug() { $this->_setRole( 'administrator' ); $_POST['_ajax_nonce'] = wp_create_nonce( 'updates' ); diff --git a/tests/phpunit/tests/ajax/ReplytoComment.php b/tests/phpunit/tests/ajax/ReplytoComment.php index 4931a51380..0d98a98a39 100644 --- a/tests/phpunit/tests/ajax/ReplytoComment.php +++ b/tests/phpunit/tests/ajax/ReplytoComment.php @@ -264,7 +264,7 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { /** * Blocks comments from being saved on 'pre_comment_approved', by returning WP_Error. */ - function _pre_comment_approved_filter( $approved, $commentdata ) { + public function _pre_comment_approved_filter( $approved, $commentdata ) { return new WP_Error( 'comment_wrong', 'pre_comment_approved filter fails for new comment.', 403 ); } } diff --git a/tests/phpunit/tests/attachment/slashes.php b/tests/phpunit/tests/attachment/slashes.php index 70bf9466a8..8cb7c48487 100644 --- a/tests/phpunit/tests/attachment/slashes.php +++ b/tests/phpunit/tests/attachment/slashes.php @@ -12,7 +12,7 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase { self::$author_id = $factory->user->create( array( 'role' => 'editor' ) ); } - function set_up() { + public function set_up() { parent::set_up(); wp_set_current_user( self::$author_id ); @@ -31,7 +31,7 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. */ - function test_wp_insert_attachment() { + public function test_wp_insert_attachment() { $post_id = wp_insert_attachment( array( 'post_status' => 'publish', diff --git a/tests/phpunit/tests/auth.php b/tests/phpunit/tests/auth.php index 2db8818de7..3567a8bba5 100644 --- a/tests/phpunit/tests/auth.php +++ b/tests/phpunit/tests/auth.php @@ -32,7 +32,7 @@ class Tests_Auth extends WP_UnitTestCase { self::$wp_hasher = new PasswordHash( 8, true ); } - function set_up() { + public function set_up() { parent::set_up(); $this->user = clone self::$_user; @@ -49,12 +49,12 @@ class Tests_Auth extends WP_UnitTestCase { parent::tear_down(); } - function test_auth_cookie_valid() { + public function test_auth_cookie_valid() { $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' ); $this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) ); } - function test_auth_cookie_invalid() { + public function test_auth_cookie_invalid() { // 3600 or less and +3600 may occur in wp_validate_auth_cookie(), // as an ajax test may have defined DOING_AJAX, failing the test. @@ -70,7 +70,7 @@ class Tests_Auth extends WP_UnitTestCase { $this->assertFalse( wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' ); } - function test_auth_cookie_scheme() { + public function test_auth_cookie_scheme() { // Arbitrary scheme name. $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); $this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) ); @@ -83,7 +83,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 23494 */ - function test_password_trimming() { + public function test_password_trimming() { $passwords_to_test = array( 'a password with no trailing or leading spaces', 'a password with trailing spaces ', @@ -108,7 +108,7 @@ class Tests_Auth extends WP_UnitTestCase { * * @ticket 24973 */ - function test_wp_hash_password_trimming() { + public function test_wp_hash_password_trimming() { $password = ' pass with leading whitespace'; $this->assertTrue( wp_check_password( 'pass with leading whitespace', wp_hash_password( $password ) ) ); @@ -129,7 +129,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 29217 */ - function test_wp_verify_nonce_with_empty_arg() { + public function test_wp_verify_nonce_with_empty_arg() { $this->assertFalse( wp_verify_nonce( '' ) ); $this->assertFalse( wp_verify_nonce( null ) ); } @@ -137,14 +137,14 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 29542 */ - function test_wp_verify_nonce_with_integer_arg() { + public function test_wp_verify_nonce_with_integer_arg() { $this->assertFalse( wp_verify_nonce( 1 ) ); } /** * @ticket 24030 */ - function test_wp_nonce_verify_failed() { + public function test_wp_nonce_verify_failed() { $nonce = substr( md5( uniqid() ), 0, 10 ); $count = did_action( $this->nonce_failure_hook ); @@ -156,7 +156,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 24030 */ - function test_wp_nonce_verify_success() { + public function test_wp_nonce_verify_success() { $nonce = wp_create_nonce( 'nonce_test_action' ); $count = did_action( $this->nonce_failure_hook ); @@ -202,7 +202,7 @@ class Tests_Auth extends WP_UnitTestCase { unset( $_REQUEST['_wpnonce'] ); } - function test_password_length_limit() { + public function test_password_length_limit() { $limit = str_repeat( 'a', 4096 ); wp_set_password( $limit, self::$user_id ); @@ -252,7 +252,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 45746 */ - function test_user_activation_key_is_saved() { + public function test_user_activation_key_is_saved() { $user = get_userdata( $this->user->ID ); $key = get_password_reset_key( $user ); @@ -266,7 +266,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 32429 */ - function test_user_activation_key_is_checked() { + public function test_user_activation_key_is_checked() { global $wpdb; $key = wp_generate_password( 20, false ); @@ -304,7 +304,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 32429 */ - function test_expired_user_activation_key_is_rejected() { + public function test_expired_user_activation_key_is_rejected() { global $wpdb; $key = wp_generate_password( 20, false ); @@ -327,7 +327,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 32429 */ - function test_empty_user_activation_key_fails_key_check() { + public function test_empty_user_activation_key_fails_key_check() { // An empty user_activation_key should not allow any key to be accepted. $check = check_password_reset_key( 'key', $this->user->user_login ); $this->assertInstanceOf( 'WP_Error', $check ); @@ -340,7 +340,7 @@ class Tests_Auth extends WP_UnitTestCase { /** * @ticket 32429 */ - function test_legacy_user_activation_key_is_rejected() { + public function test_legacy_user_activation_key_is_rejected() { global $wpdb; // A legacy user_activation_key is one without the `time()` prefix introduced in WordPress 4.3. @@ -370,7 +370,7 @@ class Tests_Auth extends WP_UnitTestCase { * @ticket 32429 * @ticket 24783 */ - function test_plaintext_user_activation_key_is_rejected() { + public function test_plaintext_user_activation_key_is_rejected() { global $wpdb; // A plaintext user_activation_key is one stored before hashing was introduced in WordPress 3.7. diff --git a/tests/phpunit/tests/basic.php b/tests/phpunit/tests/basic.php index 47b807d241..5ffd6b2470 100644 --- a/tests/phpunit/tests/basic.php +++ b/tests/phpunit/tests/basic.php @@ -7,7 +7,7 @@ */ class Tests_Basic extends WP_UnitTestCase { - function test_license() { + public function test_license() { // This test is designed to only run on trunk/master. $this->skipOnAutomatedBranches(); @@ -17,7 +17,7 @@ class Tests_Basic extends WP_UnitTestCase { $this->assertSame( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." ); } - function test_security_md() { + public function test_security_md() { // This test is designed to only run on trunk/master. $this->skipOnAutomatedBranches(); @@ -28,7 +28,7 @@ class Tests_Basic extends WP_UnitTestCase { $this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." ); } - function test_package_json() { + public function test_package_json() { $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' ); $package_json = json_decode( $package_json, true ); list( $version ) = explode( '-', $GLOBALS['wp_version'] ); @@ -43,14 +43,14 @@ class Tests_Basic extends WP_UnitTestCase { /** * @depends test_package_json */ - function test_package_json_node_engine( $package_json ) { + public function test_package_json_node_engine( $package_json ) { $this->assertArrayHasKey( 'engines', $package_json ); $this->assertArrayHasKey( 'node', $package_json['engines'] ); } // Test some helper utility functions. - function test_strip_ws() { + public function test_strip_ws() { $this->assertSame( '', strip_ws( '' ) ); $this->assertSame( 'foo', strip_ws( 'foo' ) ); $this->assertSame( '', strip_ws( "\r\n\t \n\r\t" ) ); @@ -77,7 +77,7 @@ class Tests_Basic extends WP_UnitTestCase { } - function test_mask_input_value() { + public function test_mask_input_value() { $in = <<Assign Authors

To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as admins entries.

diff --git a/tests/phpunit/tests/block-template-utils.php b/tests/phpunit/tests/block-template-utils.php index c52c25a99f..a6242de614 100644 --- a/tests/phpunit/tests/block-template-utils.php +++ b/tests/phpunit/tests/block-template-utils.php @@ -33,7 +33,7 @@ class Block_Template_Utils_Test extends WP_UnitTestCase { wp_delete_post( self::$post->ID ); } - function test_build_template_result_from_post() { + public function test_build_template_result_from_post() { $template = _build_template_result_from_post( self::$post, 'wp_template' @@ -53,7 +53,7 @@ class Block_Template_Utils_Test extends WP_UnitTestCase { /** * Should retrieve the template from the CPT. */ - function test_get_block_template_from_post() { + public function test_get_block_template_from_post() { $id = get_stylesheet() . '//' . 'my_template'; $template = get_block_template( $id, 'wp_template' ); $this->assertSame( $id, $template->id ); @@ -67,7 +67,7 @@ class Block_Template_Utils_Test extends WP_UnitTestCase { /** * Should retrieve block templates. */ - function test_get_block_templates() { + public function test_get_block_templates() { function get_template_ids( $templates ) { return array_map( static function( $template ) { diff --git a/tests/phpunit/tests/block-template.php b/tests/phpunit/tests/block-template.php index 3830b7fee4..5b475567bd 100644 --- a/tests/phpunit/tests/block-template.php +++ b/tests/phpunit/tests/block-template.php @@ -43,7 +43,7 @@ class Block_Template_Test extends WP_UnitTestCase { /** * Regression: https://github.com/WordPress/gutenberg/issues/31399. */ - function test_custom_page_php_template_takes_precedence_over_all_other_templates() { + public function test_custom_page_php_template_takes_precedence_over_all_other_templates() { $custom_page_template = 'templates/full-width.php'; $custom_page_template_path = get_stylesheet_directory() . '/' . $custom_page_template; $type = 'page'; @@ -60,7 +60,7 @@ class Block_Template_Test extends WP_UnitTestCase { /** * Covers: https://github.com/WordPress/gutenberg/pull/30438. */ - function test_custom_page_block_template_takes_precedence_over_all_other_templates() { + public function test_custom_page_block_template_takes_precedence_over_all_other_templates() { global $_wp_current_template_content; $custom_page_block_template = 'wp-custom-template-my-block-template'; @@ -80,7 +80,7 @@ class Block_Template_Test extends WP_UnitTestCase { /** * Regression: https://github.com/WordPress/gutenberg/issues/31652. */ - function test_template_remains_unchanged_if_templates_array_is_empty() { + public function test_template_remains_unchanged_if_templates_array_is_empty() { $resolved_template_path = locate_block_template( '', 'search', array() ); $this->assertSame( '', $resolved_template_path ); } diff --git a/tests/phpunit/tests/blocks/context.php b/tests/phpunit/tests/blocks/context.php index f39b378c65..d1b321ab51 100644 --- a/tests/phpunit/tests/blocks/context.php +++ b/tests/phpunit/tests/blocks/context.php @@ -77,7 +77,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase { * * @ticket 49927 */ - function test_provides_block_context() { + public function test_provides_block_context() { $provided_context = array(); $this->register_block_type( @@ -146,7 +146,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase { * * @ticket 49927 */ - function test_provides_default_context() { + public function test_provides_default_context() { global $post; $provided_context = array(); @@ -181,7 +181,7 @@ class Tests_Blocks_Context extends WP_UnitTestCase { * * @ticket 49927 */ - function test_default_context_is_filterable() { + public function test_default_context_is_filterable() { $provided_context = array(); $this->register_block_type( diff --git a/tests/phpunit/tests/blocks/editor.php b/tests/phpunit/tests/blocks/editor.php index a1f43f3010..410f6777ed 100644 --- a/tests/phpunit/tests/blocks/editor.php +++ b/tests/phpunit/tests/blocks/editor.php @@ -42,7 +42,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { parent::tear_down(); } - function filter_set_block_categories_post( $block_categories, $post ) { + public function filter_set_block_categories_post( $block_categories, $post ) { if ( empty( $post ) ) { return $block_categories; } @@ -56,7 +56,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { ); } - function filter_set_allowed_block_types_post( $allowed_block_types, $post ) { + public function filter_set_allowed_block_types_post( $allowed_block_types, $post ) { if ( empty( $post ) ) { return $allowed_block_types; } @@ -64,7 +64,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { return array( 'test/filtered-block' ); } - function filter_set_block_editor_settings_post( $editor_settings, $post ) { + public function filter_set_block_editor_settings_post( $editor_settings, $post ) { if ( empty( $post ) ) { return $allowed_block_types; } @@ -77,7 +77,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_block_editor_context_no_settings() { + public function test_block_editor_context_no_settings() { $context = new WP_Block_Editor_Context(); $this->assertNull( $context->post ); @@ -86,7 +86,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_block_editor_context_post() { + public function test_block_editor_context_post() { $context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); $this->assertSame( get_post(), $context->post ); @@ -96,7 +96,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { * @ticket 52920 * @expectedDeprecated block_categories */ - function test_get_block_categories_deprecated_filter_post_object() { + public function test_get_block_categories_deprecated_filter_post_object() { add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 ); $block_categories = get_block_categories( get_post() ); @@ -119,7 +119,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { * @ticket 52920 * @expectedDeprecated block_categories */ - function test_get_block_categories_deprecated_filter_post_editor() { + public function test_get_block_categories_deprecated_filter_post_editor() { add_filter( 'block_categories', array( $this, 'filter_set_block_categories_post' ), 10, 2 ); $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); @@ -142,7 +142,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_get_allowed_block_types_default() { + public function test_get_allowed_block_types_default() { $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); $allowed_block_types = get_allowed_block_types( $post_editor_context ); @@ -153,7 +153,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { * @ticket 52920 * @expectedDeprecated allowed_block_types */ - function test_get_allowed_block_types_deprecated_filter_post_editor() { + public function test_get_allowed_block_types_deprecated_filter_post_editor() { add_filter( 'allowed_block_types', array( $this, 'filter_set_allowed_block_types_post' ), 10, 2 ); $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); @@ -167,7 +167,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_get_default_block_editor_settings() { + public function test_get_default_block_editor_settings() { $settings = get_default_block_editor_settings(); $this->assertCount( 16, $settings ); @@ -270,7 +270,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 53397 */ - function test_get_legacy_widget_block_editor_settings() { + public function test_get_legacy_widget_block_editor_settings() { $settings = get_legacy_widget_block_editor_settings(); $this->assertCount( 1, $settings ); $this->assertSameSets( @@ -299,7 +299,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_get_block_editor_settings_overrides_default_settings_all_editors() { + public function test_get_block_editor_settings_overrides_default_settings_all_editors() { function filter_allowed_block_types_my_editor() { return array( 'test/filtered-my-block' ); } @@ -346,7 +346,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 53458 */ - function test_get_block_editor_settings_theme_json_settings() { + public function test_get_block_editor_settings_theme_json_settings() { switch_theme( 'block-theme' ); $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); @@ -411,7 +411,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { * @ticket 52920 * @expectedDeprecated block_editor_settings */ - function test_get_block_editor_settings_deprecated_filter_post_editor() { + public function test_get_block_editor_settings_deprecated_filter_post_editor() { add_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ), 10, 2 ); $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); @@ -430,7 +430,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_block_editor_rest_api_preload_no_paths() { + public function test_block_editor_rest_api_preload_no_paths() { $editor_context = new WP_Block_Editor_Context(); block_editor_rest_api_preload( array(), $editor_context ); @@ -442,7 +442,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { * @ticket 52920 * @expectedDeprecated block_editor_preload_paths */ - function test_block_editor_rest_api_preload_deprecated_filter_post_editor() { + public function test_block_editor_rest_api_preload_deprecated_filter_post_editor() { function filter_remove_preload_paths( $preload_paths, $post ) { if ( empty( $post ) ) { return $preload_paths; @@ -468,7 +468,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 52920 */ - function test_block_editor_rest_api_preload_filter_all() { + public function test_block_editor_rest_api_preload_filter_all() { function filter_add_preload_paths( $preload_paths, WP_Block_Editor_Context $context ) { if ( empty( $context->post ) ) { array_push( $preload_paths, array( '/wp/v2/types', 'OPTIONS' ) ); @@ -497,7 +497,7 @@ class Tests_Blocks_Editor extends WP_UnitTestCase { /** * @ticket 53344 */ - function test_get_block_editor_theme_styles() { + public function test_get_block_editor_theme_styles() { $theme_styles = get_block_editor_theme_styles(); $this->assertCount( 1, $theme_styles ); $this->assertSameSets( diff --git a/tests/phpunit/tests/blocks/register.php b/tests/phpunit/tests/blocks/register.php index ee98bca81b..18463671d4 100644 --- a/tests/phpunit/tests/blocks/register.php +++ b/tests/phpunit/tests/blocks/register.php @@ -50,14 +50,14 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * Empty render function for tests to use. */ - function render_stub() {} + public function render_stub() {} /** * Tear down after each test. * * @since 5.0.0 */ - function tear_down() { + public function tear_down() { $registry = WP_Block_Type_Registry::get_instance(); foreach ( array( 'core/test-static', 'core/test-dynamic', 'tests/notice' ) as $block_name ) { @@ -74,14 +74,14 @@ class Tests_Blocks_Register extends WP_UnitTestCase { * * @return string */ - function filter_set_locale_to_polish() { + public function filter_set_locale_to_polish() { return 'pl_PL'; } /** * @ticket 45109 */ - function test_register_affects_main_registry() { + public function test_register_affects_main_registry() { $name = 'core/test-static'; $settings = array( 'icon' => 'text', @@ -96,7 +96,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 45109 */ - function test_unregister_affects_main_registry() { + public function test_unregister_affects_main_registry() { $name = 'core/test-static'; $settings = array( 'icon' => 'text', @@ -112,7 +112,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_does_not_remove_block_asset_path_prefix() { + public function test_does_not_remove_block_asset_path_prefix() { $result = remove_block_asset_path_prefix( 'script-handle' ); $this->assertSame( 'script-handle', $result ); @@ -121,7 +121,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_removes_block_asset_path_prefix() { + public function test_removes_block_asset_path_prefix() { $result = remove_block_asset_path_prefix( 'file:./block.js' ); $this->assertSame( './block.js', $result ); @@ -130,7 +130,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_generate_block_asset_handle() { + public function test_generate_block_asset_handle() { $block_name = 'unit-tests/my-block'; $this->assertSame( @@ -158,7 +158,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50328 */ - function test_generate_block_asset_handle_core_block() { + public function test_generate_block_asset_handle_core_block() { $block_name = 'core/paragraph'; $this->assertSame( @@ -186,7 +186,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_field_not_found_register_block_script_handle() { + public function test_field_not_found_register_block_script_handle() { $result = register_block_script_handle( array(), 'script' ); $this->assertFalse( $result ); @@ -195,7 +195,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_empty_value_register_block_script_handle() { + public function test_empty_value_register_block_script_handle() { $metadata = array( 'script' => '' ); $result = register_block_script_handle( $metadata, 'script' ); @@ -206,7 +206,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { * @expectedIncorrectUsage register_block_script_handle * @ticket 50263 */ - function test_missing_asset_file_register_block_script_handle() { + public function test_missing_asset_file_register_block_script_handle() { $metadata = array( 'file' => __FILE__, 'name' => 'unit-tests/test-block', @@ -220,7 +220,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_handle_passed_register_block_script_handle() { + public function test_handle_passed_register_block_script_handle() { $metadata = array( 'editorScript' => 'test-script-handle', ); @@ -232,7 +232,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_success_register_block_script_handle() { + public function test_success_register_block_script_handle() { $metadata = array( 'file' => DIR_TESTDATA . '/blocks/notice/block.json', 'name' => 'unit-tests/test-block', @@ -246,7 +246,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_field_not_found_register_block_style_handle() { + public function test_field_not_found_register_block_style_handle() { $result = register_block_style_handle( array(), 'style' ); $this->assertFalse( $result ); @@ -255,7 +255,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_empty_value_found_register_block_style_handle() { + public function test_empty_value_found_register_block_style_handle() { $metadata = array( 'style' => '' ); $result = register_block_style_handle( $metadata, 'style' ); @@ -265,7 +265,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 50263 */ - function test_handle_passed_register_block_style_handle() { + public function test_handle_passed_register_block_style_handle() { $metadata = array( 'style' => 'test-style-handle', ); @@ -278,7 +278,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { * @ticket 50263 * @ticket 50328 */ - function test_success_register_block_style_handle() { + public function test_success_register_block_style_handle() { $metadata = array( 'file' => DIR_TESTDATA . '/blocks/notice/block.json', 'name' => 'unit-tests/test-block', @@ -302,7 +302,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { * * @ticket 50263 */ - function test_metadata_not_found_in_wordpress_core() { + public function test_metadata_not_found_in_wordpress_core() { $result = register_block_type_from_metadata( 'unknown' ); $this->assertFalse( $result ); @@ -314,7 +314,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { * * @ticket 50263 */ - function test_metadata_not_found_in_the_current_directory() { + public function test_metadata_not_found_in_the_current_directory() { $result = register_block_type_from_metadata( __DIR__ ); $this->assertFalse( $result ); @@ -327,7 +327,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { * @ticket 50263 * @ticket 50328 */ - function test_block_registers_with_metadata_fixture() { + public function test_block_registers_with_metadata_fixture() { $result = register_block_type_from_metadata( DIR_TESTDATA . '/blocks/notice' ); @@ -414,7 +414,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 53233 */ - function test_block_register_block_type_proxy_for_metadata() { + public function test_block_register_block_type_proxy_for_metadata() { $result = register_block_type( DIR_TESTDATA . '/blocks/notice' ); @@ -426,7 +426,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 52301 */ - function test_block_registers_with_metadata_i18n_support() { + public function test_block_registers_with_metadata_i18n_support() { add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) ); load_textdomain( 'notice', WP_LANG_DIR . '/plugins/notice-pl_PL.mo' ); @@ -472,7 +472,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 45109 */ - function test_get_dynamic_block_names() { + public function test_get_dynamic_block_names() { register_block_type( 'core/test-static', array() ); register_block_type( 'core/test-dynamic', array( 'render_callback' => array( $this, 'render_stub' ) ) ); @@ -485,7 +485,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase { /** * @ticket 45109 */ - function test_has_blocks() { + public function test_has_blocks() { // Test with passing post ID. $this->assertTrue( has_blocks( self::$post_id ) ); diff --git a/tests/phpunit/tests/blocks/render.php b/tests/phpunit/tests/blocks/render.php index 94f14b390b..373217bd74 100644 --- a/tests/phpunit/tests/blocks/render.php +++ b/tests/phpunit/tests/blocks/render.php @@ -83,14 +83,14 @@ class Tests_Blocks_Render extends WP_UnitTestCase { $this->assertSame( trim( $classic_filtered_content ), trim( $block_filtered_content ) ); } - function handle_shortcode( $atts, $content ) { + public function handle_shortcode( $atts, $content ) { return $content; } /** * @ticket 45495 */ - function test_nested_calls_to_the_content() { + public function test_nested_calls_to_the_content() { register_block_type( 'core/test', array( @@ -108,7 +108,7 @@ class Tests_Blocks_Render extends WP_UnitTestCase { $this->assertSame( $content, $the_content ); } - function dynamic_the_content_call( $attrs, $content ) { + public function dynamic_the_content_call( $attrs, $content ) { apply_filters( 'the_content', '' ); return $content; } diff --git a/tests/phpunit/tests/blocks/serialize.php b/tests/phpunit/tests/blocks/serialize.php index f7077b7c28..aa28f21209 100644 --- a/tests/phpunit/tests/blocks/serialize.php +++ b/tests/phpunit/tests/blocks/serialize.php @@ -19,7 +19,7 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase { /** * @dataProvider data_serialize_identity_from_parsed */ - function test_serialize_identity_from_parsed( $original ) { + public function test_serialize_identity_from_parsed( $original ) { $blocks = parse_blocks( $original ); $actual = serialize_blocks( $blocks ); @@ -28,7 +28,7 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase { $this->assertSame( $expected, $actual ); } - function data_serialize_identity_from_parsed() { + public function data_serialize_identity_from_parsed() { return array( // Void block. array( '' ), @@ -53,7 +53,7 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase { ); } - function test_serialized_block_name() { + public function test_serialized_block_name() { $this->assertNull( strip_core_block_namespace( null ) ); $this->assertSame( 'example', strip_core_block_namespace( 'example' ) ); $this->assertSame( 'example', strip_core_block_namespace( 'core/example' ) ); diff --git a/tests/phpunit/tests/blocks/wpBlock.php b/tests/phpunit/tests/blocks/wpBlock.php index 0545babd6a..eb3fd1b769 100644 --- a/tests/phpunit/tests/blocks/wpBlock.php +++ b/tests/phpunit/tests/blocks/wpBlock.php @@ -41,14 +41,14 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { parent::tear_down(); } - function filter_render_block( $content, $parsed_block ) { + public function filter_render_block( $content, $parsed_block ) { return 'Original: "' . $content . '", from block "' . $parsed_block['blockName'] . '"'; } /** * @ticket 49927 */ - function test_constructor_assigns_properties_from_parsed_block() { + public function test_constructor_assigns_properties_from_parsed_block() { $this->registry->register( 'core/example', array() ); $parsed_blocks = parse_blocks( 'ab' ); @@ -66,7 +66,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_constructor_assigns_block_type_from_registry() { + public function test_constructor_assigns_block_type_from_registry() { $block_type_settings = array( 'attributes' => array( 'defaulted' => array( @@ -91,7 +91,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_lazily_assigns_attributes_with_defaults() { + public function test_lazily_assigns_attributes_with_defaults() { $this->registry->register( 'core/example', array( @@ -125,7 +125,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_lazily_assigns_attributes_with_only_defaults() { + public function test_lazily_assigns_attributes_with_only_defaults() { $this->registry->register( 'core/example', array( @@ -153,7 +153,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_constructor_assigns_context_from_block_type() { + public function test_constructor_assigns_context_from_block_type() { $this->registry->register( 'core/example', array( @@ -174,7 +174,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_constructor_maps_inner_blocks() { + public function test_constructor_maps_inner_blocks() { $this->registry->register( 'core/example', array() ); $parsed_blocks = parse_blocks( 'ab' ); @@ -190,7 +190,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_constructor_prepares_context_for_inner_blocks() { + public function test_constructor_prepares_context_for_inner_blocks() { $this->registry->register( 'core/outer', array( @@ -226,7 +226,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_constructor_assigns_merged_context() { + public function test_constructor_assigns_merged_context() { $this->registry->register( 'core/example', array( @@ -270,7 +270,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_render_static_block_type_returns_own_content() { + public function test_render_static_block_type_returns_own_content() { $this->registry->register( 'core/static', array() ); $this->registry->register( 'core/dynamic', @@ -292,7 +292,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_render_passes_block_for_render_callback() { + public function test_render_passes_block_for_render_callback() { $this->registry->register( 'core/greeting', array( @@ -313,7 +313,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_render_applies_render_block_filter() { + public function test_render_applies_render_block_filter() { $this->registry->register( 'core/example', array() ); add_filter( 'render_block', array( $this, 'filter_render_block' ), 10, 2 ); @@ -333,7 +333,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 46187 */ - function test_render_applies_dynamic_render_block_filter() { + public function test_render_applies_dynamic_render_block_filter() { $this->registry->register( 'core/example', array() ); add_filter( 'render_block_core/example', array( $this, 'filter_render_block' ), 10, 2 ); @@ -353,7 +353,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_passes_attributes_to_render_callback() { + public function test_passes_attributes_to_render_callback() { $this->registry->register( 'core/greeting', array( @@ -387,7 +387,7 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_passes_content_to_render_callback() { + public function test_passes_content_to_render_callback() { $this->registry->register( 'core/outer', array( diff --git a/tests/phpunit/tests/blocks/wpBlockList.php b/tests/phpunit/tests/blocks/wpBlockList.php index 084778894e..e3755a9cd2 100644 --- a/tests/phpunit/tests/blocks/wpBlockList.php +++ b/tests/phpunit/tests/blocks/wpBlockList.php @@ -45,7 +45,7 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_array_access() { + public function test_array_access() { $parsed_blocks = parse_blocks( '' ); $context = array(); $blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry ); @@ -69,7 +69,7 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_iterable() { + public function test_iterable() { $parsed_blocks = parse_blocks( '' ); $context = array(); $blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry ); @@ -101,7 +101,7 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase { /** * @ticket 49927 */ - function test_countable() { + public function test_countable() { $parsed_blocks = parse_blocks( '' ); $context = array(); $blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry ); diff --git a/tests/phpunit/tests/blocks/wpBlockType.php b/tests/phpunit/tests/blocks/wpBlockType.php index e0c64df8db..a6d83be565 100644 --- a/tests/phpunit/tests/blocks/wpBlockType.php +++ b/tests/phpunit/tests/blocks/wpBlockType.php @@ -216,7 +216,7 @@ class Tests_Blocks_wpBlockType extends WP_UnitTestCase { /** * @ticket 45145 */ - function test_prepare_attributes_none_defined() { + public function test_prepare_attributes_none_defined() { $attributes = array( 'exists' => 'keep' ); $block_type = new WP_Block_Type( 'core/dummy', array() ); diff --git a/tests/phpunit/tests/cache.php b/tests/phpunit/tests/cache.php index 8ca5dd9de2..26f1264242 100644 --- a/tests/phpunit/tests/cache.php +++ b/tests/phpunit/tests/cache.php @@ -6,19 +6,19 @@ class Tests_Cache extends WP_UnitTestCase { public $cache = null; - function set_up() { + public function set_up() { parent::set_up(); // Create two cache objects with a shared cache directory. // This simulates a typical cache situation, two separate requests interacting. $this->cache =& $this->init_cache(); } - function tear_down() { + public function tear_down() { $this->flush_cache(); parent::tear_down(); } - function &init_cache() { + private function &init_cache() { global $wp_object_cache; $cache_class = get_class( $wp_object_cache ); $cache = new $cache_class(); @@ -26,11 +26,11 @@ class Tests_Cache extends WP_UnitTestCase { return $cache; } - function test_miss() { + public function test_miss() { $this->assertFalse( $this->cache->get( 'test_miss' ) ); } - function test_add_get() { + public function test_add_get() { $key = __FUNCTION__; $val = 'val'; @@ -38,7 +38,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( $val, $this->cache->get( $key ) ); } - function test_add_get_0() { + public function test_add_get_0() { $key = __FUNCTION__; $val = 0; @@ -50,7 +50,7 @@ class Tests_Cache extends WP_UnitTestCase { /** * @ticket 20004 */ - function test_add_get_null() { + public function test_add_get_null() { $key = __FUNCTION__; $val = null; @@ -62,7 +62,7 @@ class Tests_Cache extends WP_UnitTestCase { /** * @ticket 20004 */ - function test_add_get_false() { + public function test_add_get_false() { $key = __FUNCTION__; $val = false; @@ -71,7 +71,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( $val, $this->cache->get( $key ) ); } - function test_add() { + public function test_add() { $key = __FUNCTION__; $val1 = 'val1'; $val2 = 'val2'; @@ -84,7 +84,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( $val1, $this->cache->get( $key ) ); } - function test_replace() { + public function test_replace() { $key = __FUNCTION__; $val = 'val1'; $val2 = 'val2'; @@ -98,7 +98,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( $val2, $this->cache->get( $key ) ); } - function test_set() { + public function test_set() { $key = __FUNCTION__; $val1 = 'val1'; $val2 = 'val2'; @@ -111,7 +111,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( $val2, $this->cache->get( $key ) ); } - function test_flush() { + public function test_flush() { global $_wp_using_ext_object_cache; if ( $_wp_using_ext_object_cache ) { @@ -130,7 +130,7 @@ class Tests_Cache extends WP_UnitTestCase { } // Make sure objects are cloned going to and from the cache. - function test_object_refs() { + public function test_object_refs() { $key = __FUNCTION__ . '_1'; $object_a = new stdClass; $object_a->foo = 'alpha'; @@ -152,7 +152,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( 'bravo', $object_a->foo ); } - function test_incr() { + public function test_incr() { $key = __FUNCTION__; $this->assertFalse( $this->cache->incr( $key ) ); @@ -165,7 +165,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( 3, $this->cache->get( $key ) ); } - function test_wp_cache_incr() { + public function test_wp_cache_incr() { $key = __FUNCTION__; $this->assertFalse( wp_cache_incr( $key ) ); @@ -178,7 +178,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( 3, wp_cache_get( $key ) ); } - function test_decr() { + public function test_decr() { $key = __FUNCTION__; $this->assertFalse( $this->cache->decr( $key ) ); @@ -198,7 +198,7 @@ class Tests_Cache extends WP_UnitTestCase { /** * @ticket 21327 */ - function test_wp_cache_decr() { + public function test_wp_cache_decr() { $key = __FUNCTION__; $this->assertFalse( wp_cache_decr( $key ) ); @@ -215,7 +215,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( 0, wp_cache_get( $key ) ); } - function test_delete() { + public function test_delete() { $key = __FUNCTION__; $val = 'val'; @@ -230,7 +230,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertFalse( $this->cache->delete( $key, 'default' ) ); } - function test_wp_cache_delete() { + public function test_wp_cache_delete() { $key = __FUNCTION__; $val = 'val'; @@ -249,7 +249,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertFalse( wp_cache_delete( $key, 'default' ) ); } - function test_switch_to_blog() { + public function test_switch_to_blog() { if ( ! method_exists( $this->cache, 'switch_to_blog' ) ) { $this->markTestSkipped( 'This test requires a switch_to_blog() method on the cache object.' ); } @@ -295,7 +295,7 @@ class Tests_Cache extends WP_UnitTestCase { $this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) ); } - function test_wp_cache_init() { + public function test_wp_cache_init() { $new_blank_cache_object = new WP_Object_Cache(); wp_cache_init(); @@ -309,7 +309,7 @@ class Tests_Cache extends WP_UnitTestCase { } } - function test_wp_cache_replace() { + public function test_wp_cache_replace() { $key = 'my-key'; $val1 = 'first-val'; $val2 = 'second-val'; diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php index d5198ee558..93eed462fc 100644 --- a/tests/phpunit/tests/canonical.php +++ b/tests/phpunit/tests/canonical.php @@ -18,7 +18,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase { /** * @dataProvider data_canonical */ - function test_canonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { + public function test_canonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { if ( false !== strpos( $test_url, '%d' ) ) { if ( false !== strpos( $test_url, '/?author=%d' ) ) { @@ -32,7 +32,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase { $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - function data_canonical() { + public function data_canonical() { /* * Data format: * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/customRules.php b/tests/phpunit/tests/canonical/customRules.php index 332701f34b..b76f5d4879 100644 --- a/tests/phpunit/tests/canonical/customRules.php +++ b/tests/phpunit/tests/canonical/customRules.php @@ -7,7 +7,7 @@ */ class Tests_Canonical_CustomRules extends WP_Canonical_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); global $wp_rewrite; // Add a custom Rewrite rule to test category redirections. @@ -18,11 +18,11 @@ class Tests_Canonical_CustomRules extends WP_Canonical_UnitTestCase { /** * @dataProvider data */ - function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { + public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - function data() { + public function data() { /* * Data format: * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/https.php b/tests/phpunit/tests/canonical/https.php index 4b115e6167..257ee5cdb2 100644 --- a/tests/phpunit/tests/canonical/https.php +++ b/tests/phpunit/tests/canonical/https.php @@ -6,7 +6,7 @@ * @group query */ class Tests_Canonical_HTTPS extends WP_Canonical_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); diff --git a/tests/phpunit/tests/canonical/noRewrite.php b/tests/phpunit/tests/canonical/noRewrite.php index abc9bfbca7..53c6ca9b59 100644 --- a/tests/phpunit/tests/canonical/noRewrite.php +++ b/tests/phpunit/tests/canonical/noRewrite.php @@ -24,11 +24,11 @@ class Tests_Canonical_NoRewrite extends WP_Canonical_UnitTestCase { /** * @dataProvider data */ - function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { + public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - function data() { + public function data() { /* * Test URL. * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/pageOnFront.php b/tests/phpunit/tests/canonical/pageOnFront.php index 64058ab4fe..e8833dd660 100644 --- a/tests/phpunit/tests/canonical/pageOnFront.php +++ b/tests/phpunit/tests/canonical/pageOnFront.php @@ -7,7 +7,7 @@ */ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); update_option( 'show_on_front', 'page' ); @@ -35,11 +35,11 @@ class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase { /** * @dataProvider data */ - function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { + public function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { $this->assertCanonical( $test_url, $expected, $ticket, $expected_doing_it_wrong ); } - function data() { + public function data() { /* * Data format: * [0]: Test URL. diff --git a/tests/phpunit/tests/canonical/paged.php b/tests/phpunit/tests/canonical/paged.php index 27aef3622a..62786b28f9 100644 --- a/tests/phpunit/tests/canonical/paged.php +++ b/tests/phpunit/tests/canonical/paged.php @@ -6,7 +6,7 @@ */ class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase { - function test_redirect_canonical_with_nextpage_pagination() { + public function test_redirect_canonical_with_nextpage_pagination() { $para = 'This is a paragraph. This is a paragraph. This is a paragraph.'; diff --git a/tests/phpunit/tests/canonical/postStatus.php b/tests/phpunit/tests/canonical/postStatus.php index 391ec6b3e4..3e5ca9343a 100644 --- a/tests/phpunit/tests/canonical/postStatus.php +++ b/tests/phpunit/tests/canonical/postStatus.php @@ -166,7 +166,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { wp_trash_post( self::$posts['trash-page']->ID ); } - function set_up() { + public function set_up() { parent::set_up(); self::setup_custom_types(); } @@ -248,7 +248,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { * @type string $expected Expected URL. * } */ - function data_canonical_redirects_to_plain_permalinks() { + public function data_canonical_redirects_to_plain_permalinks() { $data = array(); $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' ); $select_allow_list = array( 'content_author', 'editor' ); @@ -584,7 +584,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { * @type string $expected Expected URL. * } */ - function data_canonical_redirects_to_pretty_permalinks() { + public function data_canonical_redirects_to_pretty_permalinks() { $data = array(); $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' ); $select_allow_list = array( 'content_author', 'editor' ); diff --git a/tests/phpunit/tests/category.php b/tests/phpunit/tests/category.php index 5b88f4117d..934c543876 100644 --- a/tests/phpunit/tests/category.php +++ b/tests/phpunit/tests/category.php @@ -9,7 +9,7 @@ */ class Tests_Category extends WP_UnitTestCase { - function tear_down() { + public function tear_down() { _unregister_taxonomy( 'test_tax_cat' ); parent::tear_down(); } @@ -19,7 +19,7 @@ class Tests_Category extends WP_UnitTestCase { * * @expectedDeprecated get_all_category_ids */ - function test_get_all_category_ids() { + public function test_get_all_category_ids() { // Ccreate categories. self::factory()->category->create_many( 2 ); @@ -35,7 +35,7 @@ class Tests_Category extends WP_UnitTestCase { /** * Validate get_category_by_slug function */ - function test_get_category_by_slug() { + public function test_get_category_by_slug() { // Create test categories. $testcat = self::factory()->category->create_and_get( @@ -65,7 +65,7 @@ class Tests_Category extends WP_UnitTestCase { /** * Validate _make_cat_compat function */ - function test__make_cat_compat() { + public function test__make_cat_compat() { // Create test categories and array representations. $testcat_array = array( @@ -142,7 +142,7 @@ class Tests_Category extends WP_UnitTestCase { /** * Validate get_cat_name function */ - function test_get_cat_name() { + public function test_get_cat_name() { // Create test category. $testcat = self::factory()->category->create_and_get( @@ -162,7 +162,7 @@ class Tests_Category extends WP_UnitTestCase { /** * Validate get_cat_name function */ - function test_get_cat_ID() { + public function test_get_cat_ID() { // Create test category. $testcat = self::factory()->category->create_and_get( @@ -182,7 +182,7 @@ class Tests_Category extends WP_UnitTestCase { /** * Validate get_category_by_path function */ - function test_get_category_by_path() { + public function test_get_category_by_path() { // Create test categories. $root_id = self::factory()->category->create( diff --git a/tests/phpunit/tests/comment-submission.php b/tests/phpunit/tests/comment-submission.php index 2cd5d8473a..26c4889926 100644 --- a/tests/phpunit/tests/comment-submission.php +++ b/tests/phpunit/tests/comment-submission.php @@ -34,7 +34,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase { self::delete_user( self::$editor_id ); } - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-phpass.php'; } diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index 56f55847c2..db21e79f10 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -179,7 +179,7 @@ class Tests_Comment extends WP_UnitTestCase { public function test_wp_update_comment_is_wp_error() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); - add_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); + add_filter( 'wp_update_comment_data', array( $this, 'wp_update_comment_data_filter' ), 10, 3 ); $result = wp_update_comment( array( @@ -189,7 +189,7 @@ class Tests_Comment extends WP_UnitTestCase { true ); - remove_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); + remove_filter( 'wp_update_comment_data', array( $this, 'wp_update_comment_data_filter' ), 10, 3 ); $this->assertWPError( $result ); } @@ -197,7 +197,7 @@ class Tests_Comment extends WP_UnitTestCase { /** * Blocks comments from being updated by returning WP_Error. */ - public function _wp_update_comment_data_filter( $data, $comment, $commentarr ) { + public function wp_update_comment_data_filter( $data, $comment, $commentarr ) { return new WP_Error( 'comment_wrong', 'wp_update_comment_data filter fails for this comment.', 500 ); } diff --git a/tests/phpunit/tests/comment/getCommentsPagesCount.php b/tests/phpunit/tests/comment/getCommentsPagesCount.php index c843016752..eb03cfb3f0 100644 --- a/tests/phpunit/tests/comment/getCommentsPagesCount.php +++ b/tests/phpunit/tests/comment/getCommentsPagesCount.php @@ -13,7 +13,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * setUp options */ - function set_up() { + public function set_up() { parent::set_up(); $this->option_page_comments = get_option( 'page_comments' ); $this->option_page_comments = get_option( 'comments_per_page' ); @@ -26,7 +26,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * tearDown options */ - function tear_down() { + public function tear_down() { update_option( 'page_comments', $this->option_page_comments ); update_option( 'comments_per_page', $this->option_page_comments ); update_option( 'thread_comments', $this->option_page_comments ); @@ -37,7 +37,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * Validate get_comments_pages_count for empty comments */ - function test_empty() { + public function test_empty() { // Setup post and comments. $post_id = self::factory()->post->create( array( @@ -64,7 +64,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * Validate get_comments_pages_count for treaded comments */ - function test_threaded_comments() { + public function test_threaded_comments() { // Setup post and comments. $post = self::factory()->post->create_and_get( array( @@ -84,7 +84,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * Validate get_comments_pages_count for option tread_comments */ - function test_option_thread_comments() { + public function test_option_thread_comments() { // Setup post and comments. $post = self::factory()->post->create_and_get( @@ -115,7 +115,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * Validate $wp_query logic of get_comment_pages_count */ - function test_wp_query_comments_per_page() { + public function test_wp_query_comments_per_page() { global $wp_query; update_option( 'posts_per_rss', 100 ); @@ -164,7 +164,7 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { /** * Validate max_num_comment_pages logic of get_comment_pages_count */ - function test_max_num_comment_pages() { + public function test_max_num_comment_pages() { global $wp_query; $wp_query = new WP_Query(); diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 4fc3cd22ed..68265dfdac 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -1284,7 +1284,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertSame( array( $comments[2] ), $q->comments ); } - function test_get_comments_for_post() { + public function test_get_comments_for_post() { $limit = 5; $post_id = self::factory()->post->create(); @@ -1344,7 +1344,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 21003 */ - function test_orderby_meta() { + public function test_orderby_meta() { $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); $comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); $comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); @@ -1596,7 +1596,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 27064 */ - function test_get_comments_by_user() { + public function test_get_comments_by_user() { $users = self::factory()->user->create_many( 2 ); self::factory()->comment->create( array( @@ -1689,7 +1689,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 28434 */ - function test_fields_ids_query() { + public function test_fields_ids_query() { $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, @@ -1725,7 +1725,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 */ - function test_fields_comment__in() { + public function test_fields_comment__in() { $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, @@ -1761,7 +1761,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 */ - function test_fields_comment__not_in() { + public function test_fields_comment__not_in() { $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, @@ -1797,7 +1797,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 */ - function test_fields_post__in() { + public function test_fields_post__in() { $p1 = self::factory()->post->create(); $p2 = self::factory()->post->create(); $p3 = self::factory()->post->create(); @@ -1837,7 +1837,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29189 */ - function test_fields_post__not_in() { + public function test_fields_post__not_in() { $p1 = self::factory()->post->create(); $p2 = self::factory()->post->create(); $p3 = self::factory()->post->create(); @@ -1877,7 +1877,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 */ - function test_fields_post_author__in() { + public function test_fields_post_author__in() { $author_id1 = 105; $author_id2 = 106; @@ -1920,7 +1920,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 */ - function test_fields_post_author__not_in() { + public function test_fields_post_author__not_in() { $author_id1 = 111; $author_id2 = 112; @@ -1963,7 +1963,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 */ - function test_fields_author__in() { + public function test_fields_author__in() { $p1 = self::factory()->post->create(); $p2 = self::factory()->post->create(); $p3 = self::factory()->post->create(); @@ -2011,7 +2011,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { /** * @ticket 29885 */ - function test_fields_author__not_in() { + public function test_fields_author__not_in() { $p1 = self::factory()->post->create(); $p2 = self::factory()->post->create(); $p3 = self::factory()->post->create(); diff --git a/tests/phpunit/tests/comment/slashes.php b/tests/phpunit/tests/comment/slashes.php index 3a386a13ab..5b0f061b07 100644 --- a/tests/phpunit/tests/comment/slashes.php +++ b/tests/phpunit/tests/comment/slashes.php @@ -15,7 +15,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { self::$post_id = $factory->post->create(); } - function set_up() { + public function set_up() { parent::set_up(); wp_set_current_user( self::$author_id ); @@ -34,7 +34,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the extended model function that expects slashed data. */ - function test_wp_new_comment() { + public function test_wp_new_comment() { $post_id = self::$post_id; // Not testing comment_author_email or comment_author_url @@ -73,7 +73,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the controller function that expects slashed data. */ - function test_edit_comment() { + public function test_edit_comment() { $post_id = self::$post_id; $comment_id = self::factory()->comment->create( array( @@ -119,7 +119,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. */ - function test_wp_insert_comment() { + public function test_wp_insert_comment() { $post_id = self::$post_id; $comment_id = wp_insert_comment( @@ -150,7 +150,7 @@ class Tests_Comment_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. */ - function test_wp_update_comment() { + public function test_wp_update_comment() { $post_id = self::$post_id; $comment_id = self::factory()->comment->create( array( diff --git a/tests/phpunit/tests/comment/template.php b/tests/phpunit/tests/comment/template.php index 6091a5e546..93e88ca107 100644 --- a/tests/phpunit/tests/comment/template.php +++ b/tests/phpunit/tests/comment/template.php @@ -19,7 +19,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { self::$post_id = self::factory()->post->create(); } - function test_get_comments_number() { + public function test_get_comments_number() { $post_id = self::$post_id; $this->assertSame( 0, get_comments_number( 0 ) ); @@ -32,7 +32,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { $this->assertSame( '12', get_comments_number( get_post( $post_id ) ) ); } - function test_get_comments_number_without_arg() { + public function test_get_comments_number_without_arg() { $post_id = self::$post_id; $permalink = get_permalink( $post_id ); $this->go_to( $permalink ); @@ -48,7 +48,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { /** * @ticket 48772 */ - function test_get_comments_number_text_with_post_id() { + public function test_get_comments_number_text_with_post_id() { $post_id = self::$post_id; $this->factory->comment->create_post_comments( $post_id, 6 ); @@ -67,7 +67,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { /** * @ticket 13651 */ - function test_get_comments_number_text_declension_with_default_args() { + public function test_get_comments_number_text_declension_with_default_args() { $post_id = self::$post_id; $permalink = get_permalink( $post_id ); $this->go_to( $permalink ); @@ -90,21 +90,21 @@ class Tests_Comment_Template extends WP_UnitTestCase { * @ticket 13651 * @dataProvider data_get_comments_number_text_declension */ - function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) { + public function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) { $post_id = self::$post_id; $permalink = get_permalink( $post_id ); $this->factory->comment->create_post_comments( $post_id, $number ); $this->go_to( $permalink ); - add_filter( 'gettext_with_context', array( $this, '_enable_comment_number_declension' ), 10, 4 ); + add_filter( 'gettext_with_context', array( $this, 'enable_comment_number_declension' ), 10, 4 ); $this->assertSame( $output, get_comments_number_text( false, false, $input ) ); - remove_filter( 'gettext_with_context', array( $this, '_enable_comment_number_declension' ), 10, 4 ); + remove_filter( 'gettext_with_context', array( $this, 'enable_comment_number_declension' ), 10, 4 ); } - function _enable_comment_number_declension( $translation, $text, $context, $domain ) { + public function enable_comment_number_declension( $translation, $text, $context, $domain ) { if ( 'Comment number declension: on or off' === $context ) { $translation = 'on'; } @@ -123,7 +123,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { * } * } */ - function data_get_comments_number_text_declension() { + public function data_get_comments_number_text_declension() { return array( array( 2, diff --git a/tests/phpunit/tests/comment/walker.php b/tests/phpunit/tests/comment/walker.php index 32037f52e0..1027a96d14 100644 --- a/tests/phpunit/tests/comment/walker.php +++ b/tests/phpunit/tests/comment/walker.php @@ -5,7 +5,7 @@ */ class Tests_Comment_Walker extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); $this->post_id = self::factory()->post->create(); @@ -14,7 +14,7 @@ class Tests_Comment_Walker extends WP_UnitTestCase { /** * @ticket 14041 */ - function test_has_children() { + public function test_has_children() { $comment_parent = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); $comment_child = self::factory()->comment->create( array( diff --git a/tests/phpunit/tests/cron.php b/tests/phpunit/tests/cron.php index 2940c1708a..36d5edd7dd 100644 --- a/tests/phpunit/tests/cron.php +++ b/tests/phpunit/tests/cron.php @@ -16,7 +16,7 @@ class Tests_Cron extends WP_UnitTestCase { */ private $plus_thirty_minutes; - function set_up() { + public function set_up() { parent::set_up(); // Make sure the schedule is clear. _set_cron_array( array() ); @@ -24,19 +24,19 @@ class Tests_Cron extends WP_UnitTestCase { $this->plus_thirty_minutes = strtotime( '+30 minutes' ); } - function tear_down() { + public function tear_down() { // Make sure the schedule is clear. _set_cron_array( array() ); parent::tear_down(); } - function test_wp_get_schedule_empty() { + public function test_wp_get_schedule_empty() { // Nothing scheduled. $hook = __FUNCTION__; $this->assertFalse( wp_get_schedule( $hook ) ); } - function test_schedule_event_single() { + public function test_schedule_event_single() { // Schedule an event and make sure it's returned by wp_next_scheduled(). $hook = __FUNCTION__; $timestamp = strtotime( '+1 hour' ); @@ -50,7 +50,7 @@ class Tests_Cron extends WP_UnitTestCase { } - function test_schedule_event_single_args() { + public function test_schedule_event_single_args() { // Schedule an event with arguments and make sure it's returned by wp_next_scheduled(). $hook = 'event'; $timestamp = strtotime( '+1 hour' ); @@ -68,7 +68,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertFalse( wp_get_schedule( $hook, $args ) ); } - function test_schedule_event() { + public function test_schedule_event() { // Schedule an event and make sure it's returned by wp_next_scheduled(). $hook = __FUNCTION__; $recur = 'hourly'; @@ -82,7 +82,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertSame( $recur, wp_get_schedule( $hook ) ); } - function test_schedule_event_args() { + public function test_schedule_event_args() { // Schedule an event and make sure it's returned by wp_next_scheduled(). $hook = 'event'; $timestamp = strtotime( '+1 hour' ); @@ -111,7 +111,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @covers ::wp_schedule_event */ - function test_wp_schedule_event_without_cron_option_does_not_throw_warning() { + public function test_wp_schedule_event_without_cron_option_does_not_throw_warning() { delete_option( 'cron' ); // Verify that the cause of the error is in place. @@ -132,7 +132,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @covers ::wp_schedule_single_event */ - function test_wp_schedule_single_event_without_cron_option() { + public function test_wp_schedule_single_event_without_cron_option() { delete_option( 'cron' ); // Verify that the cause of the error is in place. @@ -148,7 +148,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertNotContains( false, get_option( 'cron' ), 'Resulting cron array contains the value "false"' ); } - function test_unschedule_event() { + public function test_unschedule_event() { // Schedule an event and make sure it's returned by wp_next_scheduled(). $hook = __FUNCTION__; $timestamp = strtotime( '+1 hour' ); @@ -162,7 +162,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertFalse( wp_next_scheduled( $hook ) ); } - function test_clear_schedule() { + public function test_clear_schedule() { $hook = __FUNCTION__; $args = array( 'arg1' ); @@ -189,7 +189,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertFalse( wp_next_scheduled( $hook, $args ) ); } - function test_clear_undefined_schedule() { + public function test_clear_undefined_schedule() { $hook = __FUNCTION__; $args = array( 'arg1' ); @@ -201,7 +201,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertSame( 0, $hook_unscheduled ); } - function test_clear_schedule_multiple_args() { + public function test_clear_schedule_multiple_args() { $hook = __FUNCTION__; $args = array( 'arg1', 'arg2' ); @@ -230,7 +230,7 @@ class Tests_Cron extends WP_UnitTestCase { /** * @ticket 10468 */ - function test_clear_schedule_new_args() { + public function test_clear_schedule_new_args() { $hook = __FUNCTION__; $args = array( 'arg1' ); $multi_hook = __FUNCTION__ . '_multi'; @@ -268,7 +268,7 @@ class Tests_Cron extends WP_UnitTestCase { /** * @ticket 18997 */ - function test_unschedule_hook() { + public function test_unschedule_hook() { $hook = __FUNCTION__; $args = array( rand_str() ); @@ -288,7 +288,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertFalse( wp_next_scheduled( $hook ) ); } - function test_unschedule_undefined_hook() { + public function test_unschedule_undefined_hook() { $hook = __FUNCTION__; $unrelated_hook = __FUNCTION__ . '_two'; @@ -309,7 +309,7 @@ class Tests_Cron extends WP_UnitTestCase { /** * @ticket 6966 */ - function test_duplicate_event() { + public function test_duplicate_event() { // Duplicate events close together should be skipped. $hook = __FUNCTION__; $args = array( 'arg1' ); @@ -332,7 +332,7 @@ class Tests_Cron extends WP_UnitTestCase { /** * @ticket 6966 */ - function test_not_duplicate_event() { + public function test_not_duplicate_event() { // Duplicate events far apart should work normally. $hook = __FUNCTION__; $args = array( 'arg1' ); @@ -351,7 +351,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertSame( $ts1, wp_next_scheduled( $hook, $args ) ); } - function test_not_duplicate_event_reversed() { + public function test_not_duplicate_event_reversed() { // Duplicate events far apart should work normally regardless of order. $hook = __FUNCTION__; $args = array( 'arg1' ); @@ -376,7 +376,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 32656 */ - function test_pre_schedule_event_filter() { + public function test_pre_schedule_event_filter() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts1 = strtotime( '+30 minutes' ); @@ -384,7 +384,7 @@ class Tests_Cron extends WP_UnitTestCase { $expected = _get_cron_array(); - add_filter( 'pre_schedule_event', array( $this, '_filter_pre_schedule_event_filter' ), 10, 2 ); + add_filter( 'pre_schedule_event', array( $this, 'filter_pre_schedule_event_filter' ), 10, 2 ); $this->assertTrue( wp_schedule_single_event( $ts1, $hook, $args ) ); $this->assertTrue( wp_schedule_event( $ts2, 'hourly', $hook ) ); @@ -410,7 +410,7 @@ class Tests_Cron extends WP_UnitTestCase { /** * Filter the scheduling of events to use the preflight array. */ - function _filter_pre_schedule_event_filter( $null, $event ) { + public function filter_pre_schedule_event_filter( $null, $event ) { $key = md5( serialize( $event->args ) ); $this->preflight_cron_array[ $event->timestamp ][ $event->hook ][ $key ] = array( @@ -428,7 +428,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 32656 */ - function test_pre_reschedule_event_filter() { + public function test_pre_reschedule_event_filter() { $hook = __FUNCTION__; $ts1 = strtotime( '+30 minutes' ); @@ -452,7 +452,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 32656 */ - function test_pre_unschedule_event_filter() { + public function test_pre_unschedule_event_filter() { $hook = __FUNCTION__; $ts1 = strtotime( '+30 minutes' ); @@ -476,7 +476,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 32656 */ - function test_pre_clear_scheduled_hook_filters() { + public function test_pre_clear_scheduled_hook_filters() { $hook = __FUNCTION__; $ts1 = strtotime( '+30 minutes' ); @@ -507,7 +507,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 32656 */ - function test_pre_scheduled_event_hooks() { + public function test_pre_scheduled_event_hooks() { add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) ); $actual = wp_get_scheduled_event( 'preflight_event', array(), $this->plus_thirty_minutes ); @@ -524,7 +524,7 @@ class Tests_Cron extends WP_UnitTestCase { $this->assertSame( $expected->timestamp, $actual2 ); } - function filter_pre_scheduled_event_hooks() { + public function filter_pre_scheduled_event_hooks() { return (object) array( 'hook' => 'preflight_event', 'timestamp' => $this->plus_thirty_minutes, @@ -541,7 +541,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 45976. */ - function test_get_scheduled_event_singles() { + public function test_get_scheduled_event_singles() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts_late = strtotime( '+30 minutes' ); @@ -584,7 +584,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 45976. */ - function test_get_scheduled_event_recurring() { + public function test_get_scheduled_event_recurring() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts_late = strtotime( '+30 minutes' ); @@ -628,7 +628,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 45976. */ - function test_get_scheduled_event_false() { + public function test_get_scheduled_event_false() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts = strtotime( '+3 minutes' ); @@ -653,7 +653,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 44818 */ - function test_duplicate_past_event() { + public function test_duplicate_past_event() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts1 = strtotime( '-14 minutes' ); @@ -680,7 +680,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 44818 */ - function test_duplicate_near_future_event() { + public function test_duplicate_near_future_event() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts1 = strtotime( '+4 minutes' ); @@ -708,7 +708,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 44818 */ - function test_duplicate_future_event() { + public function test_duplicate_future_event() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts1 = strtotime( '+15 minutes' ); @@ -732,7 +732,7 @@ class Tests_Cron extends WP_UnitTestCase { * * @ticket 44818 */ - function test_not_duplicate_future_event() { + public function test_not_duplicate_future_event() { $hook = __FUNCTION__; $args = array( 'arg1' ); $ts1 = strtotime( '+15 minutes' ); diff --git a/tests/phpunit/tests/customize/control.php b/tests/phpunit/tests/customize/control.php index df45a4e00a..c83418c301 100644 --- a/tests/phpunit/tests/customize/control.php +++ b/tests/phpunit/tests/customize/control.php @@ -24,7 +24,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase { /** * Set up. */ - function set_up() { + public function set_up() { parent::set_up(); wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; @@ -37,7 +37,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase { * * @see WP_Customize_Control::check_capabilities() */ - function test_check_capabilities() { + public function test_check_capabilities() { do_action( 'customize_register', $this->wp_customize ); $control = new WP_Customize_Control( $this->wp_customize, @@ -105,7 +105,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase { /** * @ticket 38164 */ - function test_dropdown_pages() { + public function test_dropdown_pages() { do_action( 'customize_register', $this->wp_customize ); $this->assertInstanceOf( 'WP_Customize_Nav_Menus', $this->wp_customize->nav_menus ); @@ -172,7 +172,7 @@ class Test_WP_Customize_Control extends WP_UnitTestCase { /** * Tear down. */ - function tear_down() { + public function tear_down() { $this->wp_customize = null; unset( $GLOBALS['wp_customize'] ); parent::tear_down(); diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php index 033d0e9433..e23418ea61 100644 --- a/tests/phpunit/tests/customize/custom-css-setting.php +++ b/tests/phpunit/tests/customize/custom-css-setting.php @@ -27,7 +27,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @see WP_UnitTestCase::setup() */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; @@ -54,7 +54,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { /** * Tear down the test case. */ - function tear_down() { + public function tear_down() { $this->setting = null; parent::tear_down(); } @@ -62,7 +62,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { /** * Delete the $wp_customize global when cleaning up scope. */ - function clean_up_global_scope() { + public function clean_up_global_scope() { global $wp_customize; $wp_customize = null; parent::clean_up_global_scope(); @@ -77,7 +77,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @covers WP_Customize_Custom_CSS_Setting::__construct */ - function test_construct() { + public function test_construct() { $this->assertTrue( post_type_exists( 'custom_css' ) ); $this->assertSame( 'custom_css', $this->setting->type ); $this->assertSame( get_stylesheet(), $this->setting->stylesheet ); @@ -110,7 +110,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * @covers WP_Customize_Custom_CSS_Setting::preview * @covers WP_Customize_Custom_CSS_Setting::update */ - function test_crud() { + public function test_crud() { $this->setting->default = '/* Hello World */'; $this->assertSame( $this->setting->default, $this->setting->value() ); @@ -211,7 +211,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @ticket 39032 */ - function test_custom_css_revision_saved() { + public function test_custom_css_revision_saved() { $inserted_css = 'body { background: black; }'; $updated_css = 'body { background: red; }'; @@ -245,7 +245,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @ticket 39259 */ - function test_get_custom_css_post_queries_after_failed_lookup() { + public function test_get_custom_css_post_queries_after_failed_lookup() { set_theme_mod( 'custom_css_post_id', -1 ); $queries_before = get_num_queries(); wp_get_custom_css_post(); @@ -257,7 +257,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @ticket 39259 */ - function test_update_custom_css_updates_theme_mod() { + public function test_update_custom_css_updates_theme_mod() { set_theme_mod( 'custom_css_post_id', -1 ); $post = wp_update_custom_css_post( 'body { background: blue; }' ); $this->assertSame( $post->ID, get_theme_mod( 'custom_css_post_id' ) ); @@ -268,7 +268,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @covers WP_Customize_Custom_CSS_Setting::value */ - function test_value_filter() { + public function test_value_filter() { add_filter( 'customize_value_custom_css', array( $this, 'filter_value' ), 10, 2 ); $this->setting->default = '/*default*/'; $this->assertSame( '/*default*//*filtered*/', $this->setting->value() ); @@ -297,7 +297,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * @param WP_Customize_Setting $setting Setting. * @return string */ - function filter_value( $value, $setting ) { + public function filter_value( $value, $setting ) { $this->assertInstanceOf( 'WP_Customize_Custom_CSS_Setting', $setting ); $value .= '/*filtered*/'; return $value; @@ -308,7 +308,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @covers WP_Customize_Custom_CSS_Setting::update */ - function test_update_filter() { + public function test_update_filter() { $original_css = 'body { color:red; }'; $post_id = $this->factory()->post->create( array( @@ -343,7 +343,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * @param string $args Args. * @return array Data. */ - function filter_update_custom_css_data( $data, $args ) { + public function filter_update_custom_css_data( $data, $args ) { $this->assertIsArray( $data ); $this->assertSameSets( array( 'css', 'preprocessed' ), array_keys( $data ) ); $this->assertSame( '', $data['preprocessed'] ); @@ -366,7 +366,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * * @covers WP_Customize_Custom_CSS_Setting::validate */ - function test_validate() { + public function test_validate() { // Empty CSS throws no errors. $result = $this->setting->validate( '' ); diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php index 145c04b733..e3fd37059b 100644 --- a/tests/phpunit/tests/customize/manager.php +++ b/tests/phpunit/tests/customize/manager.php @@ -53,7 +53,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * Set up test. */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $this->manager = $this->instantiate(); @@ -70,7 +70,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * Tear down test. */ - function tear_down() { + public function tear_down() { $this->manager = null; unset( $GLOBALS['wp_customize'] ); $_REQUEST = array(); @@ -83,7 +83,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @throws Exception If an inactive core Twenty* theme cannot be found. * @return string Theme slug (stylesheet). */ - function get_inactive_core_theme() { + private function get_inactive_core_theme() { $stylesheet = get_stylesheet(); foreach ( wp_get_themes() as $theme ) { if ( $theme->stylesheet !== $stylesheet && 0 === strpos( $theme->stylesheet, 'twenty' ) ) { @@ -98,7 +98,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @return WP_Customize_Manager */ - function instantiate() { + private function instantiate() { $GLOBALS['wp_customize'] = new WP_Customize_Manager(); return $GLOBALS['wp_customize']; } @@ -108,7 +108,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @covers WP_Customize_Manager::__construct */ - function test_constructor() { + public function test_constructor() { $uuid = wp_generate_uuid4(); $theme = 'twentyfifteen'; $messenger_channel = 'preview-123'; @@ -227,7 +227,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @covers WP_Customize_Manager::setup_theme */ - function test_setup_theme_in_customize_admin() { + public function test_setup_theme_in_customize_admin() { global $pagenow, $wp_customize; $pagenow = 'customize.php'; set_current_screen( 'customize' ); @@ -273,7 +273,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see _delete_option_fresh_site() * @ticket 41039 */ - function test_fresh_site_flag_clearing() { + public function test_fresh_site_flag_clearing() { global $wp_customize, $wpdb; // Make sure fresh site flag is cleared when publishing a changeset. @@ -296,7 +296,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @covers WP_Customize_Manager::setup_theme */ - function test_setup_theme_in_frontend() { + public function test_setup_theme_in_frontend() { global $wp_customize, $pagenow, $show_admin_bar; $pagenow = 'front'; set_current_screen( 'front' ); @@ -331,7 +331,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 39221 * @covers WP_Customize_Manager::settings_previewed */ - function test_settings_previewed() { + public function test_settings_previewed() { $wp_customize = new WP_Customize_Manager( array( 'settings_previewed' => false ) ); $this->assertFalse( $wp_customize->settings_previewed() ); @@ -384,7 +384,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::changeset_uuid */ - function test_changeset_uuid() { + public function test_changeset_uuid() { $uuid = wp_generate_uuid4(); $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); $this->assertSame( $uuid, $wp_customize->changeset_uuid() ); @@ -398,7 +398,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::wp_loaded */ - function test_wp_loaded() { + public function test_wp_loaded() { wp_set_current_user( self::$admin_user_id ); $wp_customize = new WP_Customize_Manager(); $title = 'Hello World'; @@ -416,7 +416,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::find_changeset_post_id */ - function test_find_changeset_post_id() { + public function test_find_changeset_post_id() { $uuid = wp_generate_uuid4(); $post_id = $this->factory()->post->create( array( @@ -441,7 +441,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::changeset_post_id */ - function test_changeset_post_id() { + public function test_changeset_post_id() { $uuid = wp_generate_uuid4(); $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); $this->assertNull( $wp_customize->changeset_post_id() ); @@ -465,7 +465,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::changeset_data */ - function test_changeset_data() { + public function test_changeset_data() { wp_set_current_user( self::$admin_user_id ); $uuid = wp_generate_uuid4(); $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); @@ -543,7 +543,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @covers WP_Customize_Manager::_save_starter_content_changeset * @requires function imagejpeg */ - function test_import_theme_starter_content() { + public function test_import_theme_starter_content() { wp_set_current_user( self::$admin_user_id ); register_nav_menu( 'top', 'Top' ); add_theme_support( 'custom-logo' ); @@ -811,7 +811,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 45484 * @covers WP_Customize_Manager::import_theme_starter_content */ - function test_import_theme_starter_content_with_nested_arrays() { + public function test_import_theme_starter_content_with_nested_arrays() { wp_set_current_user( self::$admin_user_id ); $existing_published_home_page_id = $this->factory()->post->create( @@ -885,7 +885,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::customize_preview_init */ - function test_customize_preview_init() { + public function test_customize_preview_init() { // Test authorized admin user. wp_set_current_user( self::$admin_user_id ); @@ -930,7 +930,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 40020 * @covers WP_Customize_Manager::filter_iframe_security_headers */ - function test_filter_iframe_security_headers() { + public function test_filter_iframe_security_headers() { $wp_customize = new WP_Customize_Manager(); $headers = $wp_customize->filter_iframe_security_headers( array() ); $this->assertArrayHasKey( 'X-Frame-Options', $headers ); @@ -945,7 +945,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::add_state_query_params */ - function test_add_state_query_params() { + public function test_add_state_query_params() { $preview_theme = $this->get_inactive_core_theme(); $uuid = wp_generate_uuid4(); @@ -1004,7 +1004,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::save_changeset_post */ - function test_save_changeset_post_without_theme_activation() { + public function test_save_changeset_post_without_theme_activation() { global $wp_customize; wp_set_current_user( self::$admin_user_id ); @@ -1421,7 +1421,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param array $context Context. * @return array Data. */ - function filter_customize_changeset_save_data( $data, $context ) { + public function filter_customize_changeset_save_data( $data, $context ) { $this->customize_changeset_save_data_call_count += 1; $this->assertIsArray( $data ); $this->assertIsArray( $context ); @@ -1440,7 +1440,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @return WP_Error Error. */ - function return_illegal_error() { + public function return_illegal_error() { return new WP_Error( 'illegal' ); } @@ -1451,7 +1451,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @covers WP_Customize_Manager::save_changeset_post * @covers WP_Customize_Manager::update_stashed_theme_mod_settings */ - function test_save_changeset_post_with_theme_activation() { + public function test_save_changeset_post_with_theme_activation() { global $wp_customize; wp_set_current_user( self::$admin_user_id ); @@ -1489,7 +1489,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 38705 * @covers WP_Customize_Manager::save_changeset_post */ - function test_save_changeset_post_with_varying_users() { + public function test_save_changeset_post_with_varying_users() { global $wp_customize; add_theme_support( 'custom-background' ); @@ -1664,7 +1664,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see wp_delete_auto_drafts() * @covers WP_Customize_Manager::save_changeset_post */ - function test_save_changeset_post_dumping_auto_draft_date() { + public function test_save_changeset_post_dumping_auto_draft_date() { global $wp_customize; wp_set_current_user( self::$admin_user_id ); @@ -1704,7 +1704,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 38865 * @covers WP_Customize_Manager::save_changeset_post */ - function test_save_changeset_post_with_unchanged_values() { + public function test_save_changeset_post_with_unchanged_values() { global $wp_customize; add_theme_support( 'custom-background' ); @@ -1904,7 +1904,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 41621 * @covers WP_Customize_Manager::save_changeset_post */ - function test_remove_setting_from_changeset_post() { + public function test_remove_setting_from_changeset_post() { $uuid = wp_generate_uuid4(); $manager = $this->create_test_manager( $uuid ); @@ -1940,7 +1940,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 38705 * @covers WP_Customize_Manager::save_changeset_post */ - function test_save_changeset_post_with_varying_unfiltered_html_cap() { + public function test_save_changeset_post_with_varying_unfiltered_html_cap() { global $wp_customize; grant_super_admin( self::$admin_user_id ); $this->assertTrue( user_can( self::$admin_user_id, 'unfiltered_html' ) ); @@ -2012,7 +2012,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see WP_Customize_Widgets::schedule_customize_register() * @see WP_Customize_Widgets::customize_register() */ - function test_wp_customize_publish_changeset() { + public function test_wp_customize_publish_changeset() { global $wp_customize; $wp_customize = null; @@ -2058,7 +2058,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 41336 * @covers WP_Customize_Manager::save_changeset_post */ - function test_publish_changeset_with_future_status_when_future_date() { + public function test_publish_changeset_with_future_status_when_future_date() { $wp_customize = $this->create_test_manager( wp_generate_uuid4() ); $wp_customize->save_changeset_post( @@ -2079,7 +2079,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @covers WP_Customize_Manager::save_changeset_post * @covers WP_Customize_Manager::get_changeset_post_data */ - function test_save_changeset_post_for_bad_changeset() { + public function test_save_changeset_post_for_bad_changeset() { $uuid = wp_generate_uuid4(); $post_id = wp_insert_post( array( @@ -2150,7 +2150,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @param WP_Customize_Manager $wp_customize Manager. */ - function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) { + public function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) { $wp_customize->add_setting( 'scratchpad', array( @@ -2167,7 +2167,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param string $value Value. * @return string Value. */ - function filter_sanitize_scratchpad( $value ) { + public function filter_sanitize_scratchpad( $value ) { return apply_filters( 'content_save_pre', $value ); } @@ -2185,7 +2185,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param WP_Customize_Setting $setting Setting. * @return mixed Value. */ - function filter_customize_setting_to_log_current_user( $value, $setting ) { + public function filter_customize_setting_to_log_current_user( $value, $setting ) { $this->filtered_setting_current_user_ids[ $setting->id ] = get_current_user_id(); return $value; } @@ -2196,7 +2196,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::is_cross_domain */ - function test_is_cross_domain() { + public function test_is_cross_domain() { $wp_customize = new WP_Customize_Manager(); update_option( 'home', 'http://example.com' ); @@ -2214,7 +2214,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::get_allowed_urls */ - function test_get_allowed_urls() { + public function test_get_allowed_urls() { $wp_customize = new WP_Customize_Manager(); $this->assertFalse( is_ssl() ); $this->assertFalse( $wp_customize->is_cross_domain() ); @@ -2232,7 +2232,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param array $urls URLs. * @return array URLs. */ - function filter_customize_allowed_urls( $urls ) { + public function filter_customize_allowed_urls( $urls ) { $urls[] = 'http://headless.example.com/'; return $urls; } @@ -2242,7 +2242,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @group ajax */ - function test_doing_ajax() { + public function test_doing_ajax() { add_filter( 'wp_doing_ajax', '__return_true' ); $manager = $this->manager; @@ -2256,7 +2256,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * Test ! WP_Customize_Manager::doing_ajax(). */ - function test_not_doing_ajax() { + public function test_not_doing_ajax() { add_filter( 'wp_doing_ajax', '__return_false' ); $manager = $this->manager; @@ -2268,7 +2268,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 30988 */ - function test_unsanitized_post_values_from_input() { + public function test_unsanitized_post_values_from_input() { wp_set_current_user( self::$admin_user_id ); $manager = $this->manager; @@ -2297,7 +2297,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::unsanitized_post_values */ - function test_unsanitized_post_values_with_changeset_and_stashed_theme_mods() { + public function test_unsanitized_post_values_with_changeset_and_stashed_theme_mods() { wp_set_current_user( self::$admin_user_id ); $preview_theme = $this->get_inactive_core_theme(); @@ -2421,7 +2421,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 30988 */ - function test_post_value() { + public function test_post_value() { wp_set_current_user( self::$admin_user_id ); $posted_settings = array( 'foo' => 'OOF', @@ -2445,7 +2445,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 34893 */ - function test_invalid_post_value() { + public function test_invalid_post_value() { wp_set_current_user( self::$admin_user_id ); $default_value = 'foo_default'; $setting = $this->manager->add_setting( @@ -2483,7 +2483,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param mixed $value Value. * @return string|WP_Error */ - function filter_customize_sanitize_foo( $value ) { + public function filter_customize_sanitize_foo( $value ) { if ( 'return_null_in_sanitize' === $value ) { $value = null; } elseif ( is_string( $value ) ) { @@ -2502,7 +2502,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param mixed $value Value. * @return WP_Error */ - function filter_customize_validate_foo( $validity, $value ) { + public function filter_customize_validate_foo( $validity, $value ) { if ( false !== stripos( $value, 'add( 'invalid_value_in_validate', __( 'Invalid value.' ), array( 'source' => 'filter_customize_validate_foo' ) ); } @@ -2514,7 +2514,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 37247 */ - function test_post_value_validation_sanitization_order() { + public function test_post_value_validation_sanitization_order() { wp_set_current_user( self::$admin_user_id ); $default_value = '0'; $setting = $this->manager->add_setting( @@ -2539,7 +2539,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param mixed $value Value. * @return string|WP_Error */ - function filter_customize_sanitize_numeric( $value ) { + public function filter_customize_sanitize_numeric( $value ) { return absint( $value ); } @@ -2550,7 +2550,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param mixed $value Value. * @return WP_Error */ - function filter_customize_validate_numeric( $validity, $value ) { + public function filter_customize_validate_numeric( $validity, $value ) { if ( ! is_string( $value ) || ! is_numeric( $value ) ) { $validity->add( 'invalid_value_in_validate', __( 'Invalid value.' ), array( 'source' => 'filter_customize_validate_numeric' ) ); } @@ -2562,7 +2562,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::validate_setting_values() */ - function test_validate_setting_values() { + public function test_validate_setting_values() { wp_set_current_user( self::$admin_user_id ); $setting = $this->manager->add_setting( 'foo', @@ -2611,7 +2611,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 37638 * @covers WP_Customize_Manager::validate_setting_values */ - function test_late_validate_setting_values() { + public function test_late_validate_setting_values() { $setting = new Test_Setting_Without_Applying_Validate_Filter( $this->manager, 'required' ); $this->manager->add_setting( $setting ); @@ -2637,7 +2637,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30937 * @covers WP_Customize_Manager::validate_setting_values */ - function test_validate_setting_values_args() { + public function test_validate_setting_values_args() { wp_set_current_user( self::$admin_user_id ); $this->manager->register_controls(); @@ -2675,7 +2675,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param WP_Customize_Setting $setting Setting. * @return WP_Error Validity. */ - function late_validate_length( $validity, $value, $setting ) { + public function late_validate_length( $validity, $value, $setting ) { $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); if ( strlen( $value ) < 10 ) { $validity->add( 'minlength', '' ); @@ -2688,7 +2688,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 37247 */ - function test_validate_setting_values_validation_sanitization_order() { + public function test_validate_setting_values_validation_sanitization_order() { wp_set_current_user( self::$admin_user_id ); $setting = $this->manager->add_setting( 'numeric', @@ -2709,7 +2709,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::prepare_setting_validity_for_js() */ - function test_prepare_setting_validity_for_js() { + public function test_prepare_setting_validity_for_js() { $this->assertTrue( $this->manager->prepare_setting_validity_for_js( true ) ); $error = new WP_Error(); $error->add( 'bad_letter', 'Bad letter', 'A' ); @@ -2733,7 +2733,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::set_post_value() */ - function test_set_post_value() { + public function test_set_post_value() { wp_set_current_user( self::$admin_user_id ); $this->manager->add_setting( 'foo', @@ -2768,7 +2768,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param mixed $value Value. * @return int Value. */ - function sanitize_foo_for_test_set_post_value( $value ) { + public function sanitize_foo_for_test_set_post_value( $value ) { return (int) $value; } @@ -2787,7 +2787,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @param mixed ...$args Optional arguments passed to the action. */ - function capture_customize_post_value_set_actions( ...$args ) { + public function capture_customize_post_value_set_actions( ...$args ) { $action = current_action(); $this->captured_customize_post_value_set_actions[] = compact( 'action', 'args' ); } @@ -2797,7 +2797,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 30936 */ - function test_add_dynamic_settings() { + public function test_add_dynamic_settings() { $manager = $this->manager; $setting_ids = array( 'foo', 'bar' ); $manager->add_setting( 'foo', array( 'default' => 'foo_default' ) ); @@ -2818,7 +2818,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 38013 * @covers WP_Customize_Manager::has_published_pages */ - function test_has_published_pages() { + public function test_has_published_pages() { foreach ( get_pages() as $page ) { wp_delete_post( $page->ID, true ); } @@ -2847,7 +2847,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 38013 * @covers WP_Customize_Manager::has_published_pages */ - function test_has_published_pages_when_nav_menus_created_posts() { + public function test_has_published_pages_when_nav_menus_created_posts() { foreach ( get_pages() as $page ) { wp_delete_post( $page->ID, true ); } @@ -2876,7 +2876,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 30936 */ - function test_register_dynamic_settings() { + public function test_register_dynamic_settings() { wp_set_current_user( self::$admin_user_id ); $posted_settings = array( 'foo' => 'OOF', @@ -2898,7 +2898,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * In lieu of closures, callback for customize_register action added in test_register_dynamic_settings(). */ - function action_customize_register_for_dynamic_settings() { + public function action_customize_register_for_dynamic_settings() { add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args_for_test_dynamic_settings' ), 10, 2 ); add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_customize_dynamic_setting_class_for_test_dynamic_settings' ), 10, 3 ); } @@ -2910,7 +2910,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param string $setting_id Setting ID. * @return array */ - function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) { + public function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) { $this->assertIsString( $setting_id ); if ( in_array( $setting_id, array( 'foo', 'bar' ), true ) ) { $setting_args = array( 'default' => "dynamic_{$setting_id}_default" ); @@ -2926,7 +2926,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param array $setting_args Setting args. * @return string */ - function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) { + public function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) { $this->assertSame( 'WP_Customize_Setting', $setting_class ); $this->assertIsString( $setting_id ); $this->assertIsArray( $setting_args ); @@ -2938,7 +2938,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::get_document_title_template() */ - function test_get_document_title_template() { + public function test_get_document_title_template() { $tpl = $this->manager->get_document_title_template(); $this->assertStringContainsString( '%s', $tpl ); } @@ -2949,7 +2949,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see WP_Customize_Manager::get_preview_url() * @see WP_Customize_Manager::set_preview_url() */ - function test_preview_url() { + public function test_preview_url() { $this->assertSame( home_url( '/' ), $this->manager->get_preview_url() ); $preview_url = home_url( '/foo/bar/baz/' ); $this->manager->set_preview_url( $preview_url ); @@ -2964,7 +2964,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see WP_Customize_Manager::get_return_url() * @see WP_Customize_Manager::set_return_url() */ - function test_return_url() { + public function test_return_url() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) ); $this->assertSame( home_url( '/' ), $this->manager->get_return_url() ); @@ -2999,7 +2999,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 46686 */ - function test_return_url_with_deactivated_theme() { + public function test_return_url_with_deactivated_theme() { $this->manager->set_return_url( admin_url( 'themes.php?page=mytheme_documentation' ) ); $this->assertSame( admin_url( 'themes.php' ), $this->manager->get_return_url() ); } @@ -3010,7 +3010,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @see WP_Customize_Manager::get_autofocus() * @see WP_Customize_Manager::set_autofocus() */ - function test_autofocus() { + public function test_autofocus() { $this->assertEmpty( $this->manager->get_autofocus() ); $this->manager->set_autofocus( array( 'unrecognized' => 'food' ) ); @@ -3038,7 +3038,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::get_nonces() */ - function test_nonces() { + public function test_nonces() { $nonces = $this->manager->get_nonces(); $this->assertIsArray( $nonces ); $this->assertArrayHasKey( 'save', $nonces ); @@ -3057,7 +3057,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param WP_Customize_Manager $manager Manager. * @return array Nonces. */ - function filter_customize_refresh_nonces( $nonces, $manager ) { + public function filter_customize_refresh_nonces( $nonces, $manager ) { $this->assertInstanceOf( 'WP_Customize_Manager', $manager ); $nonces['foo'] = wp_create_nonce( 'foo' ); return $nonces; @@ -3068,7 +3068,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::customize_pane_settings() */ - function test_customize_pane_settings() { + public function test_customize_pane_settings() { wp_set_current_user( self::$admin_user_id ); $this->manager->register_controls(); $this->manager->prepare_controls(); @@ -3119,7 +3119,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 38867 * @covers WP_Customize_Manager::remove_frameless_preview_messenger_channel */ - function test_remove_frameless_preview_messenger_channel() { + public function test_remove_frameless_preview_messenger_channel() { wp_set_current_user( self::$admin_user_id ); $manager = new WP_Customize_Manager( array( 'messenger_channel' => null ) ); ob_start(); @@ -3139,7 +3139,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @see WP_Customize_Manager::customize_preview_settings() */ - function test_customize_preview_settings() { + public function test_customize_preview_settings() { wp_set_current_user( self::$admin_user_id ); $this->manager->register_controls(); $this->manager->prepare_controls(); @@ -3171,7 +3171,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 33552 */ - function test_customize_loaded_components_filter() { + public function test_customize_loaded_components_filter() { $manager = new WP_Customize_Manager(); $this->assertInstanceOf( 'WP_Customize_Widgets', $manager->widgets ); $this->assertInstanceOf( 'WP_Customize_Nav_Menus', $manager->nav_menus ); @@ -3203,7 +3203,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @return array Components. */ - function return_array_containing_widgets( $components, $customize_manager ) { + public function return_array_containing_widgets( $components, $customize_manager ) { $this->assertIsArray( $components ); $this->assertContains( 'widgets', $components ); $this->assertContains( 'nav_menus', $components ); @@ -3220,7 +3220,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @return array Components. */ - function return_array_containing_nav_menus( $components, $customize_manager ) { + public function return_array_containing_nav_menus( $components, $customize_manager ) { $this->assertIsArray( $components ); $this->assertContains( 'widgets', $components ); $this->assertContains( 'nav_menus', $components ); @@ -3233,7 +3233,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @ticket 30225 * @ticket 34594 */ - function test_prepare_controls_stable_sorting() { + public function test_prepare_controls_stable_sorting() { $manager = new WP_Customize_Manager(); $manager->register_controls(); $section_id = 'foo-section'; @@ -3273,7 +3273,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 34596 */ - function test_add_section_return_instance() { + public function test_add_section_return_instance() { $manager = new WP_Customize_Manager(); wp_set_current_user( self::$admin_user_id ); @@ -3307,7 +3307,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 34596 */ - function test_add_setting_return_instance() { + public function test_add_setting_return_instance() { $manager = new WP_Customize_Manager(); wp_set_current_user( self::$admin_user_id ); @@ -3328,7 +3328,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 34597 */ - function test_add_setting_honoring_dynamic() { + public function test_add_setting_honoring_dynamic() { $manager = new WP_Customize_Manager(); $setting_id = 'dynamic'; @@ -3353,7 +3353,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param string $id Setting ID. * @return string Setting class. */ - function return_dynamic_customize_setting_class( $class, $id, $args ) { + public function return_dynamic_customize_setting_class( $class, $id, $args ) { unset( $args ); if ( 0 === strpos( $id, 'dynamic' ) ) { $class = 'Test_Dynamic_Customize_Setting'; @@ -3368,7 +3368,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @param string $id Setting ID. * @return string Setting args. */ - function return_dynamic_customize_setting_args( $args, $id ) { + public function return_dynamic_customize_setting_args( $args, $id ) { if ( 0 === strpos( $id, 'dynamic' ) ) { $args['custom'] = 'foo'; } @@ -3378,7 +3378,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 34596 */ - function test_add_panel_return_instance() { + public function test_add_panel_return_instance() { $manager = new WP_Customize_Manager(); wp_set_current_user( self::$admin_user_id ); @@ -3411,7 +3411,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 34596 */ - function test_add_control_return_instance() { + public function test_add_control_return_instance() { $manager = new WP_Customize_Manager(); $section_id = 'foo-section'; wp_set_current_user( self::$admin_user_id ); @@ -3459,7 +3459,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 31195 */ - function test_get_previewable_devices() { + public function test_get_previewable_devices() { // Setup the instance. $manager = new WP_Customize_Manager(); @@ -3496,7 +3496,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @return array */ - function filtered_device_list() { + private function filtered_device_list() { return array( 'custom-device' => array( 'label' => __( 'Enter custom-device preview mode' ), @@ -3512,14 +3512,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @return array */ - function filter_customize_previewable_devices( $devices ) { + public function filter_customize_previewable_devices( $devices ) { return $this->filtered_device_list(); } /** * @ticket 37128 */ - function test_prepare_controls_wp_list_sort_controls() { + public function test_prepare_controls_wp_list_sort_controls() { wp_set_current_user( self::$admin_user_id ); $controls = array( @@ -3552,7 +3552,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 37128 */ - function test_prepare_controls_wp_list_sort_sections() { + public function test_prepare_controls_wp_list_sort_sections() { wp_set_current_user( self::$admin_user_id ); $sections = array( @@ -3581,7 +3581,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { /** * @ticket 37128 */ - function test_prepare_controls_wp_list_sort_panels() { + public function test_prepare_controls_wp_list_sort_panels() { wp_set_current_user( self::$admin_user_id ); $panels = array( @@ -3612,7 +3612,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @ticket 39125 */ - function test_sanitize_external_header_video_trim() { + public function test_sanitize_external_header_video_trim() { $this->manager->register_controls(); $setting = $this->manager->get_setting( 'external_header_video' ); $video_url = 'https://www.youtube.com/watch?v=72xdCU__XCk'; diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php index f54cf5d5d5..212f871747 100644 --- a/tests/phpunit/tests/customize/nav-menu-item-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php @@ -18,7 +18,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_UnitTestCase::setup() */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); @@ -31,7 +31,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { /** * Delete the $wp_customize global when cleaning up scope. */ - function clean_up_global_scope() { + public function clean_up_global_scope() { global $wp_customize; $wp_customize = null; parent::clean_up_global_scope(); @@ -43,7 +43,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * @param object $menu_item Menu item. * @return object */ - function filter_type_label( $menu_item ) { + public function filter_type_label( $menu_item ) { if ( 'custom_type' === $menu_item->type ) { $menu_item->type_label = 'Custom Label'; } @@ -54,7 +54,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { /** * Test constants and statics. */ - function test_constants() { + public function test_constants() { do_action( 'customize_register', $this->wp_customize ); $this->assertTrue( post_type_exists( WP_Customize_Nav_Menu_Item_Setting::POST_TYPE ) ); } @@ -64,7 +64,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::__construct() */ - function test_construct() { + public function test_construct() { do_action( 'customize_register', $this->wp_customize ); $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' ); @@ -108,7 +108,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { /** * Test empty constructor. */ - function test_construct_empty_menus() { + public function test_construct_empty_menus() { do_action( 'customize_register', $this->wp_customize ); $_wp_customize = $this->wp_customize; unset( $_wp_customize->nav_menus ); @@ -128,7 +128,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::__construct() */ - function test_construct_placeholder() { + public function test_construct_placeholder() { do_action( 'customize_register', $this->wp_customize ); $default = array( 'title' => 'Lorem', @@ -146,7 +146,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::value() */ - function test_value_type_post_type() { + public function test_value_type_post_type() { do_action( 'customize_register', $this->wp_customize ); $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); @@ -197,7 +197,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::value() */ - function test_value_type_post_type_without_label() { + public function test_value_type_post_type_without_label() { do_action( 'customize_register', $this->wp_customize ); $original_title = 'Hello World'; @@ -229,7 +229,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::value() */ - function test_value_type_taxonomy() { + public function test_value_type_taxonomy() { do_action( 'customize_register', $this->wp_customize ); $tax_id = self::factory()->category->create( array( 'name' => 'Salutations' ) ); @@ -268,7 +268,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::value() */ - function test_custom_type_label() { + public function test_custom_type_label() { do_action( 'customize_register', $this->wp_customize ); add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) ); @@ -300,7 +300,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::value() */ - function test_value_nav_menu_term_id_returns_zero() { + public function test_value_nav_menu_term_id_returns_zero() { do_action( 'customize_register', $this->wp_customize ); $menu_id = -123; @@ -345,7 +345,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::preview() */ - function test_preview_updated() { + public function test_preview_updated() { do_action( 'customize_register', $this->wp_customize ); $first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); @@ -400,7 +400,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::preview() */ - function test_preview_inserted() { + public function test_preview_inserted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); @@ -459,7 +459,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::preview() */ - function test_preview_deleted() { + public function test_preview_deleted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); @@ -499,7 +499,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::sanitize() */ - function test_sanitize() { + public function test_sanitize() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); @@ -637,7 +637,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::update() */ - function test_save_updated() { + public function test_save_updated() { do_action( 'customize_register', $this->wp_customize ); $first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); @@ -706,7 +706,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::update() */ - function test_save_inserted() { + public function test_save_inserted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); @@ -779,7 +779,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::update() */ - function test_save_deleted() { + public function test_save_deleted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); @@ -831,7 +831,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { /** * @ticket 33665 */ - function test_invalid_nav_menu_item() { + public function test_invalid_nav_menu_item() { $menu_id = wp_create_nav_menu( 'Primary' ); register_post_type( 'poem', @@ -888,7 +888,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() */ - function test_value_as_wp_post_nav_menu_item() { + public function test_value_as_wp_post_nav_menu_item() { $post_id = self::factory()->post->create(); $setting = new WP_Customize_Nav_Menu_Item_Setting( @@ -949,7 +949,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * @ticket 38945 * @covers WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item */ - function test_value_as_wp_post_nav_menu_item_term_urls() { + public function test_value_as_wp_post_nav_menu_item_term_urls() { $term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); register_post_type( 'press_release', @@ -1022,7 +1022,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * @ticket 38945 * @covers WP_Customize_Nav_Menu_Item_Setting::get_original_title */ - function test_get_original_title() { + public function test_get_original_title() { $menu_id = wp_create_nav_menu( 'Menu' ); register_post_type( 'press_release', @@ -1217,7 +1217,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { * @ticket 38015 * @see WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() */ - function test_value_as_wp_post_nav_menu_item_with_empty_title() { + public function test_value_as_wp_post_nav_menu_item_with_empty_title() { $original_title = 'The Original Title'; $post_id = self::factory()->post->create( array( 'post_title' => $original_title ) ); diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php index 2f8d0858d6..4a727618eb 100644 --- a/tests/phpunit/tests/customize/nav-menu-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-setting.php @@ -19,7 +19,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_UnitTestCase::setup() */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); @@ -32,7 +32,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { /** * Delete the $wp_customize global when cleaning up scope. */ - function clean_up_global_scope() { + public function clean_up_global_scope() { global $wp_customize; $wp_customize = null; parent::clean_up_global_scope(); @@ -43,14 +43,14 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @return array */ - function get_nav_menu_items_option() { + private function get_nav_menu_items_option() { return get_option( 'nav_menu_options', array( 'auto_add' => array() ) ); } /** * Test constants and statics. */ - function test_constants() { + public function test_constants() { do_action( 'customize_register', $this->wp_customize ); $this->assertTrue( taxonomy_exists( WP_Customize_Nav_Menu_Setting::TAXONOMY ) ); } @@ -60,7 +60,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::__construct() */ - function test_construct() { + public function test_construct() { do_action( 'customize_register', $this->wp_customize ); $setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' ); @@ -91,7 +91,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { /** * Test empty constructor. */ - function test_construct_empty_menus() { + public function test_construct_empty_menus() { do_action( 'customize_register', $this->wp_customize ); $_wp_customize = $this->wp_customize; unset( $_wp_customize->nav_menus ); @@ -111,7 +111,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::__construct() */ - function test_construct_placeholder() { + public function test_construct_placeholder() { do_action( 'customize_register', $this->wp_customize ); $default = array( 'name' => 'Lorem \\o/', @@ -128,7 +128,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::value() */ - function test_value() { + public function test_value() { do_action( 'customize_register', $this->wp_customize ); $menu_name = 'Test 123 \\o/'; @@ -168,7 +168,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::preview() */ - function test_preview_updated() { + public function test_preview_updated() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_update_nav_menu_object( @@ -235,7 +235,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::preview() */ - function test_preview_inserted() { + public function test_preview_inserted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = -123; @@ -280,7 +280,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::preview() */ - function test_preview_deleted() { + public function test_preview_deleted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_update_nav_menu_object( @@ -319,7 +319,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::sanitize() */ - function test_sanitize() { + public function test_sanitize() { do_action( 'customize_register', $this->wp_customize ); $setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' ); @@ -350,7 +350,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::update() */ - function test_save_updated() { + public function test_save_updated() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_update_nav_menu_object( @@ -415,7 +415,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::update() */ - function test_save_inserted() { + public function test_save_inserted() { do_action( 'customize_register', $this->wp_customize ); $menu_id = -123; @@ -464,7 +464,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::update() */ - function test_save_inserted_conflicted_name() { + public function test_save_inserted_conflicted_name() { do_action( 'customize_register', $this->wp_customize ); $menu_name = 'Foo'; @@ -489,7 +489,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menu_Setting::update() */ - function test_save_deleted() { + public function test_save_deleted() { do_action( 'customize_register', $this->wp_customize ); $menu_name = 'Lorem Ipsum \\o/'; diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 62550a5233..e786e15183 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -19,7 +19,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_UnitTestCase::setup() */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); @@ -31,7 +31,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { /** * Delete the $wp_customize global when cleaning up scope. */ - function clean_up_global_scope() { + public function clean_up_global_scope() { global $wp_customize; $wp_customize = null; parent::clean_up_global_scope(); @@ -43,7 +43,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * @param array $items Menu item types. * @return array Menu item types. */ - function filter_item_types( $items ) { + public function filter_item_types( $items ) { $items[] = array( 'title' => 'Custom', 'type_label' => 'Custom Type', @@ -62,7 +62,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * @param string $object The object name (e.g. category). * @return array Menu items. */ - function filter_items( $items, $type, $object ) { + public function filter_items( $items, $type, $object ) { $items[] = array( 'id' => 'custom-1', 'title' => 'Cool beans', @@ -81,7 +81,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::__construct() */ - function test_construct() { + public function test_construct() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); $this->assertInstanceOf( 'WP_Customize_Manager', $menus->manager ); @@ -107,7 +107,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_returns_wp_error() { + public function test_load_available_items_query_returns_wp_error() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Invalid post type $obj_name. @@ -126,7 +126,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_maybe_returns_home() { + public function test_load_available_items_query_maybe_returns_home() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Expected menu item array. @@ -157,7 +157,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_returns_post_item_with_page_number() { + public function test_load_available_items_query_returns_post_item_with_page_number() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create page. @@ -187,7 +187,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_returns_page_item() { + public function test_load_available_items_query_returns_page_item() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create page. @@ -218,7 +218,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_returns_post_item() { + public function test_load_available_items_query_returns_post_item() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create post. @@ -244,7 +244,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_returns_term_item() { + public function test_load_available_items_query_returns_term_item() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); // Create term. @@ -270,7 +270,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::load_available_items_query() */ - function test_load_available_items_query_returns_custom_item() { + public function test_load_available_items_query_returns_custom_item() { add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); add_filter( 'customize_nav_menu_available_items', array( $this, 'filter_items' ), 10, 4 ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -295,7 +295,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::search_available_items_query() */ - function test_search_available_items_query() { + public function test_search_available_items_query() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); do_action( 'customize_register', $this->wp_customize ); @@ -464,7 +464,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * } * @return array Items. */ - function filter_search( $items, $args ) { + public function filter_search( $items, $args ) { $this->assertIsArray( $items ); $this->assertIsArray( $args ); $this->assertArrayHasKey( 's', $args ); @@ -492,7 +492,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::enqueue_scripts() */ - function test_enqueue_scripts() { + public function test_enqueue_scripts() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); $menus->enqueue_scripts(); @@ -507,7 +507,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::filter_dynamic_setting_args() */ - function test_filter_dynamic_setting_args() { + public function test_filter_dynamic_setting_args() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); $expected = array( 'type' => 'nav_menu_item' ); @@ -524,7 +524,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::filter_dynamic_setting_class() */ - function test_filter_dynamic_setting_class() { + public function test_filter_dynamic_setting_class() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -542,7 +542,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::customize_register() */ - function test_customize_register() { + public function test_customize_register() { do_action( 'customize_register', $this->wp_customize ); $menu_id = wp_create_nav_menu( 'Primary' ); $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); @@ -574,7 +574,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::intval_base10() */ - function test_intval_base10() { + public function test_intval_base10() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -593,7 +593,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::available_item_types() */ - function test_available_item_types() { + public function test_available_item_types() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -729,7 +729,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::print_templates() */ - function test_print_templates() { + public function test_print_templates() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -753,7 +753,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::available_items_template() */ - function test_available_items_template() { + public function test_available_items_template() { add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -800,7 +800,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::customize_dynamic_partial_args() */ - function test_customize_dynamic_partial_args() { + public function test_customize_dynamic_partial_args() { do_action( 'customize_register', $this->wp_customize ); $args = apply_filters( 'customize_dynamic_partial_args', false, 'nav_menu_instance[68b329da9893e34099c7d8ad5cb9c940]' ); @@ -822,7 +822,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::customize_preview_init() */ - function test_customize_preview_init() { + public function test_customize_preview_init() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -837,7 +837,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @covers WP_Customize_Nav_Menus::make_auto_draft_status_previewable */ - function test_make_auto_draft_status_previewable() { + public function test_make_auto_draft_status_previewable() { global $wp_post_statuses; $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); $menus->make_auto_draft_status_previewable(); @@ -849,7 +849,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @covers WP_Customize_Nav_Menus::sanitize_nav_menus_created_posts */ - function test_sanitize_nav_menus_created_posts() { + public function test_sanitize_nav_menus_created_posts() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); $contributor_user_id = $this->factory()->user->create( array( 'role' => 'contributor' ) ); $author_user_id = $this->factory()->user->create( array( 'role' => 'author' ) ); @@ -923,7 +923,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @covers WP_Customize_Nav_Menus::save_nav_menus_created_posts */ - function test_save_nav_menus_created_posts() { + public function test_save_nav_menus_created_posts() { $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); do_action( 'customize_register', $this->wp_customize ); @@ -1031,7 +1031,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::filter_wp_nav_menu_args() */ - function test_filter_wp_nav_menu_args() { + public function test_filter_wp_nav_menu_args() { do_action( 'customize_register', $this->wp_customize ); $menus = $this->wp_customize->nav_menus; $menu_id = wp_create_nav_menu( 'Foo' ); @@ -1117,7 +1117,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * @covers WP_Customize_Nav_Menus::filter_wp_nav_menu * @covers WP_Customize_Nav_Menus::filter_wp_nav_menu_args */ - function test_filter_wp_nav_menu() { + public function test_filter_wp_nav_menu() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -1158,7 +1158,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::customize_preview_enqueue_deps() */ - function test_customize_preview_enqueue_deps() { + public function test_customize_preview_enqueue_deps() { do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); @@ -1172,7 +1172,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::export_preview_data() */ - function test_export_preview_data() { + public function test_export_preview_data() { ob_start(); $this->wp_customize->nav_menus->export_preview_data(); $html = ob_get_clean(); @@ -1186,7 +1186,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * * @see WP_Customize_Nav_Menus::render_nav_menu_partial() */ - function test_render_nav_menu_partial() { + public function test_render_nav_menu_partial() { $this->wp_customize->nav_menus->customize_preview_init(); $menu = wp_create_nav_menu( 'Foo' ); diff --git a/tests/phpunit/tests/customize/panel.php b/tests/phpunit/tests/customize/panel.php index 75166327b9..5aeaa6cb0b 100644 --- a/tests/phpunit/tests/customize/panel.php +++ b/tests/phpunit/tests/customize/panel.php @@ -12,7 +12,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { */ protected $manager; - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); @@ -20,7 +20,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { $this->undefined = new stdClass(); } - function tear_down() { + public function tear_down() { $this->manager = null; unset( $GLOBALS['wp_customize'] ); parent::tear_down(); @@ -29,7 +29,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::__construct() */ - function test_construct_default_args() { + public function test_construct_default_args() { $panel = new WP_Customize_Panel( $this->manager, 'foo' ); $this->assertIsInt( $panel->instance_number ); $this->assertSame( $this->manager, $panel->manager ); @@ -47,7 +47,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::__construct() */ - function test_construct_custom_args() { + public function test_construct_custom_args() { $args = array( 'priority' => 200, 'capability' => 'edit_posts', @@ -67,7 +67,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::__construct() */ - function test_construct_custom_type() { + public function test_construct_custom_type() { $panel = new Custom_Panel_Test( $this->manager, 'foo' ); $this->assertSame( 'titleless', $panel->type ); } @@ -76,7 +76,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::active() * @see WP_Customize_Panel::active_callback() */ - function test_active() { + public function test_active() { $panel = new WP_Customize_Panel( $this->manager, 'foo' ); $this->assertTrue( $panel->active() ); @@ -97,7 +97,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @param WP_Customize_Panel $panel * @return bool */ - function filter_active_test( $active, $panel ) { + public function filter_active_test( $active, $panel ) { $this->assertFalse( $active ); $this->assertInstanceOf( 'WP_Customize_Panel', $panel ); $active = true; @@ -107,7 +107,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::json() */ - function test_json() { + public function test_json() { $args = array( 'priority' => 200, 'capability' => 'edit_posts', @@ -131,7 +131,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::check_capabilities() */ - function test_check_capabilities() { + public function test_check_capabilities() { $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); @@ -149,7 +149,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::get_content() */ - function test_get_content() { + public function test_get_content() { $panel = new WP_Customize_Panel( $this->manager, 'foo' ); $this->assertEmpty( $panel->get_content() ); } @@ -157,7 +157,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::maybe_render() */ - function test_maybe_render() { + public function test_maybe_render() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $panel = new WP_Customize_Panel( $this->manager, 'bar' ); $customize_render_panel_count = did_action( 'customize_render_panel' ); @@ -175,14 +175,14 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { * @see WP_Customize_Panel::maybe_render() * @param WP_Customize_Panel $panel */ - function action_customize_render_panel_test( $panel ) { + public function action_customize_render_panel_test( $panel ) { $this->assertInstanceOf( 'WP_Customize_Panel', $panel ); } /** * @see WP_Customize_Panel::print_template() */ - function test_print_templates_standard() { + public function test_print_templates_standard() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $panel = new WP_Customize_Panel( $this->manager, 'baz' ); @@ -200,7 +200,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { /** * @see WP_Customize_Panel::print_template() */ - function test_print_templates_custom() { + public function test_print_templates_custom() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $panel = new Custom_Panel_Test( $this->manager, 'baz' ); diff --git a/tests/phpunit/tests/customize/partial.php b/tests/phpunit/tests/customize/partial.php index a47c0ccd1c..5e173a8acf 100644 --- a/tests/phpunit/tests/customize/partial.php +++ b/tests/phpunit/tests/customize/partial.php @@ -29,7 +29,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { /** * Set up. */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); @@ -44,7 +44,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::__construct() */ - function test_construct_default_args() { + public function test_construct_default_args() { $partial_id = 'blogname'; $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id ); $this->assertSame( $partial_id, $partial->id ); @@ -64,7 +64,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * @param WP_Customize_Partial $partial Partial. * @return string|false Content or false if error. */ - function render_post_content_partial( $partial ) { + public function render_post_content_partial( $partial ) { $id_data = $partial->id_data(); $post_id = (int) $id_data['keys'][0]; if ( empty( $post_id ) ) { @@ -82,7 +82,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::__construct() */ - function test_construct_non_default_args() { + public function test_construct_non_default_args() { $post_id = self::factory()->post->create( array( @@ -129,7 +129,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::id_data() */ - function test_id_data() { + public function test_id_data() { $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo' ); $id_data = $partial->id_data(); $this->assertSame( 'foo', $id_data['base'] ); @@ -163,7 +163,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * @param array $container_context Data. * @return string|false Content. */ - function filter_customize_partial_render( $rendered, $partial, $container_context ) { + public function filter_customize_partial_render( $rendered, $partial, $container_context ) { $this->assertTrue( false === $rendered || is_string( $rendered ) ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); $this->assertIsArray( $container_context ); @@ -179,7 +179,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * @param array $container_context Data. * @return string|false Content. */ - function filter_customize_partial_render_with_id( $rendered, $partial, $container_context ) { + public function filter_customize_partial_render_with_id( $rendered, $partial, $container_context ) { $this->assertSame( sprintf( 'customize_partial_render_%s', $partial->id ), current_filter() ); $this->assertTrue( false === $rendered || is_string( $rendered ) ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); @@ -193,7 +193,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @return string Content. */ - function render_echo_and_return() { + public function render_echo_and_return() { echo 'foo'; return 'bar'; } @@ -201,7 +201,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { /** * Echo render_callback(). */ - function render_echo() { + public function render_echo() { echo 'foo'; } @@ -210,7 +210,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @return string Content. */ - function render_return() { + public function render_return() { return 'bar'; } @@ -219,7 +219,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::render() */ - function test_render_with_bad_callback_should_give_preference_to_return_value() { + public function test_render_with_bad_callback_should_give_preference_to_return_value() { $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', @@ -236,7 +236,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::render() */ - function test_render_echo_callback() { + public function test_render_echo_callback() { $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', @@ -259,7 +259,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::render() */ - function test_render_return_callback() { + public function test_render_return_callback() { $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', @@ -282,7 +282,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::render_callback() */ - function test_render_callback_default() { + public function test_render_callback_default() { $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo' ); $this->assertFalse( $partial->render_callback( $partial, array() ) ); $this->assertFalse( call_user_func( $partial->render_callback, $partial, array() ) ); @@ -293,7 +293,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::json() */ - function test_json() { + public function test_json() { $post_id = 123; $partial_id = sprintf( 'post_content[%d]', $post_id ); $args = array( @@ -321,7 +321,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { * * @see WP_Customize_Partial::check_capabilities() */ - function test_check_capabilities() { + public function test_check_capabilities() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); do_action( 'customize_register', $this->wp_customize ); $partial = new WP_Customize_Partial( @@ -390,7 +390,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { /** * Tear down. */ - function tear_down() { + public function tear_down() { $this->wp_customize = null; unset( $GLOBALS['wp_customize'] ); parent::tear_down(); diff --git a/tests/phpunit/tests/customize/section.php b/tests/phpunit/tests/customize/section.php index e846d07535..50d58091b3 100644 --- a/tests/phpunit/tests/customize/section.php +++ b/tests/phpunit/tests/customize/section.php @@ -19,7 +19,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { */ protected $manager; - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); @@ -27,7 +27,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { $this->undefined = new stdClass(); } - function tear_down() { + public function tear_down() { $this->manager = null; unset( $GLOBALS['wp_customize'] ); parent::tear_down(); @@ -36,7 +36,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::__construct() */ - function test_construct_default_args() { + public function test_construct_default_args() { $section = new WP_Customize_Section( $this->manager, 'foo' ); $this->assertIsInt( $section->instance_number ); $this->assertSame( $this->manager, $section->manager ); @@ -54,7 +54,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::__construct() */ - function test_construct_custom_args() { + public function test_construct_custom_args() { $args = array( 'priority' => 200, 'capability' => 'edit_posts', @@ -77,7 +77,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::__construct() */ - function test_construct_custom_type() { + public function test_construct_custom_type() { $section = new Custom_Section_Test( $this->manager, 'foo' ); $this->assertSame( 'titleless', $section->type ); } @@ -86,7 +86,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @see WP_Customize_Section::active() * @see WP_Customize_Section::active_callback() */ - function test_active() { + public function test_active() { $section = new WP_Customize_Section( $this->manager, 'foo' ); $this->assertTrue( $section->active() ); @@ -107,7 +107,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @param WP_Customize_Section $section * @return bool */ - function filter_active_test( $active, $section ) { + public function filter_active_test( $active, $section ) { $this->assertFalse( $active ); $this->assertInstanceOf( 'WP_Customize_Section', $section ); $active = true; @@ -117,7 +117,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::json() */ - function test_json() { + public function test_json() { $args = array( 'priority' => 200, 'capability' => 'edit_posts', @@ -145,7 +145,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::check_capabilities() */ - function test_check_capabilities() { + public function test_check_capabilities() { wp_set_current_user( self::$admin_id ); $section = new WP_Customize_Section( $this->manager, 'foo' ); @@ -162,7 +162,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::get_content() */ - function test_get_content() { + public function test_get_content() { $section = new WP_Customize_Section( $this->manager, 'foo' ); $this->assertEmpty( $section->get_content() ); } @@ -170,7 +170,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::maybe_render() */ - function test_maybe_render() { + public function test_maybe_render() { wp_set_current_user( self::$admin_id ); $section = new WP_Customize_Section( $this->manager, 'bar' ); $customize_render_section_count = did_action( 'customize_render_section' ); @@ -188,14 +188,14 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { * @see WP_Customize_Section::maybe_render() * @param WP_Customize_Section $section */ - function action_customize_render_section_test( $section ) { + public function action_customize_render_section_test( $section ) { $this->assertInstanceOf( 'WP_Customize_Section', $section ); } /** * @see WP_Customize_Section::print_template() */ - function test_print_templates_standard() { + public function test_print_templates_standard() { wp_set_current_user( self::$admin_id ); $section = new WP_Customize_Section( $this->manager, 'baz' ); @@ -210,7 +210,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { /** * @see WP_Customize_Section::print_template() */ - function test_print_templates_custom() { + public function test_print_templates_custom() { wp_set_current_user( self::$admin_id ); $section = new Custom_Section_Test( $this->manager, 'baz' ); diff --git a/tests/phpunit/tests/customize/selective-refresh-ajax.php b/tests/phpunit/tests/customize/selective-refresh-ajax.php index 035bbd21de..541ca23b27 100644 --- a/tests/phpunit/tests/customize/selective-refresh-ajax.php +++ b/tests/phpunit/tests/customize/selective-refresh-ajax.php @@ -34,7 +34,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { /** * Set up the test fixture. */ - function set_up() { + public function set_up() { parent::set_up(); // Define wp_doing_ajax so that wp_die() will be used instead of die(). @@ -52,7 +52,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { /** * Do Customizer boot actions. */ - function do_customize_boot_actions() { + private function do_customize_boot_actions() { $_SERVER['REQUEST_METHOD'] = 'POST'; do_action( 'setup_theme' ); do_action( 'after_setup_theme' ); @@ -67,7 +67,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_render_partials_request_for_unauthenticated_user() { + public function test_handle_render_partials_request_for_unauthenticated_user() { $_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1'; // Check current_user_cannot_customize. @@ -123,7 +123,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { /** * Set the current user to be an admin, add the preview nonce, and set the query var. */ - function setup_valid_render_partials_request_environment() { + private function setup_valid_render_partials_request_environment() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->wp_customize->theme()->get_stylesheet() ); $_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1'; @@ -135,7 +135,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_render_partials_request_for_unrecognized_partial() { + public function test_handle_render_partials_request_for_unrecognized_partial() { $this->setup_valid_render_partials_request_environment(); $context_data = array(); $placements = array( $context_data ); @@ -172,7 +172,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_render_partials_request_for_non_rendering_partial() { + public function test_handle_render_partials_request_for_non_rendering_partial() { $this->setup_valid_render_partials_request_environment(); wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $this->wp_customize->add_setting( 'home' ); @@ -211,7 +211,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_rendering_disallowed_partial() { + public function test_handle_rendering_disallowed_partial() { $this->setup_valid_render_partials_request_environment(); wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $this->wp_customize->add_setting( @@ -247,7 +247,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_rendering_partial_with_missing_settings() { + public function test_handle_rendering_partial_with_missing_settings() { $this->setup_valid_render_partials_request_environment(); wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $this->wp_customize->selective_refresh->add_partial( 'bar', array( 'settings' => 'bar' ) ); @@ -279,7 +279,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @param array $context Context data. * @return string */ - function render_callback_blogname( $partial, $context ) { + public function render_callback_blogname( $partial, $context ) { $this->assertIsArray( $context ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); return get_bloginfo( 'name', 'display' ); @@ -292,7 +292,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @param array $context Context data. * @return string */ - function render_callback_blogdescription( $partial, $context ) { + public function render_callback_blogdescription( $partial, $context ) { $this->assertIsArray( $context ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); $x = get_bloginfo( 'description', 'display' ); @@ -304,7 +304,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_render_partials_request_with_single_valid_placement() { + public function test_handle_render_partials_request_with_single_valid_placement() { $this->setup_valid_render_partials_request_environment(); $this->wp_customize->selective_refresh->add_partial( @@ -353,7 +353,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @return array|false Args. */ - function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) { + public function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) { if ( 'test_dynamic_blogname' === $partial_id ) { $partial_args = array( 'settings' => array( 'blogname' ), @@ -373,7 +373,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * the placements' context data. * @return array Response. */ - function filter_customize_render_partials_response( $response, $component, $partial_placements ) { + public function filter_customize_render_partials_response( $response, $component, $partial_placements ) { $this->assertIsArray( $response ); $this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component ); if ( isset( $this->expected_partial_ids ) ) { @@ -395,7 +395,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @param WP_Customize_Selective_Refresh $component Selective refresh component. * @param array $partial_placements Partial IDs. */ - function handle_action_customize_render_partials_after( $component, $partial_placements ) { + public function handle_action_customize_render_partials_after( $component, $partial_placements ) { $this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component ); if ( isset( $this->expected_partial_ids ) ) { $this->assertSameSets( $this->expected_partial_ids, array_keys( $partial_placements ) ); @@ -408,7 +408,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @param WP_Customize_Selective_Refresh $component Selective refresh component. * @param array $partial_placements Partial IDs. */ - function handle_action_customize_render_partials_before( $component, $partial_placements ) { + public function handle_action_customize_render_partials_before( $component, $partial_placements ) { $this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component ); if ( isset( $this->expected_partial_ids ) ) { $this->assertSameSets( $this->expected_partial_ids, array_keys( $partial_placements ) ); @@ -420,7 +420,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_render_partials_request_for_dynamic_partial() { + public function test_handle_render_partials_request_for_dynamic_partial() { $this->setup_valid_render_partials_request_environment(); add_filter( 'customize_dynamic_partial_args', array( $this, 'filter_customize_dynamic_partial_args' ), 10, 2 ); @@ -458,7 +458,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::handle_render_partials_request() */ - function test_handle_render_partials_request_for_multiple_partials_placements() { + public function test_handle_render_partials_request_for_multiple_partials_placements() { $this->setup_valid_render_partials_request_environment(); $this->wp_customize->selective_refresh->add_partial( @@ -509,7 +509,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { /** * Tear down. */ - function tear_down() { + public function tear_down() { $this->expected_partial_ids = null; $this->wp_customize = null; unset( $GLOBALS['wp_customize'] ); diff --git a/tests/phpunit/tests/customize/selective-refresh.php b/tests/phpunit/tests/customize/selective-refresh.php index c8e649b219..b3cf7fd84a 100644 --- a/tests/phpunit/tests/customize/selective-refresh.php +++ b/tests/phpunit/tests/customize/selective-refresh.php @@ -29,7 +29,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { /** * Set up the test fixture. */ - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); @@ -44,7 +44,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::__construct() */ - function test_construct() { + public function test_construct() { $this->assertSame( $this->selective_refresh, $this->wp_customize->selective_refresh ); } @@ -53,7 +53,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::register_scripts() */ - function test_register_scripts() { + public function test_register_scripts() { $scripts = new WP_Scripts(); $handles = array( 'customize-selective-refresh', @@ -70,7 +70,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::partials() */ - function test_partials() { + public function test_partials() { $this->assertIsArray( $this->selective_refresh->partials() ); } @@ -81,7 +81,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * @see WP_Customize_Selective_Refresh::add_partial() * @see WP_Customize_Selective_Refresh::remove_partial() */ - function test_crud_partial() { + public function test_crud_partial() { $partial = $this->selective_refresh->add_partial( 'foo' ); $this->assertSame( $this->selective_refresh, $partial->component ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); @@ -110,7 +110,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::init_preview() */ - function test_init_preview() { + public function test_init_preview() { $this->selective_refresh->init_preview(); $this->assertSame( 10, has_action( 'template_redirect', array( $this->selective_refresh, 'handle_render_partials_request' ) ) ); $this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $this->selective_refresh, 'enqueue_preview_scripts' ) ) ); @@ -121,7 +121,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::enqueue_preview_scripts() */ - function test_enqueue_preview_scripts() { + public function test_enqueue_preview_scripts() { $scripts = wp_scripts(); $this->assertNotContains( 'customize-selective-refresh', $scripts->queue ); $this->selective_refresh->enqueue_preview_scripts(); @@ -134,7 +134,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::export_preview_data() */ - function test_export_preview_data() { + public function test_export_preview_data() { $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); $user = new WP_User( $user_id ); @@ -178,7 +178,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::add_dynamic_partials() */ - function test_add_dynamic_partials() { + public function test_add_dynamic_partials() { $partial_ids = array( 'recognized', 'recognized-class', 'unrecognized', 'already-added' ); $partials = $this->selective_refresh->add_dynamic_partials( $partial_ids ); @@ -206,7 +206,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * @param string $partial_id ID for dynamic partial. * @return false|array Dynamic partial args. */ - function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) { + public function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) { $this->assertTrue( false === $partial_args || is_array( $partial_args ) ); $this->assertIsString( $partial_id ); @@ -229,7 +229,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * @param array $partial_args The arguments to the WP_Customize_Partial constructor. * @return string */ - function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) { + public function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) { $this->assertIsArray( $partial_args ); $this->assertIsString( $partial_id ); $this->assertIsString( $partial_class ); @@ -246,7 +246,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * * @see WP_Customize_Selective_Refresh::is_render_partials_request() */ - function test_is_render_partials_request() { + public function test_is_render_partials_request() { $this->assertFalse( $this->selective_refresh->is_render_partials_request() ); $_POST[ WP_Customize_Selective_Refresh::RENDER_QUERY_VAR ] = '1'; $this->assertTrue( $this->selective_refresh->is_render_partials_request() ); @@ -255,7 +255,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { /** * Tear down. */ - function tear_down() { + public function tear_down() { $this->wp_customize = null; unset( $GLOBALS['wp_customize'] ); unset( $GLOBALS['wp_scripts'] ); diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php index b1fe0fd96c..3e9fb1db9b 100644 --- a/tests/phpunit/tests/customize/setting.php +++ b/tests/phpunit/tests/customize/setting.php @@ -17,7 +17,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { */ public $undefined; - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); @@ -25,13 +25,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { $this->undefined = new stdClass(); } - function tear_down() { + public function tear_down() { $this->manager = null; unset( $GLOBALS['wp_customize'] ); parent::tear_down(); } - function test_constructor_without_args() { + public function test_constructor_without_args() { $setting = new WP_Customize_Setting( $this->manager, 'foo' ); $this->assertSame( $this->manager, $setting->manager ); $this->assertSame( 'foo', $setting->id ); @@ -84,11 +84,11 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @param mixed $value The setting value. * @param WP_Customize_Setting $setting The setting object. */ - function sanitize_js_callback_base64_for_testing( $value, $setting ) { + public function sanitize_js_callback_base64_for_testing( $value, $setting ) { return base64_encode( $value ); } - function test_constructor_with_args() { + public function test_constructor_with_args() { $args = array( 'type' => 'option', 'capability' => 'edit_posts', @@ -136,7 +136,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * * @see WP_Customize_Setting::value() */ - function test_preview_standard_types_non_multidimensional() { + public function test_preview_standard_types_non_multidimensional() { wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) ); @@ -215,7 +215,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @see WP_Customize_Setting::preview() * @see WP_Customize_Setting::value() */ - function test_preview_standard_types_multidimensional() { + public function test_preview_standard_types_multidimensional() { wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) ); @@ -316,7 +316,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { */ protected $custom_type_data_previewed; - function custom_type_getter( $name, $default = null ) { + private function custom_type_getter( $name, $default = null ) { if ( did_action( "customize_preview_{$name}" ) && array_key_exists( $name, $this->custom_type_data_previewed ) ) { $value = $this->custom_type_data_previewed[ $name ]; } elseif ( array_key_exists( $name, $this->custom_type_data_saved ) ) { @@ -327,7 +327,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { return $value; } - function custom_type_setter( $name, $value ) { + private function custom_type_setter( $name, $value ) { $this->custom_type_data_saved[ $name ] = $value; } @@ -339,7 +339,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * * @return mixed|null */ - function custom_type_value_filter( $default, $setting = null ) { + public function custom_type_value_filter( $default, $setting = null ) { $name = preg_replace( '/^customize_value_/', '', current_filter() ); $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); $id_data = $setting->id_data(); @@ -350,7 +350,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { /** * @param WP_Customize_Setting $setting */ - function custom_type_preview( $setting ) { + public function custom_type_preview( $setting ) { $previewed_value = $setting->post_value( $this->undefined ); if ( $this->undefined !== $previewed_value ) { $this->custom_type_data_previewed[ $setting->id ] = $previewed_value; @@ -361,7 +361,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * * @see WP_Customize_Setting::preview() */ - function test_preview_custom_type() { + public function test_preview_custom_type() { wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); $type = 'custom_type'; $post_data_overrides = array( @@ -473,7 +473,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * * @ticket 30988 */ - function test_non_posted_setting_applying_default_value_in_preview() { + public function test_non_posted_setting_applying_default_value_in_preview() { $type = 'option'; $name = 'unset_option_without_post_value'; $default = "default_value_{$name}"; @@ -491,7 +491,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @see WP_Customize_Setting::save() * @see WP_Customize_Setting::update() */ - function test_update_custom_type() { + public function test_update_custom_type() { $type = 'custom'; $name = 'foo'; $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) ); @@ -526,7 +526,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @param mixed $value * @param WP_Customize_Setting $setting */ - function handle_customize_update_custom_foo_action( $value, $setting = null ) { + public function handle_customize_update_custom_foo_action( $value, $setting = null ) { $this->assertSame( 'hello world \\o/', $value ); $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); } @@ -537,7 +537,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @see Tests_WP_Customize_Setting::test_update_custom_type() * @param WP_Customize_Setting $setting */ - function handle_customize_save_custom_foo_action( $setting ) { + public function handle_customize_save_custom_foo_action( $setting ) { $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); $this->assertSame( 'custom', $setting->type ); $this->assertSame( 'foo', $setting->id ); @@ -550,7 +550,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * * @ticket 31428 */ - function test_is_current_blog_previewed() { + public function test_is_current_blog_previewed() { wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); $type = 'option'; $name = 'blogname'; @@ -572,7 +572,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { * @group multisite * @group ms-required */ - function test_previewing_with_switch_to_blog() { + public function test_previewing_with_switch_to_blog() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); $type = 'option'; $name = 'blogdescription'; @@ -594,7 +594,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { /** * @ticket 33499 */ - function test_option_autoloading() { + public function test_option_autoloading() { global $wpdb; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index 6174999c4f..446bcf5a68 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -20,7 +20,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { */ protected $backup_registered_sidebars; - function set_up() { + public function set_up() { parent::set_up(); require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; @@ -78,7 +78,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { WP_Customize_Setting::reset_aggregated_multidimensionals(); } - function clean_up_global_scope() { + public function clean_up_global_scope() { global $wp_widget_factory, $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; $wp_registered_sidebars = array(); @@ -90,7 +90,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { parent::clean_up_global_scope(); } - function tear_down() { + public function tear_down() { $this->manager = null; unset( $GLOBALS['wp_customize'] ); unset( $GLOBALS['wp_scripts'] ); @@ -98,7 +98,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { parent::tear_down(); } - function set_customized_post_data( $customized ) { + private function set_customized_post_data( $customized ) { $_POST['customized'] = wp_slash( wp_json_encode( $customized ) ); if ( $this->manager ) { foreach ( $customized as $id => $value ) { @@ -107,7 +107,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { } } - function do_customize_boot_actions() { + private function do_customize_boot_actions() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_REQUEST['nonce'] = wp_create_nonce( 'preview-customize_' . $this->manager->theme()->get_stylesheet() ); do_action( 'setup_theme' ); @@ -117,14 +117,14 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { do_action( 'wp', $GLOBALS['wp'] ); } - function remove_widgets_block_editor() { + public function remove_widgets_block_editor() { remove_theme_support( 'widgets-block-editor' ); } /** * Test WP_Customize_Widgets::__construct() */ - function test_construct() { + public function test_construct() { $this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets ); $this->assertSame( $this->manager, $this->manager->widgets->manager ); } @@ -136,7 +136,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * @see WP_Customize_Widgets::preview_sidebars_widgets() * @ticket 36660 */ - function test_customize_register_with_deleted_sidebars() { + public function test_customize_register_with_deleted_sidebars() { $sidebar_id = 'sidebar-1'; delete_option( 'sidebars_widgets' ); register_sidebar( array( 'id' => $sidebar_id ) ); @@ -228,7 +228,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::get_selective_refreshable_widgets() */ - function test_get_selective_refreshable_widgets_when_theme_supports() { + public function test_get_selective_refreshable_widgets_when_theme_supports() { global $wp_widget_factory; add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 ); add_theme_support( 'customize-selective-refresh-widgets' ); @@ -248,7 +248,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::get_selective_refreshable_widgets() */ - function test_get_selective_refreshable_widgets_when_no_theme_supports() { + public function test_get_selective_refreshable_widgets_when_no_theme_supports() { add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 ); remove_theme_support( 'customize-selective-refresh-widgets' ); $this->do_customize_boot_actions(); @@ -262,7 +262,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * @see Tests_WP_Customize_Widgets::test_get_selective_refreshable_widgets_when_theme_supports() * @see Tests_WP_Customize_Widgets::test_get_selective_refreshable_widgets_when_no_theme_supports() */ - function override_search_widget_customize_selective_refresh() { + public function override_search_widget_customize_selective_refresh() { global $wp_widget_factory; $wp_widget_factory->widgets['WP_Widget_Search']->widget_options['customize_selective_refresh'] = false; } @@ -272,7 +272,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::is_widget_selective_refreshable() */ - function test_is_widget_selective_refreshable() { + public function test_is_widget_selective_refreshable() { add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 ); add_theme_support( 'customize-selective-refresh-widgets' ); $this->do_customize_boot_actions(); @@ -288,7 +288,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * @ticket 30988 * @ticket 36389 */ - function test_register_settings() { + public function test_register_settings() { add_theme_support( 'customize-selective-refresh-widgets' ); $raw_widget_customized = array( @@ -340,7 +340,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @ticket 36389 */ - function test_register_settings_without_selective_refresh() { + public function test_register_settings_without_selective_refresh() { remove_theme_support( 'customize-selective-refresh-widgets' ); $this->test_register_settings(); } @@ -350,7 +350,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @ticket 36389 */ - function test_register_settings_with_late_theme_support_added() { + public function test_register_settings_with_late_theme_support_added() { remove_theme_support( 'customize-selective-refresh-widgets' ); add_action( 'after_setup_theme', array( $this, 'add_customize_selective_refresh_theme_support' ), 100 ); $this->test_register_settings(); @@ -359,14 +359,14 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { /** * Add customize-selective-refresh-widgets theme support. */ - function add_customize_selective_refresh_theme_support() { + public function add_customize_selective_refresh_theme_support() { add_theme_support( 'customize-selective-refresh-widgets' ); } /** * Test WP_Customize_Widgets::get_setting_args() */ - function test_get_setting_args() { + public function test_get_setting_args() { add_theme_support( 'customize-selective-refresh-widgets' ); $this->do_customize_boot_actions(); @@ -447,7 +447,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $this->assertSame( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] ); } - function filter_widget_customizer_setting_args( $args, $id ) { + public function filter_widget_customizer_setting_args( $args, $id ) { $args['uppercase_id_set_by_filter'] = strtoupper( $id ); return $args; } @@ -455,7 +455,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { /** * Test WP_Customize_Widgets::sanitize_widget_js_instance() and WP_Customize_Widgets::sanitize_widget_instance() */ - function test_sanitize_widget_js_instance() { + public function test_sanitize_widget_js_instance() { $this->do_customize_boot_actions(); $new_categories_instance = array( @@ -486,7 +486,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @ticket 53489 */ - function test_sanitize_widget_instance_raw_instance() { + public function test_sanitize_widget_instance_raw_instance() { remove_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) ); $this->do_customize_boot_actions(); @@ -513,7 +513,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @ticket 53489 */ - function test_sanitize_widget_instance_with_no_show_instance_in_rest() { + public function test_sanitize_widget_instance_with_no_show_instance_in_rest() { global $wp_widget_factory; remove_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) ); @@ -544,7 +544,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @ticket 53479 */ - function test_sanitize_widget_instance_empty_instance() { + public function test_sanitize_widget_instance_empty_instance() { $this->do_customize_boot_actions(); $this->assertSame( $this->manager->widgets->sanitize_widget_instance( array() ), array() ); } @@ -554,7 +554,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @return array */ - function get_test_widget_control_args() { + private function get_test_widget_control_args() { global $wp_registered_widgets; require_once ABSPATH . '/wp-admin/includes/widgets.php'; $widget_id = 'search-2'; @@ -575,7 +575,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { /** * @see WP_Customize_Widgets::get_widget_control() */ - function test_get_widget_control() { + public function test_get_widget_control() { $this->do_customize_boot_actions(); $widget_control = $this->manager->widgets->get_widget_control( $this->get_test_widget_control_args() ); @@ -588,7 +588,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { /** * @see WP_Customize_Widgets::get_widget_control_parts() */ - function test_get_widget_control_parts() { + public function test_get_widget_control_parts() { $this->do_customize_boot_actions(); $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $this->get_test_widget_control_args() ); $this->assertArrayHasKey( 'content', $widget_control_parts ); @@ -604,7 +604,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { /** * @see WP_Widget_Form_Customize_Control::json() */ - function test_wp_widget_form_customize_control_json() { + public function test_wp_widget_form_customize_control_json() { $this->do_customize_boot_actions(); $control = $this->manager->get_control( 'widget_search[2]' ); $params = $control->json(); @@ -626,7 +626,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { /** * @see WP_Customize_Widgets::is_panel_active() */ - function test_is_panel_active() { + public function test_is_panel_active() { global $wp_registered_sidebars; $this->do_customize_boot_actions(); @@ -643,7 +643,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * @ticket 34738 * @see WP_Customize_Widgets::call_widget_update() */ - function test_call_widget_update() { + public function test_call_widget_update() { $widget_number = 2; $widget_id = "search-{$widget_number}"; @@ -699,7 +699,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::customize_dynamic_partial_args() */ - function test_customize_dynamic_partial_args() { + public function test_customize_dynamic_partial_args() { do_action( 'customize_register', $this->manager ); $args = apply_filters( 'customize_dynamic_partial_args', false, 'widget[search-2]' ); @@ -725,7 +725,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::selective_refresh_init() */ - function test_selective_refresh_init_with_theme_support() { + public function test_selective_refresh_init_with_theme_support() { add_theme_support( 'customize-selective-refresh-widgets' ); $this->manager->widgets->selective_refresh_init(); $this->assertSame( 10, has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) ); @@ -739,7 +739,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::selective_refresh_init() */ - function test_selective_refresh_init_without_theme_support() { + public function test_selective_refresh_init_without_theme_support() { remove_theme_support( 'customize-selective-refresh-widgets' ); $this->manager->widgets->selective_refresh_init(); $this->assertFalse( has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) ); @@ -753,7 +753,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::customize_preview_enqueue() */ - function test_customize_preview_enqueue() { + public function test_customize_preview_enqueue() { $this->manager->widgets->customize_preview_enqueue(); $this->assertTrue( wp_script_is( 'customize-preview-widgets', 'enqueued' ) ); $this->assertTrue( wp_style_is( 'customize-preview', 'enqueued' ) ); @@ -768,7 +768,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * @see WP_Customize_Widgets::start_dynamic_sidebar() * @see WP_Customize_Widgets::end_dynamic_sidebar() */ - function test_filter_dynamic_sidebar_params() { + public function test_filter_dynamic_sidebar_params() { global $wp_registered_sidebars; register_sidebar( array( @@ -823,7 +823,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { * * @see WP_Customize_Widgets::render_widget_partial() */ - function test_render_widget_partial() { + public function test_render_widget_partial() { add_theme_support( 'customize-selective-refresh-widgets' ); $this->do_customize_boot_actions(); $this->manager->widgets->selective_refresh_init(); diff --git a/tests/phpunit/tests/date/getFeedBuildDate.php b/tests/phpunit/tests/date/getFeedBuildDate.php index de7a1d58a8..23d97aa473 100644 --- a/tests/phpunit/tests/date/getFeedBuildDate.php +++ b/tests/phpunit/tests/date/getFeedBuildDate.php @@ -8,7 +8,7 @@ */ class Tests_Date_GetFeedBuildDate extends WP_UnitTestCase { - function tear_down() { + public function tear_down() { global $wp_query; update_option( 'timezone_string', 'UTC' ); diff --git a/tests/phpunit/tests/date/getPermalink.php b/tests/phpunit/tests/date/getPermalink.php index f1efdfe66e..41977c7734 100644 --- a/tests/phpunit/tests/date/getPermalink.php +++ b/tests/phpunit/tests/date/getPermalink.php @@ -8,7 +8,7 @@ */ class Tests_Date_GetPermalink extends WP_UnitTestCase { - function tear_down() { + public function tear_down() { delete_option( 'permalink_structure' ); update_option( 'timezone_string', 'UTC' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set diff --git a/tests/phpunit/tests/date/mysql2date.php b/tests/phpunit/tests/date/mysql2date.php index 2591875e63..7c83446b00 100644 --- a/tests/phpunit/tests/date/mysql2date.php +++ b/tests/phpunit/tests/date/mysql2date.php @@ -7,7 +7,7 @@ */ class Tests_Date_mysql2date extends WP_UnitTestCase { - function tear_down() { + public function tear_down() { // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( 'UTC' ); @@ -17,14 +17,14 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { /** * @ticket 28310 */ - function test_mysql2date_returns_false_with_no_date() { + public function test_mysql2date_returns_false_with_no_date() { $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) ); } /** * @ticket 28310 */ - function test_mysql2date_returns_gmt_or_unix_timestamp() { + public function test_mysql2date_returns_gmt_or_unix_timestamp() { $this->assertSame( 441013392, mysql2date( 'G', '1983-12-23 07:43:12' ) ); $this->assertSame( 441013392, mysql2date( 'U', '1983-12-23 07:43:12' ) ); } @@ -32,7 +32,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { /** * @ticket 28992 */ - function test_mysql2date_should_format_time() { + public function test_mysql2date_should_format_time() { $timezone = 'Europe/Kiev'; update_option( 'timezone_string', $timezone ); $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) ); @@ -46,7 +46,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { /** * @ticket 28992 */ - function test_mysql2date_should_format_time_with_changed_time_zone() { + public function test_mysql2date_should_format_time_with_changed_time_zone() { $timezone = 'Europe/Kiev'; // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( $timezone ); @@ -62,7 +62,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { /** * @ticket 28992 */ - function test_mysql2date_should_return_wp_timestamp() { + public function test_mysql2date_should_return_wp_timestamp() { $timezone = 'Europe/Kiev'; update_option( 'timezone_string', $timezone ); $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) ); @@ -76,7 +76,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { /** * @ticket 28992 */ - function test_mysql2date_should_return_unix_timestamp_for_gmt_time() { + public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() { $timezone = 'Europe/Kiev'; update_option( 'timezone_string', $timezone ); $datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); diff --git a/tests/phpunit/tests/date/theDate.php b/tests/phpunit/tests/date/theDate.php index f0d93f9f75..b5fcb793df 100644 --- a/tests/phpunit/tests/date/theDate.php +++ b/tests/phpunit/tests/date/theDate.php @@ -88,7 +88,7 @@ class Tests_Date_TheDate extends WP_UnitTestCase { /** * @ticket 33750 */ - function test_the_date() { + public function test_the_date() { ob_start(); the_date(); $actual = ob_get_clean(); @@ -128,7 +128,7 @@ class Tests_Date_TheDate extends WP_UnitTestCase { /** * @ticket 47354 */ - function test_the_weekday_date() { + public function test_the_weekday_date() { ob_start(); the_weekday_date(); $actual = ob_get_clean(); diff --git a/tests/phpunit/tests/date/xmlrpc.php b/tests/phpunit/tests/date/xmlrpc.php index b2275403d8..8f8fb2859d 100644 --- a/tests/phpunit/tests/date/xmlrpc.php +++ b/tests/phpunit/tests/date/xmlrpc.php @@ -212,7 +212,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { * * @covers wp_xmlrpc_server::wp_editComment */ - function test_date_edit_comment() { + public function test_date_edit_comment() { $timezone = 'Europe/Kiev'; update_option( 'timezone_string', $timezone ); diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index 2320e30ed5..e10de7126e 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -121,7 +121,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 10041 */ - function test_esc_like() { + public function test_esc_like() { global $wpdb; $inputs = array( @@ -157,12 +157,12 @@ class Tests_DB extends WP_UnitTestCase { * @param $like string The like phrase, raw. * @param $result string The expected comparison result; '1' = true, '0' = false */ - function test_like_query( $data, $like, $result ) { + public function test_like_query( $data, $like, $result ) { global $wpdb; return $this->assertSame( $result, $wpdb->get_var( $wpdb->prepare( 'SELECT %s LIKE %s', $data, $wpdb->esc_like( $like ) ) ) ); } - function data_like_query() { + public function data_like_query() { return array( array( 'aaa', @@ -220,7 +220,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 18510 */ - function test_wpdb_supposedly_protected_properties() { + public function test_wpdb_supposedly_protected_properties() { global $wpdb; $this->assertNotEmpty( $wpdb->dbh ); @@ -236,7 +236,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 21212 */ - function test_wpdb_actually_protected_properties() { + public function test_wpdb_actually_protected_properties() { global $wpdb; $new_meta = "HAHA I HOPE THIS DOESN'T WORK"; @@ -251,7 +251,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 18510 */ - function test_wpdb_nonexistent_properties() { + public function test_wpdb_nonexistent_properties() { global $wpdb; $this->assertTrue( empty( $wpdb->nonexistent_property ) ); @@ -282,7 +282,7 @@ class Tests_DB extends WP_UnitTestCase { * * @ticket 26847 */ - function test_set_sql_mode() { + public function test_set_sql_mode() { global $wpdb; $current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); @@ -302,7 +302,7 @@ class Tests_DB extends WP_UnitTestCase { * * @ticket 26847 */ - function test_set_incompatible_sql_mode() { + public function test_set_incompatible_sql_mode() { global $wpdb; $current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); @@ -320,7 +320,7 @@ class Tests_DB extends WP_UnitTestCase { * * @ticket 26847 */ - function test_set_allowed_incompatible_sql_mode() { + public function test_set_allowed_incompatible_sql_mode() { global $wpdb; $current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); @@ -353,7 +353,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 25604 * @expectedIncorrectUsage wpdb::prepare */ - function test_prepare_without_arguments() { + public function test_prepare_without_arguments() { global $wpdb; $id = 0; // This, obviously, is an incorrect prepare. @@ -362,7 +362,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared ); } - function test_prepare_sprintf() { + public function test_prepare_sprintf() { global $wpdb; $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", 1, 'admin' ); @@ -372,7 +372,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @expectedIncorrectUsage wpdb::prepare */ - function test_prepare_sprintf_invalid_args() { + public function test_prepare_sprintf_invalid_args() { global $wpdb; // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged @@ -384,7 +384,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); } - function test_prepare_vsprintf() { + public function test_prepare_vsprintf() { global $wpdb; $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1, 'admin' ) ); @@ -394,7 +394,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @expectedIncorrectUsage wpdb::prepare */ - function test_prepare_vsprintf_invalid_args() { + public function test_prepare_vsprintf_invalid_args() { global $wpdb; // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged @@ -471,13 +471,13 @@ class Tests_DB extends WP_UnitTestCase { ); } - function test_db_version() { + public function test_db_version() { global $wpdb; $this->assertTrue( version_compare( $wpdb->db_version(), '5.0', '>=' ) ); } - function test_get_caller() { + public function test_get_caller() { global $wpdb; $str = $wpdb->get_caller(); $calls = explode( ', ', $str ); @@ -485,7 +485,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( $called, end( $calls ) ); } - function test_has_cap() { + public function test_has_cap() { global $wpdb; $this->assertTrue( $wpdb->has_cap( 'collation' ) ); $this->assertTrue( $wpdb->has_cap( 'group_concat' ) ); @@ -506,24 +506,24 @@ class Tests_DB extends WP_UnitTestCase { /** * @expectedDeprecated supports_collation */ - function test_supports_collation() { + public function test_supports_collation() { global $wpdb; $this->assertTrue( $wpdb->supports_collation() ); } - function test_check_database_version() { + public function test_check_database_version() { global $wpdb; $this->assertEmpty( $wpdb->check_database_version() ); } - function test_bail() { + public function test_bail() { global $wpdb; $this->expectException( 'WPDieException' ); $wpdb->bail( 'Database is dead.' ); } - function test_timers() { + public function test_timers() { global $wpdb; $wpdb->timer_start(); @@ -534,7 +534,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertGreaterThan( $stop, $wpdb->time_start ); } - function test_get_col_info() { + public function test_get_col_info() { global $wpdb; $wpdb->get_results( "SELECT ID FROM $wpdb->users" ); @@ -544,7 +544,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) ); } - function test_query_and_delete() { + public function test_query_and_delete() { global $wpdb; $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); $this->assertSame( 1, $rows ); @@ -553,7 +553,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( 1, $d_rows ); } - function test_get_row() { + public function test_get_row() { global $wpdb; $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); $this->assertSame( 1, $rows ); @@ -576,7 +576,7 @@ class Tests_DB extends WP_UnitTestCase { * * @ticket 45299 */ - function test_get_col( $query, $expected, $last_result, $column ) { + public function test_get_col( $query, $expected, $last_result, $column ) { global $wpdb; $wpdb->last_result = $last_result; @@ -606,7 +606,7 @@ class Tests_DB extends WP_UnitTestCase { * @type arrray|string|null $last_result The value to assign to `$wpdb->last_result`. * @type int|string $column The column index to retrieve. */ - function data_test_get_col() { + public function data_test_get_col() { global $wpdb; return array( @@ -655,7 +655,7 @@ class Tests_DB extends WP_UnitTestCase { ); } - function test_replace() { + public function test_replace() { global $wpdb; $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) ); $this->assertSame( 1, $rows1 ); @@ -683,7 +683,7 @@ class Tests_DB extends WP_UnitTestCase { * * @ticket 26106 */ - function test_empty_where_on_update() { + public function test_empty_where_on_update() { global $wpdb; $suppress = $wpdb->suppress_errors( true ); $wpdb->update( $wpdb->posts, array( 'post_name' => 'burrito' ), array() ); @@ -705,7 +705,7 @@ class Tests_DB extends WP_UnitTestCase { * * @ticket 28155 */ - function test_mysqli_flush_sync() { + public function test_mysqli_flush_sync() { global $wpdb; if ( ! $wpdb->use_mysqli ) { $this->markTestSkipped( 'mysqli not being used.' ); @@ -741,7 +741,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 21212 * @ticket 32763 */ - function data_get_table_from_query() { + public function data_get_table_from_query() { $table = 'a_test_table_name'; $more_tables = array( // table_name => expected_value @@ -865,11 +865,11 @@ class Tests_DB extends WP_UnitTestCase { * @dataProvider data_get_table_from_query * @ticket 21212 */ - function test_get_table_from_query( $query, $table ) { + public function test_get_table_from_query( $query, $table ) { $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) ); } - function data_get_table_from_query_false() { + public function data_get_table_from_query_false() { $table = 'a_test_table_name'; return array( array( "LOL THIS ISN'T EVEN A QUERY $table" ), @@ -880,14 +880,14 @@ class Tests_DB extends WP_UnitTestCase { * @dataProvider data_get_table_from_query_false * @ticket 21212 */ - function test_get_table_from_query_false( $query ) { + public function test_get_table_from_query_false( $query ) { $this->assertFalse( self::$_wpdb->get_table_from_query( $query ) ); } /** * @ticket 38751 */ - function data_get_escaped_table_from_show_query() { + public function data_get_escaped_table_from_show_query() { return array( // Equality. array( "SHOW TABLE STATUS WHERE Name = 'test_name'", 'test_name' ), @@ -907,14 +907,14 @@ class Tests_DB extends WP_UnitTestCase { * @dataProvider data_get_escaped_table_from_show_query * @ticket 38751 */ - function test_get_escaped_table_from_show_query( $query, $table ) { + public function test_get_escaped_table_from_show_query( $query, $table ) { $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) ); } /** * @ticket 21212 */ - function data_process_field_formats() { + public function data_process_field_formats() { $core_db_fields_no_format_specified = array( array( 'post_content' => 'foo', @@ -1022,7 +1022,7 @@ class Tests_DB extends WP_UnitTestCase { * @dataProvider data_process_field_formats * @ticket 21212 */ - function test_process_field_formats( $data, $format, $expected, $message ) { + public function test_process_field_formats( $data, $format, $expected, $message ) { $actual = self::$_wpdb->process_field_formats( $data, $format ); $this->assertSame( $expected, $actual, $message ); } @@ -1030,7 +1030,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 21212 */ - function test_process_fields() { + public function test_process_fields() { global $wpdb; if ( $wpdb->charset ) { @@ -1060,7 +1060,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 21212 * @depends test_process_fields */ - function test_process_fields_on_nonexistent_table( $data ) { + public function test_process_fields_on_nonexistent_table( $data ) { self::$_wpdb->suppress_errors( true ); $data = array( 'post_content' => '¡foo foo foo!' ); $this->assertFalse( self::$_wpdb->process_fields( 'nonexistent_table', $data, null ) ); @@ -1070,35 +1070,35 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 21212 */ - function test_pre_get_table_charset_filter() { + public function test_pre_get_table_charset_filter() { add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 ); $charset = self::$_wpdb->get_table_charset( 'some_table' ); remove_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10 ); $this->assertSame( $charset, 'fake_charset' ); } - function filter_pre_get_table_charset( $charset, $table ) { + public function filter_pre_get_table_charset( $charset, $table ) { return 'fake_charset'; } /** * @ticket 21212 */ - function test_pre_get_col_charset_filter() { + public function test_pre_get_col_charset_filter() { add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 ); $charset = self::$_wpdb->get_col_charset( 'some_table', 'some_col' ); remove_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10 ); $this->assertSame( $charset, 'fake_col_charset' ); } - function filter_pre_get_col_charset( $charset, $table, $column ) { + public function filter_pre_get_col_charset( $charset, $table, $column ) { return 'fake_col_charset'; } /** * @ticket 15158 */ - function test_null_insert() { + public function test_null_insert() { global $wpdb; $key = 'null_insert_key'; @@ -1120,7 +1120,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 15158 */ - function test_null_update_value() { + public function test_null_update_value() { global $wpdb; $key = 'null_update_value_key'; @@ -1158,7 +1158,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 15158 */ - function test_null_update_where() { + public function test_null_update_where() { global $wpdb; $key = 'null_update_where_key'; @@ -1196,7 +1196,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 15158 */ - function test_null_delete() { + public function test_null_delete() { global $wpdb; $key = 'null_update_where_key'; @@ -1232,7 +1232,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 34903 */ - function test_close() { + public function test_close() { global $wpdb; $this->assertTrue( $wpdb->close() ); @@ -1251,7 +1251,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 36917 */ - function test_charset_not_determined_when_disconnected() { + public function test_charset_not_determined_when_disconnected() { global $wpdb; $charset = 'utf8'; @@ -1269,7 +1269,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 36917 */ - function test_charset_switched_to_utf8mb4() { + public function test_charset_switched_to_utf8mb4() { global $wpdb; if ( ! $wpdb->has_cap( 'utf8mb4' ) ) { @@ -1288,7 +1288,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 32105 * @ticket 36917 */ - function test_collate_switched_to_utf8mb4_520() { + public function test_collate_switched_to_utf8mb4_520() { global $wpdb; if ( ! $wpdb->has_cap( 'utf8mb4_520' ) ) { @@ -1307,7 +1307,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 32405 * @ticket 36917 */ - function test_non_unicode_collations() { + public function test_non_unicode_collations() { global $wpdb; if ( ! $wpdb->has_cap( 'utf8mb4' ) ) { @@ -1325,7 +1325,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @ticket 37982 */ - function test_charset_switched_to_utf8() { + public function test_charset_switched_to_utf8() { global $wpdb; if ( $wpdb->has_cap( 'utf8mb4' ) ) { @@ -1344,7 +1344,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @dataProvider data_prepare_with_placeholders */ - function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) { + public function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) { global $wpdb; if ( $incorrect_usage ) { @@ -1363,7 +1363,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @dataProvider data_prepare_with_placeholders */ - function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) { + public function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) { global $wpdb; if ( $incorrect_usage ) { @@ -1379,7 +1379,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( $expected, $sql ); } - function data_prepare_with_placeholders() { + public function data_prepare_with_placeholders() { global $wpdb; return array( @@ -1557,7 +1557,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @dataProvider data_escape_and_prepare */ - function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) { + public function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) { global $wpdb; if ( $incorrect_usage ) { @@ -1574,7 +1574,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( $expected, $actual ); } - function data_escape_and_prepare() { + public function data_escape_and_prepare() { global $wpdb; return array( array( @@ -1604,7 +1604,7 @@ class Tests_DB extends WP_UnitTestCase { /** * @expectedIncorrectUsage wpdb::prepare */ - function test_double_prepare() { + public function test_double_prepare() { global $wpdb; $part = $wpdb->prepare( ' AND meta_value = %s', ' %s ' ); @@ -1614,7 +1614,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertNull( $query ); } - function test_prepare_numeric_placeholders_float_args() { + public function test_prepare_numeric_placeholders_float_args() { global $wpdb; $actual = $wpdb->prepare( @@ -1629,7 +1629,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertStringContainsString( ' second=2.2', $actual ); } - function test_prepare_numeric_placeholders_float_array() { + public function test_prepare_numeric_placeholders_float_array() { global $wpdb; $actual = $wpdb->prepare( @@ -1643,7 +1643,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertStringContainsString( ' second=2.2', $actual ); } - function test_query_unescapes_placeholders() { + public function test_query_unescapes_placeholders() { global $wpdb; $value = ' %s '; @@ -1662,7 +1662,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertSame( $value, $actual ); } - function test_esc_sql_with_unsupported_placeholder_type() { + public function test_esc_sql_with_unsupported_placeholder_type() { global $wpdb; $sql = $wpdb->prepare( ' %s %1$c ', 'foo' ); diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 98bf43a925..146ede65d1 100644 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -35,7 +35,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 21212 */ - function data_strip_invalid_text() { + public function data_strip_invalid_text() { $fields = array( 'latin1' => array( // latin1. latin1 never changes. @@ -479,7 +479,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::strip_invalid_text */ - function test_strip_invalid_text( $data, $expected, $message ) { + public function test_strip_invalid_text( $data, $expected, $message ) { $charset = self::$_wpdb->charset; if ( isset( $data[0]['connection_charset'] ) ) { $new_charset = $data[0]['connection_charset']; @@ -512,7 +512,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::process_fields */ - function test_process_fields_failure() { + public function test_process_fields_failure() { global $wpdb; $charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' ); @@ -528,7 +528,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 21212 */ - function data_process_field_charsets() { + public function data_process_field_charsets() { if ( $GLOBALS['wpdb']->charset ) { $charset = $GLOBALS['wpdb']->charset; } else { @@ -599,7 +599,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::process_field_charsets */ - function test_process_field_charsets( $data, $expected, $message ) { + public function test_process_field_charsets( $data, $expected, $message ) { $actual = self::$_wpdb->process_field_charsets( $data, $GLOBALS['wpdb']->posts ); $this->assertSame( $expected, $actual, $message ); } @@ -611,7 +611,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * @ticket 21212 * @depends test_process_field_charsets */ - function test_process_field_charsets_on_nonexistent_table() { + public function test_process_field_charsets_on_nonexistent_table() { $data = array( 'post_content' => array( 'value' => '¡foo foo foo!', @@ -628,7 +628,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::check_ascii */ - function test_check_ascii() { + public function test_check_ascii() { $ascii = "\0\t\n\r '" . '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; $this->assertTrue( self::$_wpdb->check_ascii( $ascii ) ); } @@ -638,7 +638,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::check_ascii */ - function test_check_ascii_false() { + public function test_check_ascii_false() { $this->assertFalse( self::$_wpdb->check_ascii( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ¡©«' ) ); } @@ -647,7 +647,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::strip_invalid_text_for_column */ - function test_strip_invalid_text_for_column() { + public function test_strip_invalid_text_for_column() { global $wpdb; $charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' ); @@ -737,7 +737,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 21212 */ - function data_test_get_table_charset() { + public function data_test_get_table_charset() { $table_name = 'test_get_table_charset'; $vars = array(); @@ -757,7 +757,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::get_table_charset */ - function test_get_table_charset( $drop, $create, $table, $expected_charset ) { + public function test_get_table_charset( $drop, $create, $table, $expected_charset ) { self::$_wpdb->query( $drop ); if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { @@ -778,7 +778,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 21212 */ - function data_test_get_column_charset() { + public function data_test_get_column_charset() { $table_name = 'test_get_column_charset'; $vars = array(); @@ -798,7 +798,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::get_col_charset */ - function test_get_column_charset( $drop, $create, $table, $expected_charset ) { + public function test_get_column_charset( $drop, $create, $table, $expected_charset ) { self::$_wpdb->query( $drop ); if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { @@ -821,7 +821,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::get_col_charset */ - function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) { + public function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) { self::$_wpdb->query( $drop ); if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { @@ -848,7 +848,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::get_col_charset */ - function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) { + public function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) { self::$_wpdb->query( $drop ); if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { @@ -872,7 +872,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 21212 */ - function data_strip_invalid_text_from_query() { + public function data_strip_invalid_text_from_query() { $table_name = 'strip_invalid_text_from_query_table'; $data = array( array( @@ -908,7 +908,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::strip_invalid_text_from_query */ - function test_strip_invalid_text_from_query( $create, $query, $expected, $drop ) { + public function test_strip_invalid_text_from_query( $create, $query, $expected, $drop ) { self::$_wpdb->query( $drop ); if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { @@ -926,7 +926,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 32104 */ - function data_dont_strip_text_from_schema_queries() { + public function data_dont_strip_text_from_schema_queries() { // An obviously invalid and fake table name. $table_name = "\xff\xff\xff\xff"; @@ -952,7 +952,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::strip_invalid_text_from_query */ - function test_dont_strip_text_from_schema_queries( $query ) { + public function test_dont_strip_text_from_schema_queries( $query ) { $return = self::$_wpdb->strip_invalid_text_from_query( $query ); $this->assertSame( $query, $return ); } @@ -962,7 +962,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::query */ - function test_invalid_characters_in_query() { + public function test_invalid_characters_in_query() { global $wpdb; $charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' ); @@ -976,7 +976,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @ticket 21212 */ - function data_table_collation_check() { + public function data_table_collation_check() { $table_name = 'table_collation_check'; $data = array( array( @@ -1034,7 +1034,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::check_safe_collation */ - function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) { + public function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) { self::$_wpdb->query( $drop ); self::$_wpdb->query( $create ); @@ -1053,7 +1053,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { /** * @covers wpdb::strip_invalid_text_for_column */ - function test_strip_invalid_text_for_column_bails_if_ascii_input_too_long() { + public function test_strip_invalid_text_for_column_bails_if_ascii_input_too_long() { global $wpdb; // TEXT column. @@ -1070,7 +1070,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::strip_invalid_text_from_query */ - function test_strip_invalid_text_from_query_cp1251_is_safe() { + public function test_strip_invalid_text_from_query_cp1251_is_safe() { $tablename = 'test_cp1251_query_' . rand_str( 5 ); if ( ! self::$_wpdb->query( "CREATE TABLE $tablename ( a VARCHAR(50) ) DEFAULT CHARSET 'cp1251'" ) ) { $this->markTestSkipped( "Test requires the 'cp1251' charset." ); @@ -1089,7 +1089,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::strip_invalid_text_from_query */ - function test_no_db_charset_defined() { + public function test_no_db_charset_defined() { $tablename = 'test_cp1251_query_' . rand_str( 5 ); if ( ! self::$_wpdb->query( "CREATE TABLE $tablename ( a VARCHAR(50) ) DEFAULT CHARSET 'cp1251'" ) ) { $this->markTestSkipped( "Test requires the 'cp1251' charset." ); @@ -1113,7 +1113,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { * * @covers wpdb::set_charset */ - function test_set_charset_changes_the_connection_collation() { + public function test_set_charset_changes_the_connection_collation() { self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' ); $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" ); $this->assertSame( 'utf8_general_ci', $results[0]->Value ); diff --git a/tests/phpunit/tests/db/realEscape.php b/tests/phpunit/tests/db/realEscape.php index 393b9515c9..19d3333e85 100644 --- a/tests/phpunit/tests/db/realEscape.php +++ b/tests/phpunit/tests/db/realEscape.php @@ -21,7 +21,7 @@ class Tests_DB_RealEscape extends WP_UnitTestCase { * @param mixed $input The input to escape. * @param string $expected The expected function output. */ - function test_real_escape_input_type_handling( $input, $expected ) { + public function test_real_escape_input_type_handling( $input, $expected ) { global $wpdb; $this->assertSame( $expected, $wpdb->_real_escape( $input ) ); diff --git a/tests/phpunit/tests/dbdelta.php b/tests/phpunit/tests/dbdelta.php index 543256061e..f717eb436d 100644 --- a/tests/phpunit/tests/dbdelta.php +++ b/tests/phpunit/tests/dbdelta.php @@ -405,7 +405,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 31869 */ - function test_truncated_index() { + public function test_truncated_index() { global $wpdb; if ( ! $wpdb->has_cap( 'utf8mb4' ) ) { @@ -445,7 +445,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 36748 */ - function test_dont_downsize_text_fields() { + public function test_dont_downsize_text_fields() { global $wpdb; $result = dbDelta( @@ -470,7 +470,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 36748 */ - function test_dont_downsize_blob_fields() { + public function test_dont_downsize_blob_fields() { global $wpdb; $result = dbDelta( @@ -495,7 +495,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 36748 */ - function test_upsize_text_fields() { + public function test_upsize_text_fields() { global $wpdb; $result = dbDelta( @@ -526,7 +526,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 36748 */ - function test_upsize_blob_fields() { + public function test_upsize_blob_fields() { global $wpdb; $result = dbDelta( @@ -557,7 +557,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_query_with_backticks_does_not_throw_an_undefined_index_warning() { + public function test_query_with_backticks_does_not_throw_an_undefined_index_warning() { global $wpdb; $schema = " @@ -582,7 +582,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 36948 */ - function test_spatial_indices() { + public function test_spatial_indices() { global $wpdb; $db_version = $wpdb->db_version(); @@ -643,7 +643,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_query_with_backticks_does_not_cause_a_query_to_alter_all_columns_and_indices_to_run_even_if_none_have_changed() { + public function test_query_with_backticks_does_not_cause_a_query_to_alter_all_columns_and_indices_to_run_even_if_none_have_changed() { global $wpdb; $schema = " @@ -672,7 +672,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_index_with_a_reserved_keyword_can_be_created() { + public function test_index_with_a_reserved_keyword_can_be_created() { global $wpdb; $updates = dbDelta( @@ -708,7 +708,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() { + public function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() { $updates = dbDelta( wp_get_db_schema() ); $this->assertEmpty( $updates ); @@ -717,7 +717,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies() { + public function test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies() { global $wpdb; $schema = " @@ -755,7 +755,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_index_and_key_are_synonyms_and_do_not_recreate_indices() { + public function test_index_and_key_are_synonyms_and_do_not_recreate_indices() { global $wpdb; $updates = dbDelta( @@ -779,7 +779,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 20263 */ - function test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices() { + public function test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices() { global $wpdb; $schema = " @@ -813,7 +813,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34959 */ - function test_index_col_names_with_order_do_not_recreate_indices() { + public function test_index_col_names_with_order_do_not_recreate_indices() { global $wpdb; $updates = dbDelta( @@ -837,7 +837,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34873 */ - function test_primary_key_with_single_space_does_not_recreate_index() { + public function test_primary_key_with_single_space_does_not_recreate_index() { global $wpdb; $updates = dbDelta( @@ -861,7 +861,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34869 */ - function test_index_definitions_with_spaces_do_not_recreate_indices() { + public function test_index_definitions_with_spaces_do_not_recreate_indices() { global $wpdb; $updates = dbDelta( @@ -885,7 +885,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34871 */ - function test_index_types_are_not_case_sensitive_and_do_not_recreate_indices() { + public function test_index_types_are_not_case_sensitive_and_do_not_recreate_indices() { global $wpdb; $updates = dbDelta( @@ -909,7 +909,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34874 */ - function test_key_names_are_not_case_sensitive_and_do_not_recreate_indices() { + public function test_key_names_are_not_case_sensitive_and_do_not_recreate_indices() { global $wpdb; $updates = dbDelta( @@ -934,7 +934,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34870 */ - function test_unchanged_key_lengths_do_not_recreate_index() { + public function test_unchanged_key_lengths_do_not_recreate_index() { global $wpdb; $updates = dbDelta( @@ -959,7 +959,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 34870 */ - function test_changed_key_lengths_do_not_recreate_index() { + public function test_changed_key_lengths_do_not_recreate_index() { global $wpdb; $updates = dbDelta( @@ -1043,7 +1043,7 @@ class Tests_dbDelta extends WP_UnitTestCase { /** * @ticket 31679 */ - function test_column_type_change_with_hyphens_in_name() { + public function test_column_type_change_with_hyphens_in_name() { global $wpdb; $schema = " diff --git a/tests/phpunit/tests/dependencies.php b/tests/phpunit/tests/dependencies.php index e36d2ed5d4..354bfd376e 100644 --- a/tests/phpunit/tests/dependencies.php +++ b/tests/phpunit/tests/dependencies.php @@ -4,7 +4,7 @@ * @group scripts */ class Tests_Dependencies extends WP_UnitTestCase { - function test_add() { + public function test_add() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); @@ -17,7 +17,7 @@ class Tests_Dependencies extends WP_UnitTestCase { $this->assertFalse( $dep->add( 'one', '' ) ); } - function test_remove() { + public function test_remove() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); @@ -30,7 +30,7 @@ class Tests_Dependencies extends WP_UnitTestCase { } - function test_enqueue() { + public function test_enqueue() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); @@ -46,7 +46,7 @@ class Tests_Dependencies extends WP_UnitTestCase { $this->assertTrue( $dep->query( 'two', 'queue' ) ); } - function test_dequeue() { + public function test_dequeue() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); @@ -66,7 +66,7 @@ class Tests_Dependencies extends WP_UnitTestCase { $this->assertFalse( $dep->query( 'two', 'queue' ) ); } - function test_enqueue_args() { + public function test_enqueue_args() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); @@ -84,7 +84,7 @@ class Tests_Dependencies extends WP_UnitTestCase { $this->assertSame( 'arg', $dep->args['two'] ); } - function test_dequeue_args() { + public function test_dequeue_args() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); @@ -111,7 +111,7 @@ class Tests_Dependencies extends WP_UnitTestCase { /** * @ticket 21741 */ - function test_query_and_registered_enqueued() { + public function test_query_and_registered_enqueued() { $dep = new WP_Dependencies; $this->assertTrue( $dep->add( 'one', '' ) ); diff --git a/tests/phpunit/tests/dependencies/jquery.php b/tests/phpunit/tests/dependencies/jquery.php index 28523781de..62243fe581 100644 --- a/tests/phpunit/tests/dependencies/jquery.php +++ b/tests/phpunit/tests/dependencies/jquery.php @@ -9,7 +9,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { /** * @covers WP_Scripts::query */ - function test_location_of_jquery() { + public function test_location_of_jquery() { $scripts = new WP_Scripts; wp_default_scripts( $scripts ); @@ -46,7 +46,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { * * @covers ::wp_script_is */ - function test_dont_allow_deregister_core_scripts_in_admin() { + public function test_dont_allow_deregister_core_scripts_in_admin() { set_current_screen( 'edit.php' ); $this->assertTrue( is_admin() ); $libraries = array( @@ -89,7 +89,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { * * @covers ::wp_script_is */ - function test_wp_script_is_dep_enqueued() { + public function test_wp_script_is_dep_enqueued() { wp_enqueue_script( 'jquery-ui-accordion' ); $this->assertTrue( wp_script_is( 'jquery', 'enqueued' ) ); @@ -105,7 +105,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { * * @covers WP_Scripts::do_items */ - function test_jquery_in_footer() { + public function test_jquery_in_footer() { $scripts = new WP_Scripts; $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) ); $scripts->add( 'jquery-core', '/jquery.js', array() ); diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 90394fab30..9dcb1e9b63 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -14,7 +14,7 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase { protected $wp_scripts_print_translations_output; - function set_up() { + public function set_up() { parent::set_up(); $this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null; remove_action( 'wp_default_scripts', 'wp_default_scripts' ); @@ -34,7 +34,7 @@ JS; $this->wp_scripts_print_translations_output .= "\n"; } - function tear_down() { + public function tear_down() { $GLOBALS['wp_scripts'] = $this->old_wp_scripts; add_action( 'wp_default_scripts', 'wp_default_scripts' ); parent::tear_down(); @@ -45,7 +45,7 @@ JS; * * @ticket 11315 */ - function test_wp_enqueue_script() { + public function test_wp_enqueue_script() { wp_enqueue_script( 'no-deps-no-version', 'example.com', array() ); wp_enqueue_script( 'empty-deps-no-version', 'example.com' ); wp_enqueue_script( 'empty-deps-version', 'example.com', array(), 1.2 ); @@ -66,7 +66,7 @@ JS; /** * @ticket 42804 */ - function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() { + public function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() { add_theme_support( 'html5', array( 'script' ) ); $GLOBALS['wp_scripts'] = new WP_Scripts(); @@ -152,7 +152,7 @@ JS; * * @ticket 16024 */ - function test_wp_script_add_data_with_data_key() { + public function test_wp_script_add_data_with_data_key() { // Enqueue and add data. wp_enqueue_script( 'test-only-data', 'example.com', array(), null ); wp_script_add_data( 'test-only-data', 'data', 'testing' ); @@ -171,7 +171,7 @@ JS; * * @ticket 16024 */ - function test_wp_script_add_data_with_conditional_key() { + public function test_wp_script_add_data_with_conditional_key() { // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); @@ -189,7 +189,7 @@ JS; * * @ticket 16024 */ - function test_wp_script_add_data_with_data_and_conditional_keys() { + public function test_wp_script_add_data_with_data_and_conditional_keys() { // Enqueue and add data plus conditional comments for both. wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null ); wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' ); @@ -209,7 +209,7 @@ JS; * * @ticket 16024 */ - function test_wp_script_add_data_with_invalid_key() { + public function test_wp_script_add_data_with_invalid_key() { // Enqueue and add an invalid key. wp_enqueue_script( 'test-invalid', 'example.com', array(), null ); wp_script_add_data( 'test-invalid', 'invalid', 'testing' ); @@ -227,7 +227,7 @@ JS; * * @ticket 31126 */ - function test_wp_register_script() { + public function test_wp_register_script() { $this->assertTrue( wp_register_script( 'duplicate-handler', 'http://example.com' ) ); $this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) ); } @@ -235,7 +235,7 @@ JS; /** * @ticket 35229 */ - function test_wp_register_script_with_handle_without_source() { + public function test_wp_register_script_with_handle_without_source() { $expected = "\n"; $expected .= "\n"; @@ -251,7 +251,7 @@ JS; /** * @ticket 35643 */ - function test_wp_enqueue_script_footer_alias() { + public function test_wp_enqueue_script_footer_alias() { wp_register_script( 'foo', false, array( 'bar', 'baz' ), '1.0', true ); wp_register_script( 'bar', home_url( 'bar.js' ), array(), '1.0', true ); wp_register_script( 'baz', home_url( 'baz.js' ), array(), '1.0', true ); @@ -319,7 +319,7 @@ JS; /** * @ticket 35873 */ - function test_wp_register_script_with_dependencies_in_head_and_footer() { + public function test_wp_register_script_with_dependencies_in_head_and_footer() { wp_register_script( 'parent', '/parent.js', array( 'child-head' ), null, true ); // In footer. wp_register_script( 'child-head', '/child-head.js', array( 'child-footer' ), null, false ); // In head. wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // In footer. @@ -340,7 +340,7 @@ JS; /** * @ticket 35956 */ - function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order() { + public function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order() { wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // In head. wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // In footer. wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true ); // In footer. @@ -361,7 +361,7 @@ JS; /** * @ticket 35956 */ - function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order_and_two_parent_scripts() { + public function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order_and_two_parent_scripts() { wp_register_script( 'grandchild-head', '/grandchild-head.js', array(), null, false ); // In head. wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // In head. wp_register_script( 'child-footer', '/child-footer.js', array( 'grandchild-head' ), null, true ); // In footer. @@ -392,7 +392,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_returns_bool() { + public function test_wp_add_inline_script_returns_bool() { $this->assertFalse( wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ) ); wp_enqueue_script( 'test-example', 'example.com', array(), null ); $this->assertTrue( wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ) ); @@ -401,7 +401,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_unknown_handle() { + public function test_wp_add_inline_script_unknown_handle() { $this->assertFalse( wp_add_inline_script( 'test-invalid', 'console.log("before");', 'before' ) ); $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } @@ -409,7 +409,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_before() { + public function test_wp_add_inline_script_before() { wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); @@ -422,7 +422,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_after() { + public function test_wp_add_inline_script_after() { wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_add_inline_script( 'test-example', 'console.log("after");' ); @@ -435,7 +435,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_before_and_after() { + public function test_wp_add_inline_script_before_and_after() { wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); wp_add_inline_script( 'test-example', 'console.log("after");' ); @@ -450,7 +450,7 @@ JS; /** * @ticket 44551 */ - function test_wp_add_inline_script_before_for_handle_without_source() { + public function test_wp_add_inline_script_before_for_handle_without_source() { wp_register_script( 'test-example', '' ); wp_enqueue_script( 'test-example' ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); @@ -463,7 +463,7 @@ JS; /** * @ticket 44551 */ - function test_wp_add_inline_script_after_for_handle_without_source() { + public function test_wp_add_inline_script_after_for_handle_without_source() { wp_register_script( 'test-example', '' ); wp_enqueue_script( 'test-example' ); wp_add_inline_script( 'test-example', 'console.log("after");' ); @@ -476,7 +476,7 @@ JS; /** * @ticket 44551 */ - function test_wp_add_inline_script_before_and_after_for_handle_without_source() { + public function test_wp_add_inline_script_before_and_after_for_handle_without_source() { wp_register_script( 'test-example', '' ); wp_enqueue_script( 'test-example' ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); @@ -491,7 +491,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_multiple() { + public function test_wp_add_inline_script_multiple() { wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); @@ -508,7 +508,7 @@ JS; /** * @ticket 14853 */ - function test_wp_add_inline_script_localized_data_is_added_first() { + public function test_wp_add_inline_script_localized_data_is_added_first() { wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 421959ab7f..f5eed18758 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -12,7 +12,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { private $old_wp_styles; private $old_wp_scripts; - function set_up() { + public function set_up() { parent::set_up(); if ( empty( $GLOBALS['wp_styles'] ) ) { @@ -37,7 +37,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' ); } - function tear_down() { + public function tear_down() { $GLOBALS['wp_styles'] = $this->old_wp_styles; $GLOBALS['wp_scripts'] = $this->old_wp_scripts; @@ -56,7 +56,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { * * @ticket 11315 */ - function test_wp_enqueue_style() { + public function test_wp_enqueue_style() { wp_enqueue_style( 'no-deps-no-version', 'example.com' ); wp_enqueue_style( 'no-deps-version', 'example.com', array(), 1.2 ); wp_enqueue_style( 'no-deps-null-version', 'example.com', array(), null ); @@ -77,7 +77,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { /** * @ticket 42804 */ - function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() { + public function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() { add_theme_support( 'html5', array( 'style' ) ); $GLOBALS['wp_styles'] = new WP_Styles(); @@ -285,7 +285,7 @@ CSS; * * @ticket 31126 */ - function test_wp_register_style() { + public function test_wp_register_style() { $this->assertTrue( wp_register_style( 'duplicate-handler', 'http://example.com' ) ); $this->assertFalse( wp_register_style( 'duplicate-handler', 'http://example.com' ) ); } @@ -293,7 +293,7 @@ CSS; /** * @ticket 35229 */ - function test_wp_add_inline_style_for_handle_without_source() { + public function test_wp_add_inline_style_for_handle_without_source() { $style = 'a { color: blue; }'; $expected = "\n"; @@ -316,12 +316,12 @@ CSS; * @ticket 35921 * @dataProvider data_styles_with_media */ - function test_wp_enqueue_style_with_media( $expected, $media ) { + public function test_wp_enqueue_style_with_media( $expected, $media ) { wp_enqueue_style( 'handle', 'http://example.com', array(), 1, $media ); $this->assertStringContainsString( $expected, get_echo( 'wp_print_styles' ) ); } - function data_styles_with_media() { + public function data_styles_with_media() { return array( array( "media='all'", @@ -357,7 +357,7 @@ CSS; * * @covers ::wp_enqueue_style */ - function test_block_styles_for_editing_without_theme_support() { + public function test_block_styles_for_editing_without_theme_support() { // Confirm we are without theme support by default. $this->assertFalse( current_theme_supports( 'wp-block-styles' ) ); @@ -375,7 +375,7 @@ CSS; * * @covers ::wp_common_block_scripts_and_styles */ - function test_block_styles_for_editing_with_theme_support() { + public function test_block_styles_for_editing_with_theme_support() { add_theme_support( 'wp-block-styles' ); wp_default_styles( $GLOBALS['wp_styles'] ); @@ -393,7 +393,7 @@ CSS; * * @covers ::wp_enqueue_style */ - function test_no_block_styles_for_viewing_without_theme_support() { + public function test_no_block_styles_for_viewing_without_theme_support() { // Confirm we are without theme support by default. $this->assertFalse( current_theme_supports( 'wp-block-styles' ) ); @@ -411,7 +411,7 @@ CSS; * * @covers ::wp_common_block_scripts_and_styles */ - function test_block_styles_for_viewing_with_theme_support() { + public function test_block_styles_for_viewing_with_theme_support() { add_theme_support( 'wp-block-styles' ); wp_default_styles( $GLOBALS['wp_styles'] ); @@ -428,7 +428,7 @@ CSS; * * @covers ::wp_default_styles */ - function test_block_styles_for_viewing_without_split_styles() { + public function test_block_styles_for_viewing_without_split_styles() { add_filter( 'should_load_separate_core_block_assets', '__return_false' ); wp_default_styles( $GLOBALS['wp_styles'] ); @@ -445,7 +445,7 @@ CSS; * * @covers ::wp_default_styles */ - function test_block_styles_for_viewing_with_split_styles() { + public function test_block_styles_for_viewing_with_split_styles() { add_filter( 'should_load_separate_core_block_assets', '__return_true' ); wp_default_styles( $GLOBALS['wp_styles'] ); diff --git a/tests/phpunit/tests/dependencies/wpSanitizeScriptAttributes.php b/tests/phpunit/tests/dependencies/wpSanitizeScriptAttributes.php index 47432d35e3..ef737f239a 100644 --- a/tests/phpunit/tests/dependencies/wpSanitizeScriptAttributes.php +++ b/tests/phpunit/tests/dependencies/wpSanitizeScriptAttributes.php @@ -9,7 +9,7 @@ */ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase { - function test_sanitize_script_attributes_type_set() { + public function test_sanitize_script_attributes_type_set() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -39,7 +39,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase { ); } - function test_sanitize_script_attributes_type_not_set() { + public function test_sanitize_script_attributes_type_not_set() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -68,7 +68,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase { } - function test_sanitize_script_attributes_no_attributes() { + public function test_sanitize_script_attributes_no_attributes() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -79,7 +79,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase { remove_theme_support( 'html5' ); } - function test_sanitize_script_attributes_relative_src() { + public function test_sanitize_script_attributes_relative_src() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -97,7 +97,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase { } - function test_sanitize_script_attributes_only_false_boolean_attributes() { + public function test_sanitize_script_attributes_only_false_boolean_attributes() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -113,7 +113,7 @@ class Tests_Functions_wpSanitizeScriptAttributes extends WP_UnitTestCase { remove_theme_support( 'html5' ); } - function test_sanitize_script_attributes_only_true_boolean_attributes() { + public function test_sanitize_script_attributes_only_true_boolean_attributes() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( diff --git a/tests/phpunit/tests/dependencies/wpScriptTag.php b/tests/phpunit/tests/dependencies/wpScriptTag.php index f009bb5790..ee273f8fb3 100644 --- a/tests/phpunit/tests/dependencies/wpScriptTag.php +++ b/tests/phpunit/tests/dependencies/wpScriptTag.php @@ -8,7 +8,7 @@ */ class Tests_Functions_wpScriptTag extends WP_UnitTestCase { - function get_script_tag_type_set() { + public function get_script_tag_type_set() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -41,7 +41,7 @@ class Tests_Functions_wpScriptTag extends WP_UnitTestCase { /** * @covers ::wp_get_script_tag */ - function test_get_script_tag_type_not_set() { + public function test_get_script_tag_type_not_set() { add_theme_support( 'html5', array( 'script' ) ); $this->assertSame( @@ -61,7 +61,7 @@ class Tests_Functions_wpScriptTag extends WP_UnitTestCase { /** * @covers ::wp_print_script_tag */ - function test_print_script_tag_prints_get_script_tag() { + public function test_print_script_tag_prints_get_script_tag() { add_filter( 'wp_script_attributes', static function ( $attributes ) { diff --git a/tests/phpunit/tests/external-http/basic.php b/tests/phpunit/tests/external-http/basic.php index 1f8109502c..61f1f2d129 100644 --- a/tests/phpunit/tests/external-http/basic.php +++ b/tests/phpunit/tests/external-http/basic.php @@ -9,7 +9,7 @@ class Tests_External_HTTP_Basic extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_response_code * @covers ::wp_remote_retrieve_body */ - function test_readme() { + public function test_readme() { // This test is designed to only run on trunk/master. $this->skipOnAutomatedBranches(); diff --git a/tests/phpunit/tests/feed/atom.php b/tests/phpunit/tests/feed/atom.php index 3b2c827749..0b26c7cb57 100644 --- a/tests/phpunit/tests/feed/atom.php +++ b/tests/phpunit/tests/feed/atom.php @@ -66,7 +66,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase { /** * This is a bit of a hack used to buffer feed content. */ - function do_atom() { + private function do_atom() { ob_start(); // Nasty hack! In the future it would better to leverage do_feed( 'atom' ). global $post; @@ -85,7 +85,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase { * Test the element to make sure its present and populated * with the expected child elements and attributes. */ - function test_feed_element() { + public function test_feed_element() { $this->go_to( '/?feed=atom' ); $feed = $this->do_atom(); $xml = xml_to_array( $feed ); @@ -129,7 +129,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase { /** * Validate child elements. */ - function test_entry_elements() { + public function test_entry_elements() { $this->go_to( '/?feed=atom' ); $feed = $this->do_atom(); $xml = xml_to_array( $feed ); @@ -209,7 +209,7 @@ class Tests_Feed_Atom extends WP_UnitTestCase { /** * @ticket 33591 */ - function test_atom_enclosure_with_extended_url_length_type_parsing() { + public function test_atom_enclosure_with_extended_url_length_type_parsing() { $enclosures = array( array( // URL, length, type. diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php index 50138cf255..742c78f3d7 100644 --- a/tests/phpunit/tests/feed/rss2.php +++ b/tests/phpunit/tests/feed/rss2.php @@ -78,7 +78,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { /** * This is a bit of a hack used to buffer feed content. */ - function do_rss2() { + private function do_rss2() { ob_start(); // Nasty hack! In the future it would better to leverage do_feed( 'rss2' ). global $post; @@ -97,7 +97,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * Test the element to make sure its present and populated * with the expected child elements and attributes. */ - function test_rss_element() { + public function test_rss_element() { $this->go_to( '/?feed=rss2' ); $feed = $this->do_rss2(); $xml = xml_to_array( $feed ); @@ -122,7 +122,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @return [type] [description] */ - function test_channel_element() { + public function test_channel_element() { $this->go_to( '/?feed=rss2' ); $feed = $this->do_rss2(); $xml = xml_to_array( $feed ); @@ -152,7 +152,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 39141 */ - function test_channel_pubdate_element_translated() { + public function test_channel_pubdate_element_translated() { $original_locale = $GLOBALS['wp_locale']; /* @var WP_Locale $locale */ $locale = clone $GLOBALS['wp_locale']; @@ -175,7 +175,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { $this->assertStringNotContainsString( 'Tue_Translated', $pubdate[0]['content'] ); } - function test_item_elements() { + public function test_item_elements() { $this->go_to( '/?feed=rss2' ); $feed = $this->do_rss2(); $xml = xml_to_array( $feed ); @@ -266,7 +266,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { /** * @ticket 9134 */ - function test_items_comments_closed() { + public function test_items_comments_closed() { add_filter( 'comments_open', '__return_false' ); $this->go_to( '/?feed=rss2' ); @@ -301,7 +301,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 30210 */ - function test_valid_home_feed_endpoint() { + public function test_valid_home_feed_endpoint() { // An example of a valid home feed endpoint. $this->go_to( 'feed/' ); @@ -329,7 +329,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 30210 */ - function test_valid_taxonomy_feed_endpoint() { + public function test_valid_taxonomy_feed_endpoint() { // An example of an valid taxonomy feed endpoint. $this->go_to( 'category/foo/feed/' ); @@ -357,7 +357,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 30210 */ - function test_valid_main_comment_feed_endpoint() { + public function test_valid_main_comment_feed_endpoint() { // Generate a bunch of comments. foreach ( self::$posts as $post ) { self::factory()->comment->create_post_comments( $post, 3 ); @@ -390,7 +390,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 30210 */ - function test_valid_archive_feed_endpoint() { + public function test_valid_archive_feed_endpoint() { // An example of an valid date archive feed endpoint. $this->go_to( '2003/05/27/feed/' ); @@ -418,7 +418,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 30210 */ - function test_valid_single_post_comment_feed_endpoint() { + public function test_valid_single_post_comment_feed_endpoint() { // An example of an valid date archive feed endpoint. $this->go_to( get_post_comments_feed_link( self::$posts[0] ) ); @@ -446,7 +446,7 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { * * @ticket 30210 */ - function test_valid_search_feed_endpoint() { + public function test_valid_search_feed_endpoint() { // An example of an valid search feed endpoint. $this->go_to( '?s=Lorem&feed=rss' ); diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php index 04fd32ff82..eb6168d9af 100644 --- a/tests/phpunit/tests/file.php +++ b/tests/phpunit/tests/file.php @@ -5,7 +5,7 @@ */ class Tests_File extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); $this->dir = untrailingslashit( get_temp_dir() ); @@ -17,7 +17,7 @@ class Tests_File extends WP_UnitTestCase { * @group plugins * @group themes */ - function test_get_file_data() { + public function test_get_file_data() { $theme_headers = array( 'Name' => 'Theme Name', 'ThemeURI' => 'Theme URI', @@ -48,7 +48,7 @@ class Tests_File extends WP_UnitTestCase { * @group plugins * @group themes */ - function test_get_file_data_with_cr_line_endings() { + public function test_get_file_data_with_cr_line_endings() { $headers = array( 'SomeHeader' => 'Some Header', 'Description' => 'Description', @@ -72,7 +72,7 @@ class Tests_File extends WP_UnitTestCase { * @group plugins * @group themes */ - function test_get_file_data_with_php_open_tag_prefix() { + public function test_get_file_data_with_php_open_tag_prefix() { $headers = array( 'TemplateName' => 'Template Name', ); @@ -87,7 +87,7 @@ class Tests_File extends WP_UnitTestCase { } } - function is_unique_writable_file( $path, $filename ) { + private function is_unique_writable_file( $path, $filename ) { $fullpath = $path . DIRECTORY_SEPARATOR . $filename; $fp = fopen( $fullpath, 'x' ); @@ -110,7 +110,7 @@ class Tests_File extends WP_UnitTestCase { return $result; } - function test_unique_filename_is_valid() { + public function test_unique_filename_is_valid() { // Make sure it produces a valid, writable, unique filename. $filename = wp_unique_filename( $this->dir, __FUNCTION__ . '.txt' ); @@ -119,7 +119,7 @@ class Tests_File extends WP_UnitTestCase { unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); } - function test_unique_filename_is_unique() { + public function test_unique_filename_is_unique() { // Make sure it produces two unique filenames. $name = __FUNCTION__; @@ -135,7 +135,7 @@ class Tests_File extends WP_UnitTestCase { unlink( $this->dir . DIRECTORY_SEPARATOR . $filename2 ); } - function test_unique_filename_is_sanitized() { + public function test_unique_filename_is_sanitized() { $name = __FUNCTION__; $filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' ); @@ -147,7 +147,7 @@ class Tests_File extends WP_UnitTestCase { unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); } - function test_unique_filename_with_slashes() { + public function test_unique_filename_with_slashes() { $name = __FUNCTION__; // "foo/foo.txt" $filename = wp_unique_filename( $this->dir, $name . '/' . $name . '.txt' ); @@ -160,7 +160,7 @@ class Tests_File extends WP_UnitTestCase { unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); } - function test_unique_filename_multiple_ext() { + public function test_unique_filename_multiple_ext() { $name = __FUNCTION__; $filename = wp_unique_filename( $this->dir, $name . '.php.txt' ); @@ -172,7 +172,7 @@ class Tests_File extends WP_UnitTestCase { unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); } - function test_unique_filename_no_ext() { + public function test_unique_filename_no_ext() { $name = __FUNCTION__; $filename = wp_unique_filename( $this->dir, $name ); @@ -186,13 +186,13 @@ class Tests_File extends WP_UnitTestCase { /** * @dataProvider data_wp_tempnam_filenames */ - function test_wp_tempnam( $case ) { + public function test_wp_tempnam( $case ) { $file = wp_tempnam( $case ); unlink( $file ); $this->assertNotEmpty( basename( basename( $file, '.tmp' ), '.zip' ) ); } - function data_wp_tempnam_filenames() { + public function data_wp_tempnam_filenames() { return array( array( '0.zip' ), array( '0.1.2.3.zip' ), @@ -206,7 +206,7 @@ class Tests_File extends WP_UnitTestCase { /** * @ticket 47186 */ - function test_file_signature_functions_as_expected() { + public function test_file_signature_functions_as_expected() { $file = wp_tempnam(); file_put_contents( $file, 'WordPress' ); @@ -239,7 +239,7 @@ class Tests_File extends WP_UnitTestCase { /** * @ticket 47186 */ - function test_file_signature_expected_failure() { + public function test_file_signature_expected_failure() { $file = wp_tempnam(); file_put_contents( $file, 'WordPress' ); @@ -256,7 +256,7 @@ class Tests_File extends WP_UnitTestCase { $this->assertSame( 'signature_verification_failed', $verify->get_error_code() ); } - function filter_trust_plus85Tq_key( $keys ) { + public function filter_trust_plus85Tq_key( $keys ) { // A static once-off key used to verify verify_file_signature() works as expected. $keys[] = '+85TqMhxQVAYVW4BSCVkJQvZH4q7z8I9lePbvngvf7A='; diff --git a/tests/phpunit/tests/filesystem/base.php b/tests/phpunit/tests/filesystem/base.php index 9897b26e78..52ab59e3cd 100644 --- a/tests/phpunit/tests/filesystem/base.php +++ b/tests/phpunit/tests/filesystem/base.php @@ -4,14 +4,14 @@ * This class is designed to make use of MockFS, a Virtual in-memory filesystem compatible with WP_Filesystem */ abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); add_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) ); add_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) ); WP_Filesystem(); } - function tear_down() { + public function tear_down() { global $wp_filesystem; remove_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) ); remove_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) ); @@ -20,14 +20,14 @@ abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase { parent::tear_down(); } - function filter_fs_method( $method ) { + public function filter_fs_method( $method ) { return 'MockFS'; } - function filter_abstraction_file( $file ) { + public function filter_abstraction_file( $file ) { return dirname( dirname( __DIR__ ) ) . '/includes/mock-fs.php'; } - function test_is_MockFS_sane() { + public function test_is_MockFS_sane() { global $wp_filesystem; $this->assertInstanceOf( 'WP_Filesystem_MockFS', $wp_filesystem ); diff --git a/tests/phpunit/tests/filesystem/findFolder.php b/tests/phpunit/tests/filesystem/findFolder.php index 6ada55caf8..3db6107585 100644 --- a/tests/phpunit/tests/filesystem/findFolder.php +++ b/tests/phpunit/tests/filesystem/findFolder.php @@ -8,7 +8,7 @@ require_once __DIR__ . '/base.php'; */ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase { - function test_ftp_has_root_access() { + public function test_ftp_has_root_access() { global $wp_filesystem; $fs = $wp_filesystem; $fs->init( @@ -27,7 +27,7 @@ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase { } - function test_sibling_wordpress_in_subdir() { + public function test_sibling_wordpress_in_subdir() { global $wp_filesystem; $fs = $wp_filesystem; $fs->init( @@ -57,7 +57,7 @@ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase { * example.com at / * wp.example.com at /wp.example.com/wordpress/ */ - function test_subdir_of_another() { + public function test_subdir_of_another() { global $wp_filesystem; $fs = $wp_filesystem; $fs->init( @@ -84,7 +84,7 @@ class WP_Filesystem_Find_Folder_Test extends WP_Filesystem_UnitTestCase { * * @ticket 20934 */ - function test_multiple_tokens_in_path1() { + public function test_multiple_tokens_in_path1() { global $wp_filesystem; $fs = $wp_filesystem; $fs->init( diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index aa8a611e1b..6bcd437365 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -7,7 +7,7 @@ */ class Tests_Filters extends WP_UnitTestCase { - function test_simple_filter() { + public function test_simple_filter() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -25,7 +25,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( array( $val ), $args ); } - function test_remove_filter() { + public function test_remove_filter() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -45,7 +45,7 @@ class Tests_Filters extends WP_UnitTestCase { } - function test_has_filter() { + public function test_has_filter() { $tag = __FUNCTION__; $func = __FUNCTION__ . '_func'; @@ -60,7 +60,7 @@ class Tests_Filters extends WP_UnitTestCase { } // One tag with multiple filters. - function test_multiple_filters() { + public function test_multiple_filters() { $a1 = new MockAction(); $a2 = new MockAction(); $tag = __FUNCTION__; @@ -77,7 +77,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( 1, $a2->get_call_count() ); } - function test_filter_args_1() { + public function test_filter_args_1() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -92,7 +92,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( array( $val, $arg1 ), array_pop( $argsvar ) ); } - function test_filter_args_2() { + public function test_filter_args_2() { $a1 = new MockAction(); $a2 = new MockAction(); $tag = __FUNCTION__; @@ -117,7 +117,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( array( $val ), array_pop( $argsvar2 ) ); } - function test_filter_priority() { + public function test_filter_priority() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -148,7 +148,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertSame( $expected, $a->get_events() ); } - function test_all_filter() { + public function test_all_filter() { $a = new MockAction(); $tag1 = __FUNCTION__ . '_1'; $tag2 = __FUNCTION__ . '_2'; @@ -172,7 +172,7 @@ class Tests_Filters extends WP_UnitTestCase { } - function test_remove_all_filter() { + public function test_remove_all_filter() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -199,7 +199,7 @@ class Tests_Filters extends WP_UnitTestCase { /** * @ticket 20920 */ - function test_remove_all_filters_should_respect_the_priority_argument() { + public function test_remove_all_filters_should_respect_the_priority_argument() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -218,7 +218,7 @@ class Tests_Filters extends WP_UnitTestCase { /** * @ticket 9886 */ - function test_filter_ref_array() { + public function test_filter_ref_array() { $obj = new stdClass(); $a = new MockAction(); $tag = __FUNCTION__; @@ -237,7 +237,7 @@ class Tests_Filters extends WP_UnitTestCase { /** * @ticket 12723 */ - function test_filter_ref_array_result() { + public function test_filter_ref_array_result() { $obj = new stdClass(); $a = new MockAction(); $b = new MockAction(); @@ -264,15 +264,10 @@ class Tests_Filters extends WP_UnitTestCase { } - function _self_removal( $tag ) { - remove_action( $tag, array( $this, '_self_removal' ), 10, 1 ); - return $tag; - } - /** * @ticket 29070 */ - function test_has_filter_after_remove_all_filters() { + public function test_has_filter_after_remove_all_filters() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; @@ -353,14 +348,14 @@ class Tests_Filters extends WP_UnitTestCase { * @ticket 39007 */ public function test_current_priority() { - add_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 ); + add_action( 'test_current_priority', array( $this, 'current_priority_action' ), 99 ); do_action( 'test_current_priority' ); - remove_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 ); + remove_action( 'test_current_priority', array( $this, 'current_priority_action' ), 99 ); $this->assertSame( 99, $this->current_priority ); } - public function _current_priority_action() { + public function current_priority_action() { global $wp_filter; $this->current_priority = $wp_filter[ current_filter() ]->current_priority(); } @@ -369,14 +364,14 @@ class Tests_Filters extends WP_UnitTestCase { * @ticket 39007 */ public function test_other_priority() { - add_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 ); + add_action( 'test_current_priority', array( $this, 'other_priority_action' ), 99 ); do_action( 'test_current_priority' ); - remove_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 ); + remove_action( 'test_current_priority', array( $this, 'other_priority_action' ), 99 ); $this->assertFalse( $this->current_priority ); } - public function _other_priority_action() { + public function other_priority_action() { global $wp_filter; $this->current_priority = $wp_filter['the_content']->current_priority(); } diff --git a/tests/phpunit/tests/formatting/balanceTags.php b/tests/phpunit/tests/formatting/balanceTags.php index 16f97eb70e..4726cf24db 100644 --- a/tests/phpunit/tests/formatting/balanceTags.php +++ b/tests/phpunit/tests/formatting/balanceTags.php @@ -5,7 +5,7 @@ */ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { - function nestable_tags() { + public function nestable_tags() { return array( array( 'blockquote' ), array( 'div' ), @@ -16,7 +16,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } // This is a complete(?) listing of valid single/self-closing tags. - function single_tags() { + public function single_tags() { return array( array( 'area' ), array( 'base' ), @@ -37,7 +37,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); } - function supported_traditional_tag_names() { + public function supported_traditional_tag_names() { return array( array( 'a' ), array( 'div' ), @@ -49,7 +49,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); } - function supported_custom_element_tag_names() { + public function supported_custom_element_tag_names() { return array( array( 'custom-element' ), array( 'my-custom-element' ), @@ -61,7 +61,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); } - function invalid_tag_names() { + public function invalid_tag_names() { return array( array( '<0-day>inside', '<0-day>inside' ), // Can't start with a number - handled by the "<3" fix. array( 'inside', 'inside' ), // Custom elements cannot be uppercase. @@ -73,7 +73,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name */ - function unsupported_valid_tag_names() { + public function unsupported_valid_tag_names() { return array( // We don't allow ending in a dash. array( 'inside' ), @@ -133,7 +133,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name */ - function supported_invalid_tag_names() { + public function supported_invalid_tag_names() { return array( // Reserved names for custom elements. array( 'annotation-xml' ), @@ -151,7 +151,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 47014 * @dataProvider supported_traditional_tag_names */ - function test_detects_traditional_tag_names( $tag ) { + public function test_detects_traditional_tag_names( $tag ) { $normalized = strtolower( $tag ); $this->assertSame( "<$normalized>inside", balanceTags( "<$tag>inside", true ) ); @@ -161,7 +161,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 47014 * @dataProvider supported_custom_element_tag_names */ - function test_detects_supported_custom_element_tag_names( $tag ) { + public function test_detects_supported_custom_element_tag_names( $tag ) { $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); } @@ -169,7 +169,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 47014 * @dataProvider invalid_tag_names */ - function test_ignores_invalid_tag_names( $input, $output ) { + public function test_ignores_invalid_tag_names( $input, $output ) { $this->assertSame( $output, balanceTags( $input, true ) ); } @@ -177,7 +177,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 47014 * @dataProvider unsupported_valid_tag_names */ - function test_ignores_unsupported_custom_tag_names( $tag ) { + public function test_ignores_unsupported_custom_tag_names( $tag ) { $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); } @@ -185,7 +185,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 47014 * @dataProvider supported_invalid_tag_names */ - function test_detects_supported_invalid_tag_names( $tag ) { + public function test_detects_supported_invalid_tag_names( $tag ) { $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); } @@ -195,7 +195,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 1597 * @dataProvider single_tags */ - function test_selfcloses_unclosed_known_single_tags( $tag ) { + public function test_selfcloses_unclosed_known_single_tags( $tag ) { $this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) ); } @@ -206,14 +206,14 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @ticket 1597 * @dataProvider single_tags */ - function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { + public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { $this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) ); } /** * @ticket 1597 */ - function test_closes_unknown_single_tags_with_closing_tag() { + public function test_closes_unknown_single_tags_with_closing_tag() { $inputs = array( '', @@ -236,7 +236,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } } - function test_closes_unclosed_single_tags_having_attributes() { + public function test_closes_unclosed_single_tags_having_attributes() { $inputs = array( '', '', @@ -251,7 +251,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } } - function test_allows_validly_closed_single_tags() { + public function test_allows_validly_closed_single_tags() { $inputs = array( '
', '
', @@ -267,7 +267,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { /** * @dataProvider nestable_tags */ - function test_balances_nestable_tags( $tag ) { + public function test_balances_nestable_tags( $tag ) { $inputs = array( "<$tag>Test<$tag>Test", "<$tag><$tag>Test", @@ -284,7 +284,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } } - function test_allows_adjacent_nestable_tags() { + public function test_allows_adjacent_nestable_tags() { $inputs = array( '
Example quote
', '
This is allowed>
', @@ -301,12 +301,12 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { /** * @ticket 20401 */ - function test_allows_immediately_nested_object_tags() { + public function test_allows_immediately_nested_object_tags() { $object = ''; $this->assertSame( $object, balanceTags( $object, true ) ); } - function test_balances_nested_non_nestable_tags() { + public function test_balances_nested_non_nestable_tags() { $inputs = array( 'This is bold', 'Some text here This is bold', @@ -321,7 +321,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } } - function test_fixes_improper_closing_tag_sequence() { + public function test_fixes_improper_closing_tag_sequence() { $inputs = array( '

Here is a bold and emphasis

', '
  • Aaa
  • Bbb
', @@ -336,7 +336,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } } - function test_adds_missing_closing_tags() { + public function test_adds_missing_closing_tags() { $inputs = array( 'Test', '

Test', @@ -357,7 +357,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { } } - function test_removes_extraneous_closing_tags() { + public function test_removes_extraneous_closing_tags() { $inputs = array( 'Test', '

Test
Test', diff --git a/tests/phpunit/tests/formatting/capitalPDangit.php b/tests/phpunit/tests/formatting/capitalPDangit.php index 70656a66a3..3e78e1a364 100644 --- a/tests/phpunit/tests/formatting/capitalPDangit.php +++ b/tests/phpunit/tests/formatting/capitalPDangit.php @@ -5,7 +5,7 @@ * @group formatting */ class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase { - function test_esc_attr_quotes() { + public function test_esc_attr_quotes() { global $wp_current_filter; $this->assertSame( 'Something about WordPress', capital_P_dangit( 'Something about Wordpress' ) ); $this->assertSame( 'Something about (WordPress', capital_P_dangit( 'Something about (Wordpress' ) ); diff --git a/tests/phpunit/tests/formatting/cleanPre.php b/tests/phpunit/tests/formatting/cleanPre.php index e5b1d965a1..8444ae7bd5 100644 --- a/tests/phpunit/tests/formatting/cleanPre.php +++ b/tests/phpunit/tests/formatting/cleanPre.php @@ -9,14 +9,14 @@ */ class Tests_Formatting_CleanPre extends WP_UnitTestCase { - function test_removes_self_closing_br_with_space() { + public function test_removes_self_closing_br_with_space() { $source = 'a b c\n
sldfj
'; $res = 'a b c\nsldfj'; $this->assertSame( $res, clean_pre( $source ) ); } - function test_removes_self_closing_br_without_space() { + public function test_removes_self_closing_br_without_space() { $source = 'a b c\n
sldfj
'; $res = 'a b c\nsldfj'; $this->assertSame( $res, clean_pre( $source ) ); @@ -26,13 +26,13 @@ class Tests_Formatting_CleanPre extends WP_UnitTestCase { //
is changed to
elsewhere. Left in because // that replacement shouldn't happen (what if you want // HTML 4 output?). - function test_removes_html_br() { + public function test_removes_html_br() { $source = 'a b c\n
sldfj
'; $res = 'a b c\nsldfj'; $this->assertSame( $res, clean_pre( $source ) ); } - function test_removes_p() { + public function test_removes_p() { $source = "

isn't this exciting!

oh indeed!

"; $res = "\nisn't this exciting!\noh indeed!"; $this->assertSame( $res, clean_pre( $source ) ); diff --git a/tests/phpunit/tests/formatting/convertInvalidEntries.php b/tests/phpunit/tests/formatting/convertInvalidEntries.php index 05e77fe6bf..9b243ee421 100644 --- a/tests/phpunit/tests/formatting/convertInvalidEntries.php +++ b/tests/phpunit/tests/formatting/convertInvalidEntries.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase { - function test_replaces_windows1252_entities_with_unicode_ones() { + public function test_replaces_windows1252_entities_with_unicode_ones() { $input = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ'; $output = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ'; $this->assertSame( $output, convert_invalid_entities( $input ) ); @@ -13,13 +13,13 @@ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase { /** * @ticket 20503 */ - function test_replaces_latin_letter_z_with_caron() { + public function test_replaces_latin_letter_z_with_caron() { $input = 'Žž'; $output = 'Žž'; $this->assertSame( $output, convert_invalid_entities( $input ) ); } - function test_escapes_lone_ampersands() { + public function test_escapes_lone_ampersands() { $this->assertSame( 'at&t', convert_chars( 'at&t' ) ); } } diff --git a/tests/phpunit/tests/formatting/convertSmilies.php b/tests/phpunit/tests/formatting/convertSmilies.php index 63d95aa071..760625e40a 100644 --- a/tests/phpunit/tests/formatting/convertSmilies.php +++ b/tests/phpunit/tests/formatting/convertSmilies.php @@ -48,7 +48,7 @@ class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase { * Basic Validation Test to confirm that smilies are converted to image * when use_smilies = 1 and not when use_smilies = 0 */ - function test_convert_standard_smilies( $in_txt, $converted_txt ) { + public function test_convert_standard_smilies( $in_txt, $converted_txt ) { // Standard smilies, use_smilies: ON. update_option( 'use_smilies', 1 ); @@ -91,7 +91,7 @@ class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase { * * Validate Custom Smilies are converted to images when use_smilies = 1 */ - function test_convert_custom_smilies( $in_txt, $converted_txt ) { + public function test_convert_custom_smilies( $in_txt, $converted_txt ) { global $wpsmiliestrans; // Custom smilies, use_smilies: ON. @@ -299,7 +299,7 @@ class Tests_Formatting_ConvertSmilies extends WP_UnitTestCase { * @ticket 22692 * @dataProvider get_spaces_around_smilies */ - function test_spaces_around_smilies( $in_txt, $converted_txt ) { + public function test_spaces_around_smilies( $in_txt, $converted_txt ) { // Standard smilies, use_smilies: ON. update_option( 'use_smilies', 1 ); diff --git a/tests/phpunit/tests/formatting/date.php b/tests/phpunit/tests/formatting/date.php index 9b540929e0..9f0f975d4c 100644 --- a/tests/phpunit/tests/formatting/date.php +++ b/tests/phpunit/tests/formatting/date.php @@ -11,7 +11,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { * * @ticket 20328 */ - function test_get_date_from_gmt_outside_of_dst() { + public function test_get_date_from_gmt_outside_of_dst() { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-01-01 12:34:56'; $gmt = $local; @@ -23,7 +23,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { * * @ticket 20328 */ - function test_get_date_from_gmt_during_dst() { + public function test_get_date_from_gmt_during_dst() { update_option( 'timezone_string', 'Europe/London' ); $gmt = '2012-06-01 12:34:56'; $local = '2012-06-01 13:34:56'; @@ -33,7 +33,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 20328 */ - function test_get_gmt_from_date_outside_of_dst() { + public function test_get_gmt_from_date_outside_of_dst() { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-01-01 12:34:56'; $gmt = $local; @@ -43,7 +43,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 20328 */ - function test_get_gmt_from_date_during_dst() { + public function test_get_gmt_from_date_during_dst() { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-06-01 12:34:56'; $gmt = '2012-06-01 11:34:56'; @@ -53,7 +53,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 34279 */ - function test_get_date_and_time_from_gmt_no_timezone() { + public function test_get_date_and_time_from_gmt_no_timezone() { $local = '2012-01-01 12:34:56'; $gmt = $local; $this->assertSame( $gmt, get_date_from_gmt( $local ) ); @@ -62,7 +62,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 34279 */ - function test_get_gmt_from_date_no_timezone() { + public function test_get_gmt_from_date_no_timezone() { $gmt = '2012-12-01 00:00:00'; $date = '2012-12-01'; $this->assertSame( $gmt, get_gmt_from_date( $date ) ); @@ -71,7 +71,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 34279 */ - function test_get_gmt_from_date_short_date() { + public function test_get_gmt_from_date_short_date() { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-12-01'; $gmt = '2012-12-01 00:00:00'; @@ -81,7 +81,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 34279 */ - function test_get_gmt_from_date_string_date() { + public function test_get_gmt_from_date_string_date() { update_option( 'timezone_string', 'Europe/London' ); $local = 'now'; $gmt = gmdate( 'Y-m-d H:i:s' ); @@ -91,7 +91,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { /** * @ticket 34279 */ - function test_get_gmt_from_date_string_date_no_timezone() { + public function test_get_gmt_from_date_string_date_no_timezone() { $local = 'now'; $gmt = gmdate( 'Y-m-d H:i:s' ); $this->assertEqualsWithDelta( strtotime( $gmt ), strtotime( get_gmt_from_date( $local ) ), 2, 'The dates should be equal' ); diff --git a/tests/phpunit/tests/formatting/ent2ncr.php b/tests/phpunit/tests/formatting/ent2ncr.php index 64571580e4..f5859974ef 100644 --- a/tests/phpunit/tests/formatting/ent2ncr.php +++ b/tests/phpunit/tests/formatting/ent2ncr.php @@ -7,7 +7,7 @@ class Tests_Formatting_Ent2ncr extends WP_UnitTestCase { /** * @dataProvider entities */ - function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) { + public function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) { $entity = '&' . $entity . ';'; $ncr = '&#' . $ncr . ';'; $this->assertSame( $ncr, ent2ncr( $entity ), $entity ); @@ -17,7 +17,7 @@ class Tests_Formatting_Ent2ncr extends WP_UnitTestCase { * Get test data from files, one test per line. * Comments start with "###". */ - function entities() { + public function entities() { $entities = file( DIR_TESTDATA . '/formatting/entities.txt' ); $data_provided = array(); foreach ( $entities as $line ) { diff --git a/tests/phpunit/tests/formatting/escAttr.php b/tests/phpunit/tests/formatting/escAttr.php index 65e661ca87..e60c5e9552 100644 --- a/tests/phpunit/tests/formatting/escAttr.php +++ b/tests/phpunit/tests/formatting/escAttr.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_EscAttr extends WP_UnitTestCase { - function test_esc_attr_quotes() { + public function test_esc_attr_quotes() { $attr = '"double quotes"'; $this->assertSame( '"double quotes"', esc_attr( $attr ) ); @@ -25,7 +25,7 @@ class Tests_Formatting_EscAttr extends WP_UnitTestCase { $this->assertSame( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) ); } - function test_esc_attr_amp() { + public function test_esc_attr_amp() { $out = esc_attr( 'foo & bar &baz;  ' ); $this->assertSame( 'foo & bar &baz;  ', $out ); } diff --git a/tests/phpunit/tests/formatting/escHtml.php b/tests/phpunit/tests/formatting/escHtml.php index 4db00dfb0a..3c6b918cfc 100644 --- a/tests/phpunit/tests/formatting/escHtml.php +++ b/tests/phpunit/tests/formatting/escHtml.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_EscHtml extends WP_UnitTestCase { - function test_esc_html_basics() { + public function test_esc_html_basics() { // Simple string. $html = 'The quick brown fox.'; $this->assertSame( $html, esc_html( $html ) ); @@ -20,19 +20,19 @@ class Tests_Formatting_EscHtml extends WP_UnitTestCase { $this->assertSame( $escaped, esc_html( $html ) ); } - function test_escapes_ampersands() { + public function test_escapes_ampersands() { $source = 'penn & teller & at&t'; $res = 'penn & teller & at&t'; $this->assertSame( $res, esc_html( $source ) ); } - function test_escapes_greater_and_less_than() { + public function test_escapes_greater_and_less_than() { $source = 'this > that < that '; $res = 'this > that < that <randomhtml />'; $this->assertSame( $res, esc_html( $source ) ); } - function test_ignores_existing_entities() { + public function test_ignores_existing_entities() { $source = '& £ " &'; $res = '& £ " &'; $this->assertSame( $res, esc_html( $source ) ); diff --git a/tests/phpunit/tests/formatting/escJs.php b/tests/phpunit/tests/formatting/escJs.php index bd6407518b..ddb5420174 100644 --- a/tests/phpunit/tests/formatting/escJs.php +++ b/tests/phpunit/tests/formatting/escJs.php @@ -4,41 +4,41 @@ * @group formatting */ class Tests_Formatting_EscJs extends WP_UnitTestCase { - function test_js_escape_simple() { + public function test_js_escape_simple() { $out = esc_js( 'foo bar baz();' ); $this->assertSame( 'foo bar baz();', $out ); } - function test_js_escape_quotes() { + public function test_js_escape_quotes() { $out = esc_js( 'foo "bar" \'baz\'' ); // Does it make any sense to change " into "? Why not \"? $this->assertSame( "foo "bar" \'baz\'", $out ); } - function test_js_escape_backslash() { + public function test_js_escape_backslash() { $bs = '\\'; $out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' ); // \t becomes t - bug? $this->assertSame( 'foo t bar ' . $bs . $bs . ' baz', $out ); } - function test_js_escape_amp() { + public function test_js_escape_amp() { $out = esc_js( 'foo & bar &baz;  ' ); $this->assertSame( 'foo & bar &baz;  ', $out ); } - function test_js_escape_quote_entity() { + public function test_js_escape_quote_entity() { $out = esc_js( 'foo ' bar ' baz &' ); $this->assertSame( "foo \\' bar \\' baz &", $out ); } - function test_js_no_carriage_return() { + public function test_js_no_carriage_return() { $out = esc_js( "foo\rbar\nbaz\r" ); // \r is stripped. $this->assertSame( "foobar\\nbaz", $out ); } - function test_js_escape_rn() { + public function test_js_escape_rn() { $out = esc_js( "foo\r\nbar\nbaz\r\n" ); // \r is stripped. $this->assertSame( "foo\\nbar\\nbaz\\n", $out ); diff --git a/tests/phpunit/tests/formatting/escTextarea.php b/tests/phpunit/tests/formatting/escTextarea.php index e57f48f99e..8582216ec8 100644 --- a/tests/phpunit/tests/formatting/escTextarea.php +++ b/tests/phpunit/tests/formatting/escTextarea.php @@ -5,7 +5,7 @@ */ class Tests_Formatting_EscTextarea extends WP_UnitTestCase { - function _charset_iso_8859_1() { + public function charset_iso_8859_1() { return 'iso-8859-1'; } @@ -13,24 +13,24 @@ class Tests_Formatting_EscTextarea extends WP_UnitTestCase { * Only fails in PHP 5.4 onwards * @ticket 23688 */ - function test_esc_textarea_charset_iso_8859_1() { - add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); + public function test_esc_textarea_charset_iso_8859_1() { + add_filter( 'pre_option_blog_charset', array( $this, 'charset_iso_8859_1' ) ); $iso8859_1 = 'Fran' . chr( 135 ) . 'ais'; $this->assertSame( $iso8859_1, esc_textarea( $iso8859_1 ) ); - remove_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); + remove_filter( 'pre_option_blog_charset', array( $this, 'charset_iso_8859_1' ) ); } - function _charset_utf_8() { + public function charset_utf_8() { return 'UTF-8'; } /* * @ticket 23688 */ - function test_esc_textarea_charset_utf_8() { - add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); + public function test_esc_textarea_charset_utf_8() { + add_filter( 'pre_option_blog_charset', array( $this, 'charset_utf_8' ) ); $utf8 = 'Fran' . chr( 195 ) . chr( 167 ) . 'ais'; $this->assertSame( $utf8, esc_textarea( $utf8 ) ); - remove_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); + remove_filter( 'pre_option_blog_charset', array( $this, 'charset_utf_8' ) ); } } diff --git a/tests/phpunit/tests/formatting/escUrl.php b/tests/phpunit/tests/formatting/escUrl.php index ccc9083134..4958c115d3 100644 --- a/tests/phpunit/tests/formatting/escUrl.php +++ b/tests/phpunit/tests/formatting/escUrl.php @@ -8,7 +8,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { /** * @ticket 23605 */ - function test_spaces() { + public function test_spaces() { $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) ); $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr%20WordPress' ) ); $this->assertSame( 'http://example.com/Mr%20%20WordPress', esc_url( 'http://example.com/Mr%20%20WordPress' ) ); @@ -19,7 +19,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { $this->assertSame( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one%20two%20three&bar=four' ) ); } - function test_bad_characters() { + public function test_bad_characters() { $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) ); $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) ); $this->assertSame( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0Dgo' ) ); @@ -33,14 +33,14 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADa' ) ); } - function test_relative() { + public function test_relative() { $this->assertSame( '/example.php', esc_url( '/example.php' ) ); $this->assertSame( 'example.php', esc_url( 'example.php' ) ); $this->assertSame( '#fragment', esc_url( '#fragment' ) ); $this->assertSame( '?foo=bar', esc_url( '?foo=bar' ) ); } - function test_all_url_parts() { + public function test_all_url_parts() { $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment'; $this->assertSame( @@ -60,7 +60,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) ); } - function test_bare() { + public function test_bare() { $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) ); $this->assertSame( 'http://example.com', esc_url( 'example.com' ) ); $this->assertSame( 'http://localhost', esc_url( 'localhost' ) ); @@ -68,7 +68,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { $this->assertSame( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) ); } - function test_encoding() { + public function test_encoding() { $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); @@ -81,7 +81,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { $this->assertSame( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) ); } - function test_protocol() { + public function test_protocol() { $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) ); $this->assertSame( '', esc_url( 'nasty://example.com/' ) ); $this->assertSame( @@ -146,23 +146,23 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { /** * @ticket 23187 */ - function test_protocol_case() { + public function test_protocol_case() { $this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) ); $this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) ); } - function test_display_extras() { + public function test_display_extras() { $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) ); $this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) ); } - function test_non_ascii() { + public function test_non_ascii() { $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) ); $this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) ); $this->assertSame( 'http://müller.com/', esc_url( 'http://müller.com/' ) ); } - function test_feed() { + public function test_feed() { $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) ); $this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) ); $this->assertSame( '', esc_url( 'feed:feed:javascript:alert(1)' ) ); @@ -173,7 +173,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { /** * @ticket 16859 */ - function test_square_brackets() { + public function test_square_brackets() { $this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) ); $this->assertSame( '?foo%5Bbar%5D=baz', esc_url( '?foo[bar]=baz' ) ); $this->assertSame( '//example.com/?foo%5Bbar%5D=baz', esc_url( '//example.com/?foo[bar]=baz' ) ); @@ -188,7 +188,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { /** * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding */ - function test_reserved_characters() { + public function test_reserved_characters() { $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;="; $this->assertSame( $url, esc_url_raw( $url ) ); } @@ -196,14 +196,14 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { /** * @ticket 21974 */ - function test_protocol_relative_with_colon() { + public function test_protocol_relative_with_colon() { $this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) ); } /** * @ticket 31632 */ - function test_mailto_with_newline() { + public function test_mailto_with_newline() { $body = <<assertEmpty( esc_url_raw( '"^<>{}`' ) ); } /** * @ticket 34202 */ - function test_ipv6_hosts() { + public function test_ipv6_hosts() { $this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) ); $this->assertSame( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) ); $this->assertSame( 'http://[::127.0.0.1]', esc_url( 'http://[::127.0.0.1]' ) ); diff --git a/tests/phpunit/tests/formatting/excerptRemoveBlocks.php b/tests/phpunit/tests/formatting/excerptRemoveBlocks.php index ca4b9afef8..5657047556 100644 --- a/tests/phpunit/tests/formatting/excerptRemoveBlocks.php +++ b/tests/phpunit/tests/formatting/excerptRemoveBlocks.php @@ -50,7 +50,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase { * * @return string Block output. */ - function render_fake_block() { + public function render_fake_block() { return get_the_excerpt( self::$post_id ); } @@ -59,7 +59,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase { * * @since 5.2.0 */ - function set_up() { + public function set_up() { parent::set_up(); self::$post_id = $this->factory()->post->create( array( @@ -80,7 +80,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase { * * @since 5.2.0 */ - function tear_down() { + public function tear_down() { $registry = WP_Block_Type_Registry::get_instance(); $registry->unregister( 'core/fake' ); @@ -92,7 +92,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase { * * @ticket 46133 */ - function test_excerpt_remove_blocks() { + public function test_excerpt_remove_blocks() { // Simple dynamic block.. $content = ''; @@ -117,7 +117,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase { * * @ticket 46133 */ - function test_excerpt_infinite_loop() { + public function test_excerpt_infinite_loop() { $query = new WP_Query( array( 'post__in' => array( self::$post_id ), diff --git a/tests/phpunit/tests/formatting/getBloginfo.php b/tests/phpunit/tests/formatting/getBloginfo.php index b1f87a0d16..2c80cd99b8 100644 --- a/tests/phpunit/tests/formatting/getBloginfo.php +++ b/tests/phpunit/tests/formatting/getBloginfo.php @@ -9,7 +9,7 @@ class Tests_Formatting_GetBloginfo extends WP_UnitTestCase { * @dataProvider locales * @ticket 28303 */ - function test_get_bloginfo_language( $test_locale, $expected ) { + public function test_get_bloginfo_language( $test_locale, $expected ) { global $locale; $old_locale = $locale; @@ -20,7 +20,7 @@ class Tests_Formatting_GetBloginfo extends WP_UnitTestCase { $locale = $old_locale; } - function locales() { + public function locales() { return array( // Locale, language code. array( 'en_US', 'en-US' ), @@ -36,7 +36,7 @@ class Tests_Formatting_GetBloginfo extends WP_UnitTestCase { /** * @ticket 27942 */ - function test_bloginfo_sanitize_option() { + public function test_bloginfo_sanitize_option() { $old_values = array( 'blogname' => get_option( 'blogname' ), 'blogdescription' => get_option( 'blogdescription' ), diff --git a/tests/phpunit/tests/formatting/getUrlInContent.php b/tests/phpunit/tests/formatting/getUrlInContent.php index edb6c6f656..242fe2db9c 100644 --- a/tests/phpunit/tests/formatting/getUrlInContent.php +++ b/tests/phpunit/tests/formatting/getUrlInContent.php @@ -44,7 +44,7 @@ class Tests_Formatting_GetUrlInContent extends WP_UnitTestCase { * * @dataProvider get_input_output */ - function test_get_url_in_content( $in_str, $exp_str ) { + public function test_get_url_in_content( $in_str, $exp_str ) { $this->assertSame( $exp_str, get_url_in_content( $in_str ) ); } } diff --git a/tests/phpunit/tests/formatting/humanTimeDiff.php b/tests/phpunit/tests/formatting/humanTimeDiff.php index e990d2e49b..f4eb2e2ad6 100644 --- a/tests/phpunit/tests/formatting/humanTimeDiff.php +++ b/tests/phpunit/tests/formatting/humanTimeDiff.php @@ -11,13 +11,13 @@ class Tests_Formatting_HumanTimeDiff extends WP_UnitTestCase { * @ticket 38773 * @dataProvider data_test_human_time_diff */ - function test_human_time_diff( $expected, $stopdate, $message ) { + public function test_human_time_diff( $expected, $stopdate, $message ) { $startdate = new DateTime( '2016-01-01 12:00:00' ); $this->assertSame( $expected, human_time_diff( $startdate->format( 'U' ), $stopdate->format( 'U' ) ), $message ); } // Data for test_human_time_diff. - function data_test_human_time_diff() { + public function data_test_human_time_diff() { return array( array( '37 seconds', diff --git a/tests/phpunit/tests/formatting/isEmail.php b/tests/phpunit/tests/formatting/isEmail.php index ddc24a636e..eea7b61926 100644 --- a/tests/phpunit/tests/formatting/isEmail.php +++ b/tests/phpunit/tests/formatting/isEmail.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_IsEmail extends WP_UnitTestCase { - function test_returns_the_email_address_if_it_is_valid() { + public function test_returns_the_email_address_if_it_is_valid() { $data = array( 'bob@example.com', 'phil@example.info', @@ -18,7 +18,7 @@ class Tests_Formatting_IsEmail extends WP_UnitTestCase { } } - function test_returns_false_if_given_an_invalid_email_address() { + public function test_returns_false_if_given_an_invalid_email_address() { $data = array( 'khaaaaaaaaaaaaaaan!', 'http://bob.example.com/', diff --git a/tests/phpunit/tests/formatting/likeEscape.php b/tests/phpunit/tests/formatting/likeEscape.php index a565e2fe9b..d24f4e6675 100644 --- a/tests/phpunit/tests/formatting/likeEscape.php +++ b/tests/phpunit/tests/formatting/likeEscape.php @@ -8,7 +8,7 @@ class Tests_Formatting_LikeEscape extends WP_UnitTestCase { * @ticket 10041 * @expectedDeprecated like_escape */ - function test_like_escape() { + public function test_like_escape() { $inputs = array( 'howdy%', // Single percent. diff --git a/tests/phpunit/tests/formatting/linksAddTarget.php b/tests/phpunit/tests/formatting/linksAddTarget.php index 391ad1736f..ce8e506440 100644 --- a/tests/phpunit/tests/formatting/linksAddTarget.php +++ b/tests/phpunit/tests/formatting/linksAddTarget.php @@ -96,7 +96,7 @@ class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase { * * @dataProvider get_input_output */ - function test_normalize_whitespace( $content, $target, $tags, $exp_str ) { + public function test_normalize_whitespace( $content, $target, $tags, $exp_str ) { if ( true === is_null( $target ) ) { $this->assertSame( $exp_str, links_add_target( $content ) ); } elseif ( true === is_null( $tags ) ) { diff --git a/tests/phpunit/tests/formatting/makeClickable.php b/tests/phpunit/tests/formatting/makeClickable.php index 8841548fa6..a0db986076 100644 --- a/tests/phpunit/tests/formatting/makeClickable.php +++ b/tests/phpunit/tests/formatting/makeClickable.php @@ -4,12 +4,12 @@ * @group formatting */ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { - function test_mailto_xss() { + public function test_mailto_xss() { $in = 'testzzz@"STYLE="behavior:url(\'#default#time2\')"onBegin="alert(\'refresh-XSS\')"'; $this->assertSame( $in, make_clickable( $in ) ); } - function test_valid_mailto() { + public function test_valid_mailto() { $valid_emails = array( 'foo@example.com', 'foo.bar@example.com', @@ -22,7 +22,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { } } - function test_invalid_mailto() { + public function test_invalid_mailto() { $invalid_emails = array( 'foo', 'foo@', @@ -40,7 +40,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { * Tests that make_clickable() will not link trailing periods, commas, * and (semi-)colons in URLs with protocol (i.e. http://wordpress.org). */ - function test_strip_trailing_with_protocol() { + public function test_strip_trailing_with_protocol() { $urls_before = array( 'http://wordpress.org/hello.html', 'There was a spoon named http://wordpress.org. Alice!', @@ -67,7 +67,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { * Tests that make_clickable() will not link trailing periods, commas, * and (semi-)colons in URLs with protocol (i.e. http://wordpress.org). */ - function test_strip_trailing_with_protocol_nothing_afterwards() { + public function test_strip_trailing_with_protocol_nothing_afterwards() { $urls_before = array( 'http://wordpress.org/hello.html', 'There was a spoon named http://wordpress.org.', @@ -96,7 +96,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { * Tests that make_clickable() will not link trailing periods, commas, * and (semi-)colons in URLs without protocol (i.e. www.wordpress.org). */ - function test_strip_trailing_without_protocol() { + public function test_strip_trailing_without_protocol() { $urls_before = array( 'www.wordpress.org', 'There was a spoon named www.wordpress.org. Alice!', @@ -123,7 +123,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { * Tests that make_clickable() will not link trailing periods, commas, * and (semi-)colons in URLs without protocol (i.e. www.wordpress.org). */ - function test_strip_trailing_without_protocol_nothing_afterwards() { + public function test_strip_trailing_without_protocol_nothing_afterwards() { $urls_before = array( 'www.wordpress.org', 'There was a spoon named www.wordpress.org.', @@ -149,7 +149,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 4570 */ - function test_iri() { + public function test_iri() { $urls_before = array( 'http://www.詹姆斯.com/', 'http://bg.wikipedia.org/Баба', @@ -168,7 +168,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 10990 */ - function test_brackets_in_urls() { + public function test_brackets_in_urls() { $urls_before = array( 'http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)', '(http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software))', @@ -207,7 +207,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { * * @ticket 11211 */ - function test_real_world_examples() { + public function test_real_world_examples() { $urls_before = array( 'Example: WordPress, test (some text), I love example.com (http://example.org), it is brilliant', 'Example: WordPress, test (some text), I love example.com (http://example.com), it is brilliant', @@ -228,7 +228,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 14993 */ - function test_twitter_hash_bang() { + public function test_twitter_hash_bang() { $urls_before = array( 'http://twitter.com/#!/wordpress/status/25907440233', 'This is a really good tweet http://twitter.com/#!/wordpress/status/25907440233 !', @@ -244,7 +244,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { } } - function test_wrapped_in_angles() { + public function test_wrapped_in_angles() { $before = array( 'URL wrapped in angle brackets ', 'URL wrapped in angle brackets with padding < http://example.com/ >', @@ -260,7 +260,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { } } - function test_preceded_by_punctuation() { + public function test_preceded_by_punctuation() { $before = array( 'Comma then URL,http://example.com/', 'Period then URL.http://example.com/', @@ -282,7 +282,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { } } - function test_dont_break_attributes() { + public function test_dont_break_attributes() { $urls_before = array( ":)", "(:))", @@ -309,7 +309,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 23756 */ - function test_no_links_inside_pre_or_code() { + public function test_no_links_inside_pre_or_code() { $before = array( '
http://wordpress.org
', 'http://wordpress.org', @@ -350,7 +350,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 16892 */ - function test_click_inside_html() { + public function test_click_inside_html() { $urls_before = array( 'http://example.com', '

http://example.com/

', @@ -364,7 +364,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { } } - function test_no_links_within_links() { + public function test_no_links_within_links() { $in = array( 'Some text with a link http://example.com', // 'This is already a link www.wordpress.org', // Fails in 3.3.1 too. @@ -377,7 +377,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 16892 */ - function test_no_segfault() { + public function test_no_segfault() { $in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 ); $out = make_clickable( $in ); $this->assertSame( $in, $out ); @@ -386,7 +386,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { /** * @ticket 19028 */ - function test_line_break_in_existing_clickable_link() { + public function test_line_break_in_existing_clickable_link() { $html = "someone@example.com"; $this->assertSame( $html, make_clickable( $html ) ); diff --git a/tests/phpunit/tests/formatting/normalizeWhitespace.php b/tests/phpunit/tests/formatting/normalizeWhitespace.php index 9d963e0ef6..2e7668698a 100644 --- a/tests/phpunit/tests/formatting/normalizeWhitespace.php +++ b/tests/phpunit/tests/formatting/normalizeWhitespace.php @@ -46,7 +46,7 @@ class Tests_Formatting_NormalizeWhitespace extends WP_UnitTestCase { * * @dataProvider get_input_output */ - function test_normalize_whitespace( $in_str, $exp_str ) { + public function test_normalize_whitespace( $in_str, $exp_str ) { $this->assertSame( $exp_str, normalize_whitespace( $in_str ) ); } } diff --git a/tests/phpunit/tests/formatting/redirect.php b/tests/phpunit/tests/formatting/redirect.php index 6397e468f3..e1004493bd 100644 --- a/tests/phpunit/tests/formatting/redirect.php +++ b/tests/phpunit/tests/formatting/redirect.php @@ -6,12 +6,12 @@ * @group redirect */ class Tests_Formatting_Redirect extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); add_filter( 'home_url', array( $this, 'home_url' ) ); } - function home_url() { + public function home_url() { return 'http://example.com/'; } @@ -41,7 +41,7 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { ); } - function test_wp_sanitize_redirect() { + public function test_wp_sanitize_redirect() { $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0Ago' ) ); $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0ago' ) ); $this->assertSame( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0Dgo' ) ); @@ -60,7 +60,7 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { /** * @ticket 36998 */ - function test_wp_sanitize_redirect_should_encode_spaces() { + public function test_wp_sanitize_redirect_should_encode_spaces() { $this->assertSame( 'http://example.com/test%20spaces', wp_sanitize_redirect( 'http://example.com/test%20spaces' ) ); $this->assertSame( 'http://example.com/test%20spaces%20in%20url', wp_sanitize_redirect( 'http://example.com/test spaces in url' ) ); } @@ -68,18 +68,18 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { /** * @dataProvider valid_url_provider */ - function test_wp_validate_redirect_valid_url( $url, $expected ) { + public function test_wp_validate_redirect_valid_url( $url, $expected ) { $this->assertSame( $expected, wp_validate_redirect( $url ) ); } /** * @dataProvider invalid_url_provider */ - function test_wp_validate_redirect_invalid_url( $url ) { + public function test_wp_validate_redirect_invalid_url( $url ) { $this->assertEquals( false, wp_validate_redirect( $url, false ) ); } - function valid_url_provider() { + public function valid_url_provider() { return array( array( 'http://example.com', 'http://example.com' ), array( 'http://example.com/', 'http://example.com/' ), @@ -95,7 +95,7 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { ); } - function invalid_url_provider() { + public function invalid_url_provider() { return array( // parse_url() fails. array( '' ), @@ -167,7 +167,7 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { * @ticket 47980 * @dataProvider relative_url_provider */ - function test_wp_validate_redirect_relative_url( $current_uri, $url, $expected ) { + public function test_wp_validate_redirect_relative_url( $current_uri, $url, $expected ) { // Backup the global. $unset = false; if ( ! isset( $_SERVER['REQUEST_URI'] ) ) { @@ -198,7 +198,7 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { * string Expected destination. * } */ - function relative_url_provider() { + public function relative_url_provider() { return array( array( '/', diff --git a/tests/phpunit/tests/formatting/removeAccents.php b/tests/phpunit/tests/formatting/removeAccents.php index e66b876e02..19fd50586b 100644 --- a/tests/phpunit/tests/formatting/removeAccents.php +++ b/tests/phpunit/tests/formatting/removeAccents.php @@ -80,7 +80,7 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { $this->assertSame( 'aaeiouuAEIOUU', remove_accents( 'aɑeiouüAEIOUÜ' ) ); } - function _remove_accents_germanic_umlauts_cb() { + public function remove_accents_germanic_umlauts_cb() { return 'de_DE'; } @@ -88,14 +88,14 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { * @ticket 3782 */ public function test_remove_accents_germanic_umlauts() { - add_filter( 'locale', array( $this, '_remove_accents_germanic_umlauts_cb' ) ); + add_filter( 'locale', array( $this, 'remove_accents_germanic_umlauts_cb' ) ); $this->assertSame( 'AeOeUeaeoeuess', remove_accents( 'ÄÖÜäöüß' ) ); - remove_filter( 'locale', array( $this, '_remove_accents_germanic_umlauts_cb' ) ); + remove_filter( 'locale', array( $this, 'remove_accents_germanic_umlauts_cb' ) ); } - public function _set_locale_to_danish() { + public function set_locale_to_danish() { return 'da_DK'; } @@ -103,14 +103,14 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { * @ticket 23907 */ public function test_remove_danish_accents() { - add_filter( 'locale', array( $this, '_set_locale_to_danish' ) ); + add_filter( 'locale', array( $this, 'set_locale_to_danish' ) ); $this->assertSame( 'AeOeAaaeoeaa', remove_accents( 'ÆØÅæøå' ) ); - remove_filter( 'locale', array( $this, '_set_locale_to_danish' ) ); + remove_filter( 'locale', array( $this, 'set_locale_to_danish' ) ); } - public function _set_locale_to_catalan() { + public function set_locale_to_catalan() { return 'ca'; } @@ -118,16 +118,16 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { * @ticket 37086 */ public function test_remove_catalan_middot() { - add_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); + add_filter( 'locale', array( $this, 'set_locale_to_catalan' ) ); $this->assertSame( 'allallalla', remove_accents( 'al·lallaŀla' ) ); - remove_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); + remove_filter( 'locale', array( $this, 'set_locale_to_catalan' ) ); $this->assertSame( 'al·lallalla', remove_accents( 'al·lallaŀla' ) ); } - public function _set_locale_to_serbian() { + public function set_locale_to_serbian() { return 'sr_RS'; } @@ -135,11 +135,11 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { * @ticket 38078 */ public function test_transcribe_serbian_crossed_d() { - add_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); + add_filter( 'locale', array( $this, 'set_locale_to_serbian' ) ); $this->assertSame( 'DJdj', remove_accents( 'Đđ' ) ); - remove_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); + remove_filter( 'locale', array( $this, 'set_locale_to_serbian' ) ); $this->assertSame( 'Dd', remove_accents( 'Đđ' ) ); } diff --git a/tests/phpunit/tests/formatting/sanitizeFileName.php b/tests/phpunit/tests/formatting/sanitizeFileName.php index c14803311d..fbec256219 100644 --- a/tests/phpunit/tests/formatting/sanitizeFileName.php +++ b/tests/phpunit/tests/formatting/sanitizeFileName.php @@ -4,13 +4,13 @@ * @group formatting */ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { - function test_munges_extensions() { + public function test_munges_extensions() { // r17990 $file_name = sanitize_file_name( 'test.phtml.txt' ); $this->assertSame( 'test.phtml_.txt', $file_name ); } - function test_removes_special_chars() { + public function test_removes_special_chars() { $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) ); $string = 'test'; foreach ( $special_chars as $char ) { @@ -23,7 +23,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { /** * @ticket 22363 */ - function test_removes_accents() { + public function test_removes_accents() { $in = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ'; $out = 'aaaaaaaeceeeeiiiinoooooouuuuyy'; $this->assertSame( $out, sanitize_file_name( $in ) ); @@ -34,7 +34,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { * * @ticket 16330 */ - function test_replaces_spaces() { + public function test_replaces_spaces() { $urls = array( 'unencoded space.png' => 'unencoded-space.png', 'encoded-space.jpg' => 'encoded-space.jpg', @@ -47,15 +47,15 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { } } - function test_replaces_any_number_of_hyphens_with_one_hyphen() { + public function test_replaces_any_number_of_hyphens_with_one_hyphen() { $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) ); } - function test_trims_trailing_hyphens() { + public function test_trims_trailing_hyphens() { $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) ); } - function test_replaces_any_amount_of_whitespace_with_one_hyphen() { + public function test_replaces_any_amount_of_whitespace_with_one_hyphen() { $this->assertSame( 'a-t', sanitize_file_name( 'a t' ) ); $this->assertSame( 'a-t', sanitize_file_name( "a \n\n\nt" ) ); } @@ -63,17 +63,17 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { /** * @ticket 16226 */ - function test_replaces_percent_sign() { + public function test_replaces_percent_sign() { $this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) ); } - function test_replaces_unnamed_file_extensions() { + public function test_replaces_unnamed_file_extensions() { // Test filenames with both supported and unsupported extensions. $this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) ); $this->assertSame( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) ); } - function test_replaces_unnamed_file_extensionless() { + public function test_replaces_unnamed_file_extensionless() { // Test a filenames that becomes extensionless. $this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) ); } @@ -81,11 +81,11 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { /** * @dataProvider data_wp_filenames */ - function test_replaces_invalid_utf8_characters( $input, $expected ) { + public function test_replaces_invalid_utf8_characters( $input, $expected ) { $this->assertSame( $expected, sanitize_file_name( $input ) ); } - function data_wp_filenames() { + public function data_wp_filenames() { return array( array( urldecode( '%B1myfile.png' ), 'myfile.png' ), array( urldecode( '%B1myfile' ), 'myfile' ), diff --git a/tests/phpunit/tests/formatting/sanitizeMimeType.php b/tests/phpunit/tests/formatting/sanitizeMimeType.php index 45c8ec611f..77c8b47205 100644 --- a/tests/phpunit/tests/formatting/sanitizeMimeType.php +++ b/tests/phpunit/tests/formatting/sanitizeMimeType.php @@ -8,7 +8,7 @@ class Tests_Formatting_SanitizeMimeType extends WP_UnitTestCase { /** * @ticket 17855 */ - function test_sanitize_valid_mime_type() { + public function test_sanitize_valid_mime_type() { $inputs = array( 'application/atom+xml', 'application/EDI-X12', diff --git a/tests/phpunit/tests/formatting/sanitizeOrderby.php b/tests/phpunit/tests/formatting/sanitizeOrderby.php index 95d2bed15e..cede007886 100644 --- a/tests/phpunit/tests/formatting/sanitizeOrderby.php +++ b/tests/phpunit/tests/formatting/sanitizeOrderby.php @@ -9,10 +9,10 @@ class Tests_Formatting_SanitizeOrderby extends WP_UnitTestCase { * @covers ::sanitize_sql_orderby * @dataProvider valid_orderbys */ - function test_valid( $orderby ) { + public function test_valid( $orderby ) { $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) ); } - function valid_orderbys() { + public function valid_orderbys() { return array( array( '1' ), array( '1 ASC' ), @@ -36,10 +36,10 @@ class Tests_Formatting_SanitizeOrderby extends WP_UnitTestCase { * @covers ::sanitize_sql_orderby * @dataProvider invalid_orderbys */ - function test_invalid( $orderby ) { + public function test_invalid( $orderby ) { $this->assertFalse( sanitize_sql_orderby( $orderby ) ); } - function invalid_orderbys() { + public function invalid_orderbys() { return array( array( '' ), array( '1 2' ), diff --git a/tests/phpunit/tests/formatting/sanitizePost.php b/tests/phpunit/tests/formatting/sanitizePost.php index 7a4d289262..1e69e703c1 100644 --- a/tests/phpunit/tests/formatting/sanitizePost.php +++ b/tests/phpunit/tests/formatting/sanitizePost.php @@ -8,7 +8,7 @@ class Tests_Formatting_SanitizePost extends WP_UnitTestCase { /** * @ticket 22324 */ - function test_int_fields() { + public function test_int_fields() { $post = self::factory()->post->create_and_get(); $int_fields = array( 'ID' => 'integer', diff --git a/tests/phpunit/tests/formatting/sanitizeTextField.php b/tests/phpunit/tests/formatting/sanitizeTextField.php index 00c19faa17..8d5d0ff0dd 100644 --- a/tests/phpunit/tests/formatting/sanitizeTextField.php +++ b/tests/phpunit/tests/formatting/sanitizeTextField.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase { - function data_sanitize_text_field() { + public function data_sanitize_text_field() { return array( array( 'оРангутанг', // Ensure UTF-8 text is safe. The Р is D0 A0 and A0 is the non-breaking space. @@ -128,7 +128,7 @@ class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase { * @ticket 32257 * @dataProvider data_sanitize_text_field */ - function test_sanitize_text_field( $string, $expected ) { + public function test_sanitize_text_field( $string, $expected ) { if ( is_array( $expected ) ) { $expected_oneline = $expected['oneline']; $expected_multiline = $expected['multiline']; diff --git a/tests/phpunit/tests/formatting/sanitizeTitle.php b/tests/phpunit/tests/formatting/sanitizeTitle.php index a389d580ba..7ce850f0fc 100644 --- a/tests/phpunit/tests/formatting/sanitizeTitle.php +++ b/tests/phpunit/tests/formatting/sanitizeTitle.php @@ -4,13 +4,13 @@ * @group formatting */ class Tests_Formatting_SanitizeTitle extends WP_UnitTestCase { - function test_strips_html() { + public function test_strips_html() { $input = 'Captain Awesome'; $expected = 'captain-awesome'; $this->assertSame( $expected, sanitize_title( $input ) ); } - function test_titles_sanitized_to_nothing_are_replaced_with_optional_fallback() { + public function test_titles_sanitized_to_nothing_are_replaced_with_optional_fallback() { $input = ''; $fallback = 'Captain Awesome'; $this->assertSame( $fallback, sanitize_title( $input, $fallback ) ); diff --git a/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php b/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php index 80438d4a94..797a36f018 100644 --- a/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php +++ b/tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php @@ -4,34 +4,34 @@ * @group formatting */ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { - function test_strips_html() { + public function test_strips_html() { $input = 'Captain Awesome'; $expected = 'captain-awesome'; $this->assertSame( $expected, sanitize_title_with_dashes( $input ) ); } - function test_strips_unencoded_percent_signs() { + public function test_strips_unencoded_percent_signs() { $this->assertSame( 'fran%c3%a7ois', sanitize_title_with_dashes( 'fran%c3%a7%ois' ) ); } - function test_makes_title_lowercase() { + public function test_makes_title_lowercase() { $this->assertSame( 'abc', sanitize_title_with_dashes( 'ABC' ) ); } - function test_replaces_any_amount_of_whitespace_with_one_hyphen() { + public function test_replaces_any_amount_of_whitespace_with_one_hyphen() { $this->assertSame( 'a-t', sanitize_title_with_dashes( 'a t' ) ); $this->assertSame( 'a-t', sanitize_title_with_dashes( "a \n\n\nt" ) ); } - function test_replaces_any_number_of_hyphens_with_one_hyphen() { + public function test_replaces_any_number_of_hyphens_with_one_hyphen() { $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t' ) ); } - function test_trims_trailing_hyphens() { + public function test_trims_trailing_hyphens() { $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t----' ) ); } - function test_handles_non_entity_ampersands() { + public function test_handles_non_entity_ampersands() { $this->assertSame( 'penn-teller-bull', sanitize_title_with_dashes( 'penn & teller bull' ) ); } @@ -59,18 +59,18 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { $this->assertSame( 'onetwo', sanitize_title_with_dashes( 'One&Two', '', 'save' ) ); } - function test_replaces_nbsp() { + public function test_replaces_nbsp() { $this->assertSame( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); } /** * @ticket 31790 */ - function test_replaces_nbsp_entities() { + public function test_replaces_nbsp_entities() { $this->assertSame( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); } - function test_replaces_ndash_mdash() { + public function test_replaces_ndash_mdash() { $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the Dash', '', 'save' ) ); $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do the — Dash', '', 'save' ) ); } @@ -78,22 +78,22 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { /** * @ticket 31790 */ - function test_replaces_ndash_mdash_entities() { + public function test_replaces_ndash_mdash_entities() { $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the – Dash', '', 'save' ) ); $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) ); } - function test_replaces_iexcel_iquest() { + public function test_replaces_iexcel_iquest() { $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) ); $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) ); } - function test_replaces_angle_quotes() { + public function test_replaces_angle_quotes() { $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '‹Just a Slug›', '', 'save' ) ); $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '«Just a Slug»', '', 'save' ) ); } - function test_replaces_curly_quotes() { + public function test_replaces_curly_quotes() { $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its “Curly Joe”', '', 'save' ) ); $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‘Curly Joe’', '', 'save' ) ); $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe“', '', 'save' ) ); @@ -104,11 +104,11 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { /** * @ticket 49791 */ - function test_replaces_bullet() { + public function test_replaces_bullet() { $this->assertSame( 'fancy-title-amazing', sanitize_title_with_dashes( 'Fancy Title • Amazing', '', 'save' ) ); } - function test_replaces_copy_reg_deg_trade() { + public function test_replaces_copy_reg_deg_trade() { $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just © a Slug', '', 'save' ) ); $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '® Just a Slug', '', 'save' ) ); $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a ° Slug', '', 'save' ) ); @@ -118,7 +118,7 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { /** * @ticket 10792 */ - function test_replaces_forward_slash() { + public function test_replaces_forward_slash() { $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/McCartney', '', 'save' ) ); $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon//McCartney', '', 'save' ) ); $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon///McCartney', '', 'save' ) ); @@ -129,21 +129,21 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { /** * @ticket 19820 */ - function test_replaces_multiply_sign() { + public function test_replaces_multiply_sign() { $this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) ); } /** * @ticket 20772 */ - function test_replaces_standalone_diacritic() { + public function test_replaces_standalone_diacritic() { $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'āáǎà', '', 'save' ) ); } /** * @ticket 22395 */ - function test_replaces_acute_accents() { + public function test_replaces_acute_accents() { $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'ááa´aˊ', '', 'save' ) ); } diff --git a/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php b/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php index d790cdcc16..8337a2a662 100644 --- a/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php +++ b/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php @@ -8,11 +8,11 @@ class Tests_Formatting_SanitizeTrackbackUrls extends WP_UnitTestCase { * @ticket 21624 * @dataProvider breaks */ - function test_sanitize_trackback_urls_with_multiple_urls( $break ) { + public function test_sanitize_trackback_urls_with_multiple_urls( $break ) { $this->assertSame( "http://example.com\nhttp://example.org", sanitize_trackback_urls( "http://example.com{$break}http://example.org" ) ); } - function breaks() { + public function breaks() { return array( array( "\r\n\t " ), array( "\r" ), diff --git a/tests/phpunit/tests/formatting/sanitizeUser.php b/tests/phpunit/tests/formatting/sanitizeUser.php index 43533c6642..e0ae998f5e 100644 --- a/tests/phpunit/tests/formatting/sanitizeUser.php +++ b/tests/phpunit/tests/formatting/sanitizeUser.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_SanitizeUser extends WP_UnitTestCase { - function test_strips_html() { + public function test_strips_html() { $input = 'Captain Awesome'; $expected = is_multisite() ? 'captain awesome' : 'Captain Awesome'; $this->assertSame( $expected, sanitize_user( $input ) ); @@ -32,11 +32,11 @@ class Tests_Formatting_SanitizeUser extends WP_UnitTestCase { $this->assertSame( $expected, sanitize_user( 'AT&T Test;' ) ); } - function test_strips_percent_encoded_octets() { + public function test_strips_percent_encoded_octets() { $expected = is_multisite() ? 'franois' : 'Franois'; $this->assertSame( $expected, sanitize_user( 'Fran%c3%a7ois' ) ); } - function test_optional_strict_mode_reduces_to_safe_ascii_subset() { + public function test_optional_strict_mode_reduces_to_safe_ascii_subset() { $this->assertSame( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) ); } } diff --git a/tests/phpunit/tests/formatting/seemsUtf8.php b/tests/phpunit/tests/formatting/seemsUtf8.php index 5571ba3234..a5a6157fd2 100644 --- a/tests/phpunit/tests/formatting/seemsUtf8.php +++ b/tests/phpunit/tests/formatting/seemsUtf8.php @@ -10,12 +10,12 @@ class Tests_Formatting_SeemsUtf8 extends WP_UnitTestCase { * * @dataProvider utf8_strings */ - function test_returns_true_for_utf8_strings( $utf8_string ) { + public function test_returns_true_for_utf8_strings( $utf8_string ) { // From http://www.i18nguy.com/unicode-example.html $this->assertTrue( seems_utf8( $utf8_string ) ); } - function utf8_strings() { + public function utf8_strings() { $utf8_strings = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' ); foreach ( $utf8_strings as &$string ) { $string = (array) trim( $string ); @@ -27,11 +27,11 @@ class Tests_Formatting_SeemsUtf8 extends WP_UnitTestCase { /** * @dataProvider big5_strings */ - function test_returns_false_for_non_utf8_strings( $big5_string ) { + public function test_returns_false_for_non_utf8_strings( $big5_string ) { $this->assertFalse( seems_utf8( $big5_string ) ); } - function big5_strings() { + public function big5_strings() { // Get data from formatting/big5.txt. $big5_strings = file( DIR_TESTDATA . '/formatting/big5.txt' ); foreach ( $big5_strings as &$string ) { diff --git a/tests/phpunit/tests/formatting/slashit.php b/tests/phpunit/tests/formatting/slashit.php index 9f25694405..9c32aa2c64 100644 --- a/tests/phpunit/tests/formatting/slashit.php +++ b/tests/phpunit/tests/formatting/slashit.php @@ -4,19 +4,19 @@ * @group formatting */ class Tests_Formatting_Slashit extends WP_UnitTestCase { - function test_backslashes_middle_numbers() { + public function test_backslashes_middle_numbers() { $this->assertSame( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) ); } - function test_backslashes_alphas() { + public function test_backslashes_alphas() { $this->assertSame( "\\a943\\b\\c", backslashit( 'a943bc' ) ); } - function test_double_backslashes_leading_numbers() { + public function test_double_backslashes_leading_numbers() { $this->assertSame( '\\\\95', backslashit( '95' ) ); } - function test_removes_trailing_slashes() { + public function test_removes_trailing_slashes() { $this->assertSame( 'a', untrailingslashit( 'a/' ) ); $this->assertSame( 'a', untrailingslashit( 'a////' ) ); } @@ -24,7 +24,7 @@ class Tests_Formatting_Slashit extends WP_UnitTestCase { /** * @ticket 22267 */ - function test_removes_trailing_backslashes() { + public function test_removes_trailing_backslashes() { $this->assertSame( 'a', untrailingslashit( 'a\\' ) ); $this->assertSame( 'a', untrailingslashit( 'a\\\\\\\\' ) ); } @@ -32,23 +32,23 @@ class Tests_Formatting_Slashit extends WP_UnitTestCase { /** * @ticket 22267 */ - function test_removes_trailing_mixed_slashes() { + public function test_removes_trailing_mixed_slashes() { $this->assertSame( 'a', untrailingslashit( 'a/\\' ) ); $this->assertSame( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) ); } - function test_adds_trailing_slash() { + public function test_adds_trailing_slash() { $this->assertSame( 'a/', trailingslashit( 'a' ) ); } - function test_does_not_add_trailing_slash_if_one_exists() { + public function test_does_not_add_trailing_slash_if_one_exists() { $this->assertSame( 'a/', trailingslashit( 'a/' ) ); } /** * @ticket 22267 */ - function test_converts_trailing_backslash_to_slash_if_one_exists() { + public function test_converts_trailing_backslash_to_slash_if_one_exists() { $this->assertSame( 'a/', trailingslashit( 'a\\' ) ); } } diff --git a/tests/phpunit/tests/formatting/stripslashesDeep.php b/tests/phpunit/tests/formatting/stripslashesDeep.php index a475f9402a..c5ce91b44b 100644 --- a/tests/phpunit/tests/formatting/stripslashesDeep.php +++ b/tests/phpunit/tests/formatting/stripslashesDeep.php @@ -8,7 +8,7 @@ class Tests_Formatting_StripslashesDeep extends WP_UnitTestCase { /** * @ticket 18026 */ - function test_preserves_original_datatype() { + public function test_preserves_original_datatype() { $this->assertTrue( stripslashes_deep( true ) ); $this->assertFalse( stripslashes_deep( false ) ); @@ -31,7 +31,7 @@ class Tests_Formatting_StripslashesDeep extends WP_UnitTestCase { $this->assertSame( $obj, stripslashes_deep( $obj ) ); } - function test_strips_slashes() { + public function test_strips_slashes() { $old = "I can\'t see, isn\'t that it?"; $new = "I can't see, isn't that it?"; $this->assertSame( $new, stripslashes_deep( $old ) ); @@ -46,7 +46,7 @@ class Tests_Formatting_StripslashesDeep extends WP_UnitTestCase { $this->assertEquals( $obj_new, stripslashes_deep( $obj_old ) ); } - function test_permits_escaped_slash() { + public function test_permits_escaped_slash() { $txt = "I can't see, isn\'t that it?"; $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\'t that it?" ) ); $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\\\'t that it?" ) ); diff --git a/tests/phpunit/tests/formatting/urlShorten.php b/tests/phpunit/tests/formatting/urlShorten.php index 94e2728e6b..5900e358e9 100644 --- a/tests/phpunit/tests/formatting/urlShorten.php +++ b/tests/phpunit/tests/formatting/urlShorten.php @@ -4,7 +4,7 @@ * @group formatting */ class Tests_Formatting_UrlShorten extends WP_UnitTestCase { - function test_url_shorten() { + public function test_url_shorten() { $tests = array( 'wordpress\.org/about/philosophy' => 'wordpress\.org/about/philosophy', // No longer strips slashes. 'wordpress.org/about/philosophy' => 'wordpress.org/about/philosophy', diff --git a/tests/phpunit/tests/formatting/utf8UriEncode.php b/tests/phpunit/tests/formatting/utf8UriEncode.php index a3538e0397..310b906104 100644 --- a/tests/phpunit/tests/formatting/utf8UriEncode.php +++ b/tests/phpunit/tests/formatting/utf8UriEncode.php @@ -11,19 +11,19 @@ class Tests_Formatting_Utf8UriEncode extends WP_UnitTestCase { * * @dataProvider data */ - function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) { + public function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) { $this->assertSame( $urlencoded, utf8_uri_encode( $utf8 ) ); } /** * @dataProvider data */ - function test_output_is_not_longer_than_optional_length_argument( $utf8, $unused_for_this_test ) { + public function test_output_is_not_longer_than_optional_length_argument( $utf8, $unused_for_this_test ) { $max_length = 30; $this->assertTrue( strlen( utf8_uri_encode( $utf8, $max_length ) ) <= $max_length ); } - function data() { + public function data() { $utf8_urls = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' ); $urlencoded = file( DIR_TESTDATA . '/formatting/utf-8/urlencoded.txt' ); $data_provided = array(); diff --git a/tests/phpunit/tests/formatting/wpAutop.php b/tests/phpunit/tests/formatting/wpAutop.php index ccb6721073..35567e8742 100644 --- a/tests/phpunit/tests/formatting/wpAutop.php +++ b/tests/phpunit/tests/formatting/wpAutop.php @@ -8,7 +8,7 @@ class Tests_Formatting_wpAutop extends WP_UnitTestCase { /** * @ticket 11008 */ - function test_first_post() { + public function test_first_post() { $expected = '

Welcome to WordPress! This post contains important information. After you read it, you can make it private to hide it from visitors but still have the information handy for future reference.

First things first:

    @@ -282,7 +282,7 @@ Paragraph two.'; * * @ticket 27268 */ - function test_that_wpautop_treats_block_level_elements_as_blocks() { + public function test_that_wpautop_treats_block_level_elements_as_blocks() { $blocks = array( 'table', 'thead', @@ -376,7 +376,7 @@ Paragraph two.'; * * @ticket 27268 */ - function test_that_wpautop_does_not_wrap_blockquotes_but_does_autop_their_contents() { + public function test_that_wpautop_does_not_wrap_blockquotes_but_does_autop_their_contents() { $content = '
    foo
    '; $expected = '

    foo

    '; @@ -388,7 +388,7 @@ Paragraph two.'; * * @ticket 27268 */ - function test_that_wpautop_treats_inline_elements_as_inline() { + public function test_that_wpautop_treats_inline_elements_as_inline() { $inlines = array( 'a', 'em', @@ -438,11 +438,11 @@ Paragraph two.'; * @ticket 33106 * @dataProvider data_element_sanity */ - function test_element_sanity( $input, $output ) { + public function test_element_sanity( $input, $output ) { return $this->assertSame( $output, wpautop( $input ) ); } - function data_element_sanity() { + public function data_element_sanity() { return array( array( "Hello ", @@ -490,7 +490,7 @@ Paragraph two.'; * * @ticket 33377 */ - function test_that_wpautop_skips_line_breaks_after_br() { + public function test_that_wpautop_skips_line_breaks_after_br() { $content = ' line 1
    line 2
    @@ -513,7 +513,7 @@ line 5

    '; * * @ticket 33377 */ - function test_that_wpautop_adds_a_paragraph_after_multiple_br() { + public function test_that_wpautop_adds_a_paragraph_after_multiple_br() { $content = ' line 1

    @@ -531,7 +531,7 @@ line 2
    /** * @ticket 4857 */ - function test_that_text_before_blocks_is_peed() { + public function test_that_text_before_blocks_is_peed() { $content = 'a
    b
    '; $expected = "

    a

    \n
    b
    "; @@ -546,7 +546,7 @@ line 2
    * * @ticket 39307 */ - function test_that_wpautop_does_not_add_extra_closing_p_in_figure() { + public function test_that_wpautop_does_not_add_extra_closing_p_in_figure() { $content1 = '
    Caption
    '; $expected1 = $content1; @@ -565,7 +565,7 @@ line 2
    /** * @ticket 14674 */ - function test_the_hr_is_not_peed() { + public function test_the_hr_is_not_peed() { $content = 'paragraph1
    paragraph2'; $expected = "

    paragraph1

    \n
    \n

    paragraph2

    "; @@ -577,7 +577,7 @@ line 2
    * * @ticket 9437 */ - function test_that_wpautop_ignores_inline_svgs() { + public function test_that_wpautop_ignores_inline_svgs() { $content = ' @@ -595,7 +595,7 @@ line 2
    * * @ticket 9437 */ - function test_that_wpautop_ignores_inline_scripts() { + public function test_that_wpautop_ignores_inline_scripts() { $content = '. It should go.'; @@ -48,7 +48,7 @@ class Tests_Formatting_wpTrimWords extends WP_UnitTestCase { $this->assertSame( $trimmed, wp_trim_words( $text ) ); } - function test_doesnt_trim_short_text() { + public function test_doesnt_trim_short_text() { $text = 'This is some short text.'; $this->assertSame( $text, wp_trim_words( $text ) ); } @@ -56,7 +56,7 @@ class Tests_Formatting_wpTrimWords extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_trims_to_20_counted_by_chars() { + public function test_trims_to_20_counted_by_chars() { switch_to_locale( 'ja_JP' ); $expected = substr( $this->long_text, 0, 20 ) . '…'; $actual = wp_trim_words( $this->long_text, 20 ); @@ -67,7 +67,7 @@ class Tests_Formatting_wpTrimWords extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_trims_to_20_counted_by_chars_with_double_width_chars() { + public function test_trims_to_20_counted_by_chars_with_double_width_chars() { switch_to_locale( 'ja_JP' ); $text = str_repeat( 'あ', 100 ); $expected = str_repeat( 'あ', 19 ) . '…'; @@ -79,7 +79,7 @@ class Tests_Formatting_wpTrimWords extends WP_UnitTestCase { /** * @ticket 47867 */ - function test_works_with_non_numeric_num_words() { + public function test_works_with_non_numeric_num_words() { $this->assertSame( '', wp_trim_words( $this->long_text, '', '' ) ); $this->assertSame( '', wp_trim_words( $this->long_text, 'abc', '' ) ); $this->assertSame( '', wp_trim_words( $this->long_text, null, '' ) ); diff --git a/tests/phpunit/tests/formatting/zeroise.php b/tests/phpunit/tests/formatting/zeroise.php index 0f9fd8dad4..c702fc4eb9 100644 --- a/tests/phpunit/tests/formatting/zeroise.php +++ b/tests/phpunit/tests/formatting/zeroise.php @@ -4,11 +4,11 @@ * @group formatting */ class Tests_Formatting_Zeroise extends WP_UnitTestCase { - function test_pads_with_leading_zeroes() { + public function test_pads_with_leading_zeroes() { $this->assertSame( '00005', zeroise( 5, 5 ) ); } - function test_does_nothing_if_input_is_already_longer() { + public function test_does_nothing_if_input_is_already_longer() { $this->assertSame( '5000000', zeroise( 5000000, 2 ) ); } } diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index cdeb2361a8..bcf8525216 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -4,7 +4,7 @@ * @group functions.php */ class Tests_Functions extends WP_UnitTestCase { - function test_wp_parse_args_object() { + public function test_wp_parse_args_object() { $x = new MockClass; $x->_baba = 5; $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase @@ -21,7 +21,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertSame( array(), wp_parse_args( $y ) ); } - function test_wp_parse_args_array() { + public function test_wp_parse_args_array() { // Arrays. $a = array(); $this->assertSame( array(), wp_parse_args( $a ) ); @@ -40,7 +40,7 @@ class Tests_Functions extends WP_UnitTestCase { ); } - function test_wp_parse_args_defaults() { + public function test_wp_parse_args_defaults() { $x = new MockClass; $x->_baba = 5; $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase @@ -66,7 +66,7 @@ class Tests_Functions extends WP_UnitTestCase { ); } - function test_wp_parse_args_other() { + public function test_wp_parse_args_other() { $b = true; wp_parse_str( $b, $s ); $this->assertSame( $s, wp_parse_args( $b ) ); @@ -78,7 +78,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 30753 */ - function test_wp_parse_args_boolean_strings() { + public function test_wp_parse_args_boolean_strings() { $args = wp_parse_args( 'foo=false&bar=true' ); $this->assertIsString( $args['foo'] ); $this->assertIsString( $args['bar'] ); @@ -87,13 +87,13 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 35972 */ - function test_bool_from_yn() { + public function test_bool_from_yn() { $this->assertTrue( bool_from_yn( 'Y' ) ); $this->assertTrue( bool_from_yn( 'y' ) ); $this->assertFalse( bool_from_yn( 'n' ) ); } - function test_path_is_absolute() { + public function test_path_is_absolute() { $absolute_paths = array( '/', '/foo/', @@ -111,7 +111,7 @@ class Tests_Functions extends WP_UnitTestCase { } } - function test_path_is_not_absolute() { + public function test_path_is_not_absolute() { $relative_paths = array( '', '.', @@ -135,11 +135,11 @@ class Tests_Functions extends WP_UnitTestCase { * * @dataProvider data_wp_normalize_path */ - function test_wp_normalize_path( $path, $expected ) { + public function test_wp_normalize_path( $path, $expected ) { $this->assertSame( $expected, wp_normalize_path( $path ) ); } - function data_wp_normalize_path() { + public function data_wp_normalize_path() { return array( // Windows paths. array( 'C:\\www\\path\\', 'C:/www/path/' ), @@ -163,7 +163,7 @@ class Tests_Functions extends WP_UnitTestCase { ); } - function test_wp_unique_filename() { + public function test_wp_unique_filename() { $testdir = DIR_TESTDATA . '/images/'; @@ -207,7 +207,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 42437 */ - function test_unique_filename_with_dimension_like_filename() { + public function test_unique_filename_with_dimension_like_filename() { $testdir = DIR_TESTDATA . '/images/'; add_filter( 'upload_dir', array( $this, 'upload_dir_patch_basedir' ) ); @@ -224,7 +224,7 @@ class Tests_Functions extends WP_UnitTestCase { } // Callback to patch "basedir" when used in `wp_unique_filename()`. - function upload_dir_patch_basedir( $upload_dir ) { + public function upload_dir_patch_basedir( $upload_dir ) { $upload_dir['basedir'] = DIR_TESTDATA . '/images/'; return $upload_dir; } @@ -232,7 +232,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 53668 */ - function test_wp_unique_filename_with_additional_image_extension() { + public function test_wp_unique_filename_with_additional_image_extension() { $testdir = DIR_TESTDATA . '/images/'; add_filter( 'upload_dir', array( $this, 'upload_dir_patch_basedir' ) ); @@ -314,7 +314,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @dataProvider data_is_not_serialized */ - function test_maybe_serialize( $value ) { + public function test_maybe_serialize( $value ) { if ( is_array( $value ) || is_object( $value ) ) { $expected = serialize( $value ); } else { @@ -327,7 +327,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @dataProvider data_is_serialized */ - function test_maybe_serialize_with_double_serialization( $value ) { + public function test_maybe_serialize_with_double_serialization( $value ) { $expected = serialize( $value ); $this->assertSame( $expected, maybe_serialize( $value ) ); @@ -337,7 +337,7 @@ class Tests_Functions extends WP_UnitTestCase { * @dataProvider data_is_serialized * @dataProvider data_is_not_serialized */ - function test_maybe_unserialize( $value, $is_serialized ) { + public function test_maybe_unserialize( $value, $is_serialized ) { if ( $is_serialized ) { $expected = unserialize( trim( $value ) ); } else { @@ -355,14 +355,14 @@ class Tests_Functions extends WP_UnitTestCase { * @dataProvider data_is_serialized * @dataProvider data_is_not_serialized */ - function test_is_serialized( $value, $expected ) { + public function test_is_serialized( $value, $expected ) { $this->assertSame( $expected, is_serialized( $value ) ); } /** * @dataProvider data_serialize_deserialize_objects */ - function test_deserialize_request_utility_filtered_iterator_objects( $value ) { + public function test_deserialize_request_utility_filtered_iterator_objects( $value ) { $serialized = maybe_serialize( $value ); if ( get_class( $value ) === 'Requests_Utility_FilteredIterator' ) { $new_value = unserialize( $serialized ); @@ -375,7 +375,7 @@ class Tests_Functions extends WP_UnitTestCase { } } - function data_serialize_deserialize_objects() { + public function data_serialize_deserialize_objects() { return array( array( new Requests_Utility_FilteredIterator( array( 1 ), 'md5' ) ), array( new Requests_Utility_FilteredIterator( array( 1, 2 ), 'sha1' ) ), @@ -383,7 +383,7 @@ class Tests_Functions extends WP_UnitTestCase { ); } - function data_is_serialized() { + public function data_is_serialized() { return array( array( serialize( null ), true ), array( serialize( true ), true ), @@ -409,7 +409,7 @@ class Tests_Functions extends WP_UnitTestCase { ); } - function data_is_not_serialized() { + public function data_is_not_serialized() { return array( array( null, false ), array( true, false ), @@ -439,11 +439,11 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 46570 * @dataProvider data_is_serialized_should_return_true_for_large_floats */ - function test_is_serialized_should_return_true_for_large_floats( $value ) { + public function test_is_serialized_should_return_true_for_large_floats( $value ) { $this->assertTrue( is_serialized( $value ) ); } - function data_is_serialized_should_return_true_for_large_floats() { + public function data_is_serialized_should_return_true_for_large_floats() { return array( array( serialize( 1.7976931348623157E+308 ) ), array( serialize( array( 1.7976931348623157E+308, 1.23e50 ) ) ), @@ -453,14 +453,14 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 17375 */ - function test_no_new_serializable_types() { + public function test_no_new_serializable_types() { $this->assertFalse( is_serialized( 'C:16:"Serialized_Class":6:{a:0:{}}' ) ); } /** * @group add_query_arg */ - function test_add_query_arg() { + public function test_add_query_arg() { $old_req_uri = $_SERVER['REQUEST_URI']; $urls = array( @@ -648,7 +648,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 31306 */ - function test_add_query_arg_numeric_keys() { + public function test_add_query_arg_numeric_keys() { $url = add_query_arg( array( 'foo' => 'bar' ), '1=1' ); $this->assertSame( '1=1&foo=bar', $url ); @@ -668,7 +668,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 21594 */ - function test_get_allowed_mime_types() { + public function test_get_allowed_mime_types() { $mimes = get_allowed_mime_types(); $this->assertIsArray( $mimes ); @@ -688,7 +688,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 21594 */ - function test_wp_get_mime_types() { + public function test_wp_get_mime_types() { $mimes = wp_get_mime_types(); $this->assertIsArray( $mimes ); @@ -720,7 +720,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 23688 */ - function test_canonical_charset() { + public function test_canonical_charset() { $orig_blog_charset = get_option( 'blog_charset' ); update_option( 'blog_charset', 'utf8' ); @@ -758,11 +758,11 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 43977 * @dataProvider data_wp_parse_list */ - function test_wp_parse_list( $expected, $actual ) { + public function test_wp_parse_list( $expected, $actual ) { $this->assertSame( $expected, array_values( wp_parse_list( $actual ) ) ); } - function data_wp_parse_list() { + public function data_wp_parse_list() { return array( array( array( '1', '2', '3', '4' ), '1,2,3,4' ), array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple,banana,carrot,dog' ), @@ -781,11 +781,11 @@ class Tests_Functions extends WP_UnitTestCase { /** * @dataProvider data_wp_parse_id_list */ - function test_wp_parse_id_list( $expected, $actual ) { + public function test_wp_parse_id_list( $expected, $actual ) { $this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) ); } - function data_wp_parse_id_list() { + public function data_wp_parse_id_list() { return array( array( array( 1, 2, 3, 4 ), '1,2,3,4' ), array( array( 1, 2, 3, 4 ), '1, 2,,3,4' ), @@ -800,11 +800,11 @@ class Tests_Functions extends WP_UnitTestCase { /** * @dataProvider data_wp_parse_slug_list */ - function test_wp_parse_slug_list( $expected, $actual ) { + public function test_wp_parse_slug_list( $expected, $actual ) { $this->assertSame( $expected, array_values( wp_parse_slug_list( $actual ) ) ); } - function data_wp_parse_slug_list() { + public function data_wp_parse_slug_list() { return array( array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple,banana,carrot,dog' ), array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple, banana,,carrot,dog' ), @@ -816,14 +816,14 @@ class Tests_Functions extends WP_UnitTestCase { /** * @dataProvider data_device_can_upload */ - function test_device_can_upload( $user_agent, $expected ) { + public function test_device_can_upload( $user_agent, $expected ) { $_SERVER['HTTP_USER_AGENT'] = $user_agent; $actual = _device_can_upload(); unset( $_SERVER['HTTP_USER_AGENT'] ); $this->assertSame( $expected, $actual ); } - function data_device_can_upload() { + public function data_device_can_upload() { return array( // iPhone iOS 5.0.1, Safari 5.1. array( @@ -876,7 +876,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 9064 */ - function test_wp_extract_urls() { + public function test_wp_extract_urls() { $original_urls = array( 'http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html', 'http://this.com', @@ -1043,14 +1043,14 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 28786 */ - function test_wp_json_encode() { + public function test_wp_json_encode() { $this->assertSame( wp_json_encode( 'a' ), '"a"' ); } /** * @ticket 28786 */ - function test_wp_json_encode_utf8() { + public function test_wp_json_encode_utf8() { $this->assertSame( wp_json_encode( '这' ), '"\u8fd9"' ); } @@ -1058,7 +1058,7 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 28786 * @requires function mb_detect_order */ - function test_wp_json_encode_non_utf8() { + public function test_wp_json_encode_non_utf8() { $charsets = mb_detect_order(); $old_charsets = $charsets; if ( ! in_array( 'EUC-JP', $charsets, true ) ) { @@ -1080,7 +1080,7 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 28786 * @requires function mb_detect_order */ - function test_wp_json_encode_non_utf8_in_array() { + public function test_wp_json_encode_non_utf8_in_array() { $charsets = mb_detect_order(); $old_charsets = $charsets; if ( ! in_array( 'EUC-JP', $charsets, true ) ) { @@ -1101,14 +1101,14 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 28786 */ - function test_wp_json_encode_array() { + public function test_wp_json_encode_array() { $this->assertSame( wp_json_encode( array( 'a' ) ), '["a"]' ); } /** * @ticket 28786 */ - function test_wp_json_encode_object() { + public function test_wp_json_encode_object() { $object = new stdClass; $object->a = 'b'; $this->assertSame( wp_json_encode( $object ), '{"a":"b"}' ); @@ -1117,7 +1117,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 28786 */ - function test_wp_json_encode_depth() { + public function test_wp_json_encode_depth() { $data = array( array( array( 1, 2, 3 ) ) ); $json = wp_json_encode( $data, 0, 1 ); $this->assertFalse( $json ); @@ -1130,7 +1130,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 53238 */ - function test_wp_json_file_decode() { + public function test_wp_json_file_decode() { $result = wp_json_file_decode( DIR_TESTDATA . '/blocks/notice/block.json' ); @@ -1142,7 +1142,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 53238 */ - function test_wp_json_file_decode_associative_array() { + public function test_wp_json_file_decode_associative_array() { $result = wp_json_file_decode( DIR_TESTDATA . '/blocks/notice/block.json', array( 'associative' => true ) @@ -1156,7 +1156,7 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 36054 * @dataProvider datetime_provider */ - function test_mysql_to_rfc3339( $expected, $actual ) { + public function test_mysql_to_rfc3339( $expected, $actual ) { $date_return = mysql_to_rfc3339( $actual ); $this->assertIsString( $date_return, 'The date return must be a string' ); @@ -1165,7 +1165,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertEquals( new DateTime( $expected ), new DateTime( $date_return ), 'The date is not the same after the call method' ); } - function datetime_provider() { + public function datetime_provider() { return array( array( '2016-03-15T18:54:46', '15-03-2016 18:54:46' ), array( '2016-03-02T19:13:25', '2016-03-02 19:13:25' ), @@ -1218,7 +1218,7 @@ class Tests_Functions extends WP_UnitTestCase { * * @ticket 32075 */ - function test_wp_raise_memory_limit() { + public function test_wp_raise_memory_limit() { if ( -1 !== WP_MAX_MEMORY_LIMIT ) { $this->markTestSkipped( 'WP_MAX_MEMORY_LIMIT should be set to -1.' ); } @@ -1238,7 +1238,7 @@ class Tests_Functions extends WP_UnitTestCase { * @covers ::wp_generate_uuid4 * @ticket 38164 */ - function test_wp_generate_uuid4() { + public function test_wp_generate_uuid4() { $uuids = array(); for ( $i = 0; $i < 20; $i += 1 ) { $uuid = wp_generate_uuid4(); @@ -1256,7 +1256,7 @@ class Tests_Functions extends WP_UnitTestCase { * @covers ::wp_is_uuid * @ticket 39778 */ - function test_wp_is_valid_uuid() { + public function test_wp_is_valid_uuid() { $uuids_v4 = array( '27fe2421-780c-44c5-b39b-fff753092b55', 'b7c7713a-4ee9-45a1-87ed-944a90390fc7', @@ -1306,7 +1306,7 @@ class Tests_Functions extends WP_UnitTestCase { * @covers ::wp_unique_id * @ticket 44883 */ - function test_wp_unique_id() { + public function test_wp_unique_id() { // Test without prefix. $ids = array(); @@ -1330,7 +1330,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 40017 - * @dataProvider _wp_get_image_mime + * @dataProvider wp_get_image_mime */ public function test_wp_get_image_mime( $file, $expected ) { if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) { @@ -1365,10 +1365,10 @@ class Tests_Functions extends WP_UnitTestCase { /** * @ticket 39550 - * @dataProvider _wp_check_filetype_and_ext_data + * @dataProvider wp_check_filetype_and_ext_data * @requires extension fileinfo */ - function test_wp_check_filetype_and_ext( $file, $filename, $expected ) { + public function test_wp_check_filetype_and_ext( $file, $filename, $expected ) { $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) ); } @@ -1377,7 +1377,7 @@ class Tests_Functions extends WP_UnitTestCase { * @group ms-excluded * @requires extension fileinfo */ - function test_wp_check_filetype_and_ext_with_filtered_svg() { + public function test_wp_check_filetype_and_ext_with_filtered_svg() { $file = DIR_TESTDATA . '/uploads/video-play.svg'; $filename = 'video-play.svg'; @@ -1387,11 +1387,11 @@ class Tests_Functions extends WP_UnitTestCase { 'proper_filename' => false, ); - add_filter( 'upload_mimes', array( $this, '_filter_mime_types_svg' ) ); + add_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) ); $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) ); // Cleanup. - remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_svg' ) ); + remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) ); } /** @@ -1399,7 +1399,7 @@ class Tests_Functions extends WP_UnitTestCase { * @group ms-excluded * @requires extension fileinfo */ - function test_wp_check_filetype_and_ext_with_filtered_woff() { + public function test_wp_check_filetype_and_ext_with_filtered_woff() { $file = DIR_TESTDATA . '/uploads/dashicons.woff'; $filename = 'dashicons.woff'; @@ -1409,19 +1409,19 @@ class Tests_Functions extends WP_UnitTestCase { 'proper_filename' => false, ); - add_filter( 'upload_mimes', array( $this, '_filter_mime_types_woff' ) ); + add_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) ); $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) ); // Cleanup. - remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_woff' ) ); + remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) ); } - public function _filter_mime_types_svg( $mimes ) { + public function filter_mime_types_svg( $mimes ) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } - public function _filter_mime_types_woff( $mimes ) { + public function filter_mime_types_woff( $mimes ) { $mimes['woff'] = 'application/font-woff'; return $mimes; } @@ -1429,7 +1429,7 @@ class Tests_Functions extends WP_UnitTestCase { /** * Data provider for test_wp_get_image_mime(). */ - public function _wp_get_image_mime() { + public function wp_get_image_mime() { $data = array( // Standard JPEG. array( @@ -1584,7 +1584,7 @@ class Tests_Functions extends WP_UnitTestCase { return $data; } - public function _wp_check_filetype_and_ext_data() { + public function wp_check_filetype_and_ext_data() { $data = array( // Standard image. array( diff --git a/tests/phpunit/tests/functions/addMagicQuotes.php b/tests/phpunit/tests/functions/addMagicQuotes.php index 447a4e3d6d..f42b601e09 100644 --- a/tests/phpunit/tests/functions/addMagicQuotes.php +++ b/tests/phpunit/tests/functions/addMagicQuotes.php @@ -15,7 +15,7 @@ class Tests_Functions_AddMagicQuotes extends WP_UnitTestCase { * @param array $test_array Test value. * @param array $expected Expected return value. */ - function test_add_magic_quotes( $test_array, $expected ) { + public function test_add_magic_quotes( $test_array, $expected ) { $this->assertSame( $expected, add_magic_quotes( $test_array ) ); } diff --git a/tests/phpunit/tests/functions/allowedProtocols.php b/tests/phpunit/tests/functions/allowedProtocols.php index 4ec65afbe7..8484024c86 100644 --- a/tests/phpunit/tests/functions/allowedProtocols.php +++ b/tests/phpunit/tests/functions/allowedProtocols.php @@ -10,11 +10,11 @@ class Tests_Functions_AllowedProtocols extends WP_UnitTestCase { /** * @ticket 19354 */ - function test_data_is_not_an_allowed_protocol() { + public function test_data_is_not_an_allowed_protocol() { $this->assertNotContains( 'data', wp_allowed_protocols() ); } - function test_allowed_protocol_has_an_example() { + public function test_allowed_protocol_has_an_example() { $example_protocols = array(); foreach ( $this->data_example_urls() as $example ) { $example_protocols[] = $example[0]; @@ -29,7 +29,7 @@ class Tests_Functions_AllowedProtocols extends WP_UnitTestCase { * @param string The scheme. * @param string Example URL. */ - function test_allowed_protocols( $protocol, $url ) { + public function test_allowed_protocols( $protocol, $url ) { $this->assertSame( $url, esc_url( $url, $protocol ) ); $this->assertSame( $url, esc_url( $url, wp_allowed_protocols() ) ); } @@ -37,7 +37,7 @@ class Tests_Functions_AllowedProtocols extends WP_UnitTestCase { /** * @link http://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml */ - function data_example_urls() { + public function data_example_urls() { return array( array( 'http', 'http://example.com' ), // RFC7230 array( 'https', 'https://example.com' ), // RFC7230 diff --git a/tests/phpunit/tests/functions/canonicalCharset.php b/tests/phpunit/tests/functions/canonicalCharset.php index 891cb9e767..973562c6a9 100644 --- a/tests/phpunit/tests/functions/canonicalCharset.php +++ b/tests/phpunit/tests/functions/canonicalCharset.php @@ -55,7 +55,7 @@ class Tests_Functions_CanonicalCharset extends WP_UnitTestCase { * * @covers ::get_option */ - function test_update_option_blog_charset() { + public function test_update_option_blog_charset() { $orig_blog_charset = get_option( 'blog_charset' ); update_option( 'blog_charset', 'utf8' ); diff --git a/tests/phpunit/tests/functions/pluginBasename.php b/tests/phpunit/tests/functions/pluginBasename.php index 44be82869b..d28cf914cf 100644 --- a/tests/phpunit/tests/functions/pluginBasename.php +++ b/tests/phpunit/tests/functions/pluginBasename.php @@ -37,7 +37,7 @@ class Tests_Functions_PluginBasename extends WP_UnitTestCase { /** * @ticket 29154 */ - function test_return_correct_basename_for_symlinked_plugins() { + public function test_return_correct_basename_for_symlinked_plugins() { global $wp_plugin_paths; $wp_plugin_paths = array( @@ -51,7 +51,7 @@ class Tests_Functions_PluginBasename extends WP_UnitTestCase { /** * @ticket 28441 */ - function test_return_correct_basename_for_symlinked_plugins_with_path_conflicts() { + public function test_return_correct_basename_for_symlinked_plugins_with_path_conflicts() { global $wp_plugin_paths; $wp_plugin_paths = array( diff --git a/tests/phpunit/tests/functions/wpAuthCheck.php b/tests/phpunit/tests/functions/wpAuthCheck.php index f69ab9e183..70c1780faa 100644 --- a/tests/phpunit/tests/functions/wpAuthCheck.php +++ b/tests/phpunit/tests/functions/wpAuthCheck.php @@ -14,7 +14,7 @@ class Tests_Functions_wpAuthCheck extends WP_UnitTestCase { * * @ticket 41860 */ - function test_wp_auth_check_user_not_logged_in() { + public function test_wp_auth_check_user_not_logged_in() { $expected = array( 'wp-auth-check' => false, ); @@ -28,7 +28,7 @@ class Tests_Functions_wpAuthCheck extends WP_UnitTestCase { * * @ticket 41860 */ - function test_wp_auth_check_user_logged_in() { + public function test_wp_auth_check_user_logged_in() { // Log user in. wp_set_current_user( 1 ); @@ -45,7 +45,7 @@ class Tests_Functions_wpAuthCheck extends WP_UnitTestCase { * * @ticket 41860 */ - function test_wp_auth_check_user_logged_in_login_grace_period_set() { + public function test_wp_auth_check_user_logged_in_login_grace_period_set() { // Log user in. wp_set_current_user( 1 ); diff --git a/tests/phpunit/tests/functions/wpGetArchives.php b/tests/phpunit/tests/functions/wpGetArchives.php index 1f51d33725..6d0eaded28 100644 --- a/tests/phpunit/tests/functions/wpGetArchives.php +++ b/tests/phpunit/tests/functions/wpGetArchives.php @@ -9,7 +9,7 @@ class Tests_Functions_wpGetArchives extends WP_UnitTestCase { protected $month_url; protected $year_url; - function set_up() { + public function set_up() { parent::set_up(); $this->month_url = get_month_link( gmdate( 'Y' ), gmdate( 'm' ) ); @@ -26,12 +26,12 @@ class Tests_Functions_wpGetArchives extends WP_UnitTestCase { ); } - function test_wp_get_archives_default() { + public function test_wp_get_archives_default() { $expected['default'] = "
  • " . gmdate( 'F Y' ) . '
  • '; $this->assertSame( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) ); } - function test_wp_get_archives_type() { + public function test_wp_get_archives_type() { $expected['type'] = "
  • " . gmdate( 'Y' ) . '
  • '; $this->assertSame( $expected['type'], @@ -46,7 +46,7 @@ class Tests_Functions_wpGetArchives extends WP_UnitTestCase { ); } - function test_wp_get_archives_limit() { + public function test_wp_get_archives_limit() { $ids = array_slice( array_reverse( self::$post_ids ), 0, 5 ); $link1 = get_permalink( $ids[0] ); @@ -82,7 +82,7 @@ EOF; ); } - function test_wp_get_archives_format() { + public function test_wp_get_archives_format() { $expected['format'] = "'; $this->assertSame( $expected['format'], @@ -97,7 +97,7 @@ EOF; ); } - function test_wp_get_archives_before_and_after() { + public function test_wp_get_archives_before_and_after() { $expected['before_and_after'] = "'; $this->assertSame( $expected['before_and_after'], @@ -114,7 +114,7 @@ EOF; ); } - function test_wp_get_archives_show_post_count() { + public function test_wp_get_archives_show_post_count() { $expected['show_post_count'] = "
  • " . gmdate( 'F Y' ) . ' (8)
  • '; $this->assertSame( $expected['show_post_count'], @@ -129,13 +129,13 @@ EOF; ); } - function test_wp_get_archives_echo() { + public function test_wp_get_archives_echo() { $expected['echo'] = "\t
  • " . gmdate( 'F Y' ) . '
  • ' . "\n"; $this->expectOutputString( $expected['echo'] ); wp_get_archives( array( 'echo' => true ) ); } - function test_wp_get_archives_order() { + public function test_wp_get_archives_order() { self::factory()->post->create( array( 'post_type' => 'post', @@ -182,7 +182,7 @@ EOF; /** * @ticket 21596 */ - function test_wp_get_archives_post_type() { + public function test_wp_get_archives_post_type() { register_post_type( 'taco', array( 'public' => true ) ); self::factory()->post->create( diff --git a/tests/phpunit/tests/functions/wpValidateBoolean.php b/tests/phpunit/tests/functions/wpValidateBoolean.php index 3bc2c20108..785d1bc986 100644 --- a/tests/phpunit/tests/functions/wpValidateBoolean.php +++ b/tests/phpunit/tests/functions/wpValidateBoolean.php @@ -12,7 +12,7 @@ class Tests_Functions_wpValidateBoolean extends WP_UnitTestCase { * * @return array */ - function data_provider() { + public function data_provider() { $std = new \stdClass(); return array( diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index df9a43a31f..516afa25b9 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -9,13 +9,13 @@ class Tests_General_PaginateLinks extends WP_UnitTestCase { private $i18n_count = 0; - function set_up() { + public function set_up() { parent::set_up(); $this->go_to( home_url( '/' ) ); } - function test_defaults() { + public function test_defaults() { $page2 = get_pagenum_link( 2 ); $page3 = get_pagenum_link( 3 ); $page50 = get_pagenum_link( 50 ); @@ -33,7 +33,7 @@ EXPECTED; $this->assertSameIgnoreEOL( $expected, $links ); } - function test_format() { + public function test_format() { $page2 = home_url( '/page/2/' ); $page3 = home_url( '/page/3/' ); $page50 = home_url( '/page/50/' ); @@ -56,7 +56,7 @@ EXPECTED; $this->assertSameIgnoreEOL( $expected, $links ); } - function test_prev_next_false() { + public function test_prev_next_false() { $home = home_url( '/' ); $page3 = get_pagenum_link( 3 ); $page4 = get_pagenum_link( 4 ); @@ -81,7 +81,7 @@ EXPECTED; $this->assertSameIgnoreEOL( $expected, $links ); } - function test_prev_next_true() { + public function test_prev_next_true() { $home = home_url( '/' ); $page3 = get_pagenum_link( 3 ); $page4 = get_pagenum_link( 4 ); @@ -108,14 +108,14 @@ EXPECTED; $this->assertSameIgnoreEOL( $expected, $links ); } - function increment_i18n_count() { + public function increment_i18n_count() { $this->i18n_count += 1; } /** * @ticket 25735 */ - function test_paginate_links_number_format() { + public function test_paginate_links_number_format() { $this->i18n_count = 0; add_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) ); paginate_links( @@ -137,7 +137,7 @@ EXPECTED; /** * @ticket 24606 */ - function test_paginate_links_base_value() { + public function test_paginate_links_base_value() { // Current page: 2. $links = paginate_links( @@ -205,7 +205,7 @@ EXPECTED; $this->assertSame( get_pagenum_link( 2 ), $href ); } - function add_query_arg( $url ) { + public function add_query_arg( $url ) { return add_query_arg( array( 'foo' => 'bar', @@ -218,7 +218,7 @@ EXPECTED; /** * @ticket 29636 */ - function test_paginate_links_query_args() { + public function test_paginate_links_query_args() { add_filter( 'get_pagenum_link', array( $this, 'add_query_arg' ) ); $links = paginate_links( array( @@ -256,7 +256,7 @@ EXPECTED; /** * @ticket 30831 */ - function test_paginate_links_with_custom_query_args() { + public function test_paginate_links_with_custom_query_args() { add_filter( 'get_pagenum_link', array( $this, 'add_query_arg' ) ); $links = paginate_links( array( diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index fd788a4cff..ca2e6063a1 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -17,16 +17,16 @@ class Tests_General_Template extends WP_UnitTestCase { public $custom_logo_id; public $custom_logo_url; - function set_up() { + public function set_up() { parent::set_up(); $this->wp_site_icon = new WP_Site_Icon(); } - function tear_down() { + public function tear_down() { global $wp_customize; - $this->_remove_custom_logo(); - $this->_remove_site_icon(); + $this->remove_custom_logo(); + $this->remove_site_icon(); $wp_customize = null; parent::tear_down(); @@ -37,13 +37,13 @@ class Tests_General_Template extends WP_UnitTestCase { * @covers ::get_site_icon_url * @requires function imagejpeg */ - function test_get_site_icon_url() { + public function test_get_site_icon_url() { $this->assertEmpty( get_site_icon_url() ); - $this->_set_site_icon(); + $this->set_site_icon(); $this->assertSame( $this->site_icon_url, get_site_icon_url() ); - $this->_remove_site_icon(); + $this->remove_site_icon(); $this->assertEmpty( get_site_icon_url() ); } @@ -52,11 +52,11 @@ class Tests_General_Template extends WP_UnitTestCase { * @covers ::site_icon_url * @requires function imagejpeg */ - function test_site_icon_url() { + public function test_site_icon_url() { $this->expectOutputString( '' ); site_icon_url(); - $this->_set_site_icon(); + $this->set_site_icon(); $this->expectOutputString( $this->site_icon_url ); site_icon_url(); } @@ -66,13 +66,13 @@ class Tests_General_Template extends WP_UnitTestCase { * @covers ::has_site_icon * @requires function imagejpeg */ - function test_has_site_icon() { + public function test_has_site_icon() { $this->assertFalse( has_site_icon() ); - $this->_set_site_icon(); + $this->set_site_icon(); $this->assertTrue( has_site_icon() ); - $this->_remove_site_icon(); + $this->remove_site_icon(); $this->assertFalse( has_site_icon() ); } @@ -82,10 +82,10 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::has_site_icon */ - function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() { + public function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() { $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); - $this->_set_site_icon(); + $this->set_site_icon(); restore_current_blog(); $this->assertTrue( has_site_icon( $blog_id ) ); @@ -97,7 +97,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::has_site_icon */ - function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() { + public function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() { $blog_id = $this->factory->blog->create(); $this->assertFalse( has_site_icon( $blog_id ) ); @@ -108,11 +108,11 @@ class Tests_General_Template extends WP_UnitTestCase { * @covers ::wp_site_icon * @requires function imagejpeg */ - function test_wp_site_icon() { + public function test_wp_site_icon() { $this->expectOutputString( '' ); wp_site_icon(); - $this->_set_site_icon(); + $this->set_site_icon(); $output = array( sprintf( '', esc_url( get_site_icon_url( 32 ) ) ), sprintf( '', esc_url( get_site_icon_url( 192 ) ) ), @@ -131,11 +131,11 @@ class Tests_General_Template extends WP_UnitTestCase { * @covers ::wp_site_icon * @requires function imagejpeg */ - function test_wp_site_icon_with_filter() { + public function test_wp_site_icon_with_filter() { $this->expectOutputString( '' ); wp_site_icon(); - $this->_set_site_icon(); + $this->set_site_icon(); $output = array( sprintf( '', esc_url( get_site_icon_url( 32 ) ) ), sprintf( '', esc_url( get_site_icon_url( 192 ) ) ), @@ -147,9 +147,9 @@ class Tests_General_Template extends WP_UnitTestCase { $output = implode( "\n", $output ); $this->expectOutputString( $output ); - add_filter( 'site_icon_meta_tags', array( $this, '_custom_site_icon_meta_tag' ) ); + add_filter( 'site_icon_meta_tags', array( $this, 'custom_site_icon_meta_tag' ) ); wp_site_icon(); - remove_filter( 'site_icon_meta_tags', array( $this, '_custom_site_icon_meta_tag' ) ); + remove_filter( 'site_icon_meta_tags', array( $this, 'custom_site_icon_meta_tag' ) ); } /** @@ -157,7 +157,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group site_icon * @covers ::wp_site_icon */ - function test_customize_preview_wp_site_icon_empty() { + public function test_customize_preview_wp_site_icon_empty() { global $wp_customize; wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); @@ -175,7 +175,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group site_icon * @covers ::wp_site_icon */ - function test_customize_preview_wp_site_icon_dirty() { + public function test_customize_preview_wp_site_icon_dirty() { global $wp_customize; wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); @@ -184,7 +184,7 @@ class Tests_General_Template extends WP_UnitTestCase { $wp_customize->register_controls(); $wp_customize->start_previewing_theme(); - $attachment_id = $this->_insert_attachment(); + $attachment_id = $this->insert_attachment(); $wp_customize->set_post_value( 'site_icon', $attachment_id ); $wp_customize->get_setting( 'site_icon' )->preview(); $output = array( @@ -207,7 +207,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @param $meta_tags * @return array */ - function _custom_site_icon_meta_tag( $meta_tags ) { + public function custom_site_icon_meta_tag( $meta_tags ) { $meta_tags[] = sprintf( '', esc_url( get_site_icon_url( 150 ) ) ); return $meta_tags; @@ -218,10 +218,10 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.3.0 */ - function _set_site_icon() { + private function set_site_icon() { if ( ! $this->site_icon_id ) { add_filter( 'intermediate_image_sizes_advanced', array( $this->wp_site_icon, 'additional_sizes' ) ); - $this->_insert_attachment(); + $this->insert_attachment(); remove_filter( 'intermediate_image_sizes_advanced', array( $this->wp_site_icon, 'additional_sizes' ) ); } @@ -233,7 +233,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.3.0 */ - function _remove_site_icon() { + private function remove_site_icon() { delete_option( 'site_icon' ); } @@ -242,7 +242,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.3.0 */ - function _insert_attachment() { + private function insert_attachment() { $filename = DIR_TESTDATA . '/images/test-image.jpg'; $contents = file_get_contents( $filename ); @@ -260,13 +260,13 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.5.0 */ - function test_has_custom_logo() { + public function test_has_custom_logo() { $this->assertFalse( has_custom_logo() ); - $this->_set_custom_logo(); + $this->set_custom_logo(); $this->assertTrue( has_custom_logo() ); - $this->_remove_custom_logo(); + $this->remove_custom_logo(); $this->assertFalse( has_custom_logo() ); } @@ -276,10 +276,10 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::has_custom_logo */ - function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() { + public function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() { $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); - $this->_set_custom_logo(); + $this->set_custom_logo(); restore_current_blog(); $this->assertTrue( has_custom_logo( $blog_id ) ); @@ -291,7 +291,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::has_custom_logo */ - function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() { + public function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() { $blog_id = $this->factory->blog->create(); $this->assertFalse( has_custom_logo( $blog_id ) ); @@ -303,15 +303,15 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.5.0 */ - function test_get_custom_logo() { + public function test_get_custom_logo() { $this->assertEmpty( get_custom_logo() ); - $this->_set_custom_logo(); + $this->set_custom_logo(); $custom_logo = get_custom_logo(); $this->assertNotEmpty( $custom_logo ); $this->assertIsString( $custom_logo ); - $this->_remove_custom_logo(); + $this->remove_custom_logo(); $this->assertEmpty( get_custom_logo() ); } @@ -321,11 +321,11 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::get_custom_logo */ - function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() { + public function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() { $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); - $this->_set_custom_logo(); + $this->set_custom_logo(); $custom_logo_attr = array( 'class' => 'custom-logo', @@ -352,11 +352,11 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.5.0 */ - function test_the_custom_logo() { + public function test_the_custom_logo() { $this->expectOutputString( '' ); the_custom_logo(); - $this->_set_custom_logo(); + $this->set_custom_logo(); $custom_logo_attr = array( 'class' => 'custom-logo', @@ -380,8 +380,8 @@ class Tests_General_Template extends WP_UnitTestCase { * @group custom_logo * @covers ::the_custom_logo */ - function test_the_custom_logo_with_alt() { - $this->_set_custom_logo(); + public function test_the_custom_logo_with_alt() { + $this->set_custom_logo(); $image_alt = 'My alt attribute'; @@ -406,9 +406,9 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.5.0 */ - function _set_custom_logo() { + private function set_custom_logo() { if ( ! $this->custom_logo_id ) { - $this->_insert_custom_logo(); + $this->insert_custom_logo(); } set_theme_mod( 'custom_logo', $this->custom_logo_id ); @@ -419,7 +419,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.5.0 */ - function _remove_custom_logo() { + private function remove_custom_logo() { remove_theme_mod( 'custom_logo' ); } @@ -428,7 +428,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @since 4.5.0 */ - function _insert_custom_logo() { + private function insert_custom_logo() { $filename = DIR_TESTDATA . '/images/test-image.jpg'; $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); @@ -444,7 +444,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::get_site_icon_url */ - function test_get_site_icon_url_preserves_switched_state() { + public function test_get_site_icon_url_preserves_switched_state() { $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); @@ -464,7 +464,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::has_custom_logo */ - function test_has_custom_logo_preserves_switched_state() { + public function test_has_custom_logo_preserves_switched_state() { $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); @@ -484,7 +484,7 @@ class Tests_General_Template extends WP_UnitTestCase { * @group ms-required * @covers ::get_custom_logo */ - function test_get_custom_logo_preserves_switched_state() { + public function test_get_custom_logo_preserves_switched_state() { $blog_id = $this->factory->blog->create(); switch_to_blog( $blog_id ); @@ -504,7 +504,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_header */ - function test_get_header_returns_nothing_on_success() { + public function test_get_header_returns_nothing_on_success() { $this->expectOutputRegex( '/Header/' ); // The `get_header()` function must not return anything @@ -517,7 +517,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_footer */ - function test_get_footer_returns_nothing_on_success() { + public function test_get_footer_returns_nothing_on_success() { $this->expectOutputRegex( '/Footer/' ); // The `get_footer()` function must not return anything @@ -530,7 +530,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_sidebar */ - function test_get_sidebar_returns_nothing_on_success() { + public function test_get_sidebar_returns_nothing_on_success() { $this->expectOutputRegex( '/Sidebar/' ); // The `get_sidebar()` function must not return anything @@ -543,7 +543,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_template_part */ - function test_get_template_part_returns_nothing_on_success() { + public function test_get_template_part_returns_nothing_on_success() { $this->expectOutputRegex( '/Template Part/' ); // The `get_template_part()` function must not return anything @@ -556,7 +556,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_template_part */ - function test_get_template_part_returns_false_on_failure() { + public function test_get_template_part_returns_false_on_failure() { $this->assertFalse( get_template_part( 'non-existing-template' ) ); } @@ -565,7 +565,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_template_part */ - function test_get_template_part_passes_arguments_to_template() { + public function test_get_template_part_passes_arguments_to_template() { $this->expectOutputRegex( '/{"foo":"baz"}/' ); get_template_part( 'template', 'part', array( 'foo' => 'baz' ) ); @@ -576,7 +576,7 @@ class Tests_General_Template extends WP_UnitTestCase { * * @covers ::get_the_archive_title */ - function test_get_the_archive_title_is_correct_for_author_queries() { + public function test_get_the_archive_title_is_correct_for_author_queries() { $user_with_posts = $this->factory()->user->create_and_get( array( 'role' => 'author', diff --git a/tests/phpunit/tests/general/wpGetArchives.php b/tests/phpunit/tests/general/wpGetArchives.php index 28fdabaa69..5409795fd7 100644 --- a/tests/phpunit/tests/general/wpGetArchives.php +++ b/tests/phpunit/tests/general/wpGetArchives.php @@ -6,7 +6,7 @@ * @covers ::wp_get_archives */ class Tests_General_wpGetArchives extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); wp_cache_delete( 'last_changed', 'posts' ); @@ -15,7 +15,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { /** * @ticket 23206 */ - function test_get_archives_cache() { + public function test_get_archives_cache() { global $wpdb; self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) ); diff --git a/tests/phpunit/tests/general/wpGetDocumentTitle.php b/tests/phpunit/tests/general/wpGetDocumentTitle.php index 07e9ffa43b..08d9e033f3 100644 --- a/tests/phpunit/tests/general/wpGetDocumentTitle.php +++ b/tests/phpunit/tests/general/wpGetDocumentTitle.php @@ -43,28 +43,28 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { ); } - function set_up() { + public function set_up() { parent::set_up(); - add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) ); + add_action( 'after_setup_theme', array( $this, 'add_title_tag_support' ) ); $this->blog_name = get_option( 'blogname' ); setup_postdata( get_post( self::$post_id ) ); } - function _add_title_tag_support() { + public function add_title_tag_support() { add_theme_support( 'title-tag' ); } - function test__wp_render_title_tag() { + public function test__wp_render_title_tag() { $this->go_to( '/' ); $this->expectOutputString( sprintf( "%s – %s\n", $this->blog_name, get_option( 'blogdescription' ) ) ); _wp_render_title_tag(); } - function test__wp_render_title_no_theme_support() { + public function test__wp_render_title_no_theme_support() { $this->go_to( '/' ); remove_theme_support( 'title-tag' ); @@ -73,19 +73,19 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { _wp_render_title_tag(); } - function test_short_circuiting_title() { + public function test_short_circuiting_title() { $this->go_to( '/' ); - add_filter( 'pre_get_document_title', array( $this, '_short_circuit_title' ) ); + add_filter( 'pre_get_document_title', array( $this, 'short_circuit_title' ) ); $this->assertSame( 'A Wild Title', wp_get_document_title() ); } - function _short_circuit_title( $title ) { + public function short_circuit_title( $title ) { return 'A Wild Title'; } - function test_front_page_title() { + public function test_front_page_title() { update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', @@ -96,7 +96,7 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { ) ) ); - add_filter( 'document_title_parts', array( $this, '_front_page_title_parts' ) ); + add_filter( 'document_title_parts', array( $this, 'front_page_title_parts' ) ); $this->go_to( '/' ); $this->assertSame( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); @@ -107,7 +107,7 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { $this->assertSame( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); } - function _front_page_title_parts( $parts ) { + public function front_page_title_parts( $parts ) { $this->assertArrayHasKey( 'title', $parts ); $this->assertArrayHasKey( 'tagline', $parts ); $this->assertArrayNotHasKey( 'site', $parts ); @@ -115,7 +115,7 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { return $parts; } - function test_home_title() { + public function test_home_title() { $blog_page_id = $this->factory->post->create( array( 'post_title' => 'blog-page', @@ -130,15 +130,15 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { $this->assertSame( sprintf( 'blog-page – %s', $this->blog_name ), wp_get_document_title() ); } - function test_paged_title() { + public function test_paged_title() { $this->go_to( '?page=4' ); - add_filter( 'document_title_parts', array( $this, '_paged_title_parts' ) ); + add_filter( 'document_title_parts', array( $this, 'paged_title_parts' ) ); $this->assertSame( sprintf( '%s – Page 4 – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); } - function _paged_title_parts( $parts ) { + public function paged_title_parts( $parts ) { $this->assertArrayHasKey( 'page', $parts ); $this->assertArrayHasKey( 'title', $parts ); $this->assertArrayHasKey( 'tagline', $parts ); @@ -147,15 +147,15 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { return $parts; } - function test_singular_title() { + public function test_singular_title() { $this->go_to( '?p=' . self::$post_id ); - add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) ); + add_filter( 'document_title_parts', array( $this, 'singular_title_parts' ) ); $this->assertSame( sprintf( 'test_title – %s', $this->blog_name ), wp_get_document_title() ); } - function _singular_title_parts( $parts ) { + public function singular_title_parts( $parts ) { $this->assertArrayHasKey( 'site', $parts ); $this->assertArrayHasKey( 'title', $parts ); $this->assertArrayNotHasKey( 'tagline', $parts ); @@ -163,25 +163,25 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { return $parts; } - function test_category_title() { + public function test_category_title() { $this->go_to( '?cat=' . self::$category_id ); $this->assertSame( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() ); } - function test_search_title() { + public function test_search_title() { $this->go_to( '?s=test_title' ); $this->assertSame( sprintf( 'Search Results for “test_title” – %s', $this->blog_name ), wp_get_document_title() ); } - function test_author_title() { + public function test_author_title() { $this->go_to( '?author=' . self::$author_id ); $this->assertSame( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() ); } - function test_post_type_archive_title() { + public function test_post_type_archive_title() { register_post_type( 'cpt', array( @@ -204,39 +204,39 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { $this->assertSame( sprintf( 'test_cpt – %s', $this->blog_name ), wp_get_document_title() ); } - function test_year_title() { + public function test_year_title() { $this->go_to( '?year=2015' ); $this->assertSame( sprintf( '2015 – %s', $this->blog_name ), wp_get_document_title() ); } - function test_month_title() { + public function test_month_title() { $this->go_to( '?monthnum=09' ); $this->assertSame( sprintf( 'September 2015 – %s', $this->blog_name ), wp_get_document_title() ); } - function test_day_title() { + public function test_day_title() { $this->go_to( '?day=22' ); $this->assertSame( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() ); } - function test_404_title() { + public function test_404_title() { $this->go_to( '?m=404' ); $this->assertSame( sprintf( 'Page not found – %s', $this->blog_name ), wp_get_document_title() ); } - function test_paged_post_title() { + public function test_paged_post_title() { $this->go_to( '?paged=4&p=' . self::$post_id ); - add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) ); + add_filter( 'title_tag_parts', array( $this, 'paged_post_title_parts' ) ); $this->assertSame( sprintf( 'test_title – Page 4 – %s', $this->blog_name ), wp_get_document_title() ); } - function _paged_post_title_parts( $parts ) { + public function paged_post_title_parts( $parts ) { $this->assertArrayHasKey( 'page', $parts ); $this->assertArrayHasKey( 'site', $parts ); $this->assertArrayHasKey( 'title', $parts ); @@ -245,15 +245,15 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { return $parts; } - function test_rearrange_title_parts() { + public function test_rearrange_title_parts() { $this->go_to( '?p=' . self::$post_id ); - add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) ); + add_filter( 'document_title_parts', array( $this, 'rearrange_title_parts' ) ); $this->assertSame( sprintf( '%s – test_title', $this->blog_name ), wp_get_document_title() ); } - function _rearrange_title_parts( $parts ) { + public function rearrange_title_parts( $parts ) { $parts = array( $parts['site'], $parts['title'], @@ -262,15 +262,15 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase { return $parts; } - function test_change_title_separator() { + public function test_change_title_separator() { $this->go_to( '?p=' . self::$post_id ); - add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) ); + add_filter( 'document_title_separator', array( $this, 'change_title_separator' ) ); $this->assertSame( sprintf( 'test_title %%%% %s', $this->blog_name ), wp_get_document_title() ); } - function _change_title_separator( $sep ) { + public function change_title_separator( $sep ) { return '%%'; } } diff --git a/tests/phpunit/tests/general/wpResourceHints.php b/tests/phpunit/tests/general/wpResourceHints.php index d23ed3dbaf..1761196b2c 100644 --- a/tests/phpunit/tests/general/wpResourceHints.php +++ b/tests/phpunit/tests/general/wpResourceHints.php @@ -10,7 +10,7 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { private $old_wp_scripts; private $old_wp_styles; - function set_up() { + public function set_up() { parent::set_up(); $this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null; $this->old_wp_styles = isset( $GLOBALS['wp_styles'] ) ? $GLOBALS['wp_styles'] : null; @@ -24,13 +24,13 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { $GLOBALS['wp_styles']->default_version = get_bloginfo( 'version' ); } - function tear_down() { + public function tear_down() { $GLOBALS['wp_scripts'] = $this->old_wp_scripts; $GLOBALS['wp_styles'] = $this->old_wp_styles; parent::tear_down(); } - function test_should_have_defaults_on_frontend() { + public function test_should_have_defaults_on_frontend() { $expected = "\n"; $this->expectOutputString( $expected ); @@ -38,22 +38,22 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { wp_resource_hints(); } - function test_dns_prefetching() { + public function test_dns_prefetching() { $expected = "\n" . "\n" . "\n" . "\n"; - add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_dns_prefetch_domains' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_dns_prefetch_domains' ) ); $this->assertSame( $expected, $actual ); } - function _add_dns_prefetch_domains( $hints, $method ) { + public function add_dns_prefetch_domains( $hints, $method ) { if ( 'dns-prefetch' === $method ) { $hints[] = 'http://wordpress.org'; $hints[] = 'https://wordpress.org'; @@ -69,23 +69,23 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { /** * @ticket 37652 */ - function test_preconnect() { + public function test_preconnect() { $expected = "\n" . "\n" . "\n" . "\n" . "\n"; - add_filter( 'wp_resource_hints', array( $this, '_add_preconnect_domains' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_preconnect_domains' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_preconnect_domains' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_preconnect_domains' ) ); $this->assertSame( $expected, $actual ); } - function _add_preconnect_domains( $hints, $method ) { + public function add_preconnect_domains( $hints, $method ) { if ( 'preconnect' === $method ) { $hints[] = '//wordpress.org'; $hints[] = 'https://make.wordpress.org'; @@ -97,22 +97,22 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { return $hints; } - function test_prerender() { + public function test_prerender() { $expected = "\n" . "\n" . "\n" . "\n"; - add_filter( 'wp_resource_hints', array( $this, '_add_prerender_urls' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_prerender_urls' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_prerender_urls' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_prerender_urls' ) ); $this->assertSame( $expected, $actual ); } - function _add_prerender_urls( $hints, $method ) { + public function add_prerender_urls( $hints, $method ) { if ( 'prerender' === $method ) { $hints[] = 'https://make.wordpress.org/great-again'; $hints[] = 'http://jobs.wordpress.net'; @@ -123,20 +123,20 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { return $hints; } - function test_parse_url_dns_prefetch() { + public function test_parse_url_dns_prefetch() { $expected = "\n" . "\n"; - add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_dns_prefetch_long_urls' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_dns_prefetch_long_urls' ) ); $this->assertSame( $expected, $actual ); } - function _add_dns_prefetch_long_urls( $hints, $method ) { + public function add_dns_prefetch_long_urls( $hints, $method ) { if ( 'dns-prefetch' === $method ) { $hints[] = 'http://make.wordpress.org/wp-includes/css/editor.css'; } @@ -144,7 +144,7 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { return $hints; } - function test_dns_prefetch_styles() { + public function test_dns_prefetch_styles() { $expected = "\n" . "\n"; @@ -163,7 +163,7 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { } - function test_dns_prefetch_scripts() { + public function test_dns_prefetch_scripts() { $expected = "\n" . "\n"; @@ -184,7 +184,7 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { /** * @ticket 37385 */ - function test_dns_prefetch_scripts_does_not_include_registered_only() { + public function test_dns_prefetch_scripts_does_not_include_registered_only() { $expected = "\n"; $unexpected = "\n"; @@ -201,7 +201,7 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { /** * @ticket 37502 */ - function test_deregistered_scripts_are_ignored() { + public function test_deregistered_scripts_are_ignored() { $expected = "\n"; wp_enqueue_script( 'test-script', 'http://example.org/script.js' ); @@ -214,23 +214,23 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { /** * @ticket 37652 */ - function test_malformed_urls() { + public function test_malformed_urls() { $expected = "\n"; // Errant colon. - add_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_errant_colon' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_malformed_url_errant_colon' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_errant_colon' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_malformed_url_errant_colon' ) ); $this->assertSame( $expected, $actual ); // Unsupported Scheme. - add_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_unsupported_scheme' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_malformed_url_unsupported_scheme' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_unsupported_scheme' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_malformed_url_unsupported_scheme' ) ); $this->assertSame( $expected, $actual ); } - function _add_malformed_url_errant_colon( $hints, $method ) { + public function add_malformed_url_errant_colon( $hints, $method ) { if ( 'preconnect' === $method ) { $hints[] = '://core.trac.wordpress.org/ticket/37652'; } @@ -238,7 +238,7 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { return $hints; } - function _add_malformed_url_unsupported_scheme( $hints, $method ) { + public function add_malformed_url_unsupported_scheme( $hints, $method ) { if ( 'preconnect' === $method ) { $hints[] = 'git://develop.git.wordpress.org/'; } @@ -249,23 +249,23 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase { /** * @ticket 38121 */ - function test_custom_attributes() { + public function test_custom_attributes() { $expected = "\n" . "\n" . "\n" . "\n" . "\n"; - add_filter( 'wp_resource_hints', array( $this, '_add_url_with_attributes' ), 10, 2 ); + add_filter( 'wp_resource_hints', array( $this, 'add_url_with_attributes' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); - remove_filter( 'wp_resource_hints', array( $this, '_add_url_with_attributes' ) ); + remove_filter( 'wp_resource_hints', array( $this, 'add_url_with_attributes' ) ); $this->assertSame( $expected, $actual ); } - function _add_url_with_attributes( $hints, $method ) { + public function add_url_with_attributes( $hints, $method ) { // Ignore hints with missing href attributes. $hints[] = array( 'rel' => 'foo', diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index 32be98339b..ee42056bb3 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -17,7 +17,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { protected $http_request_args; - function set_up() { + public function set_up() { parent::set_up(); $class = 'WP_Http_' . ucfirst( $this->transport ); @@ -34,7 +34,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { } } - function filter_http_request_args( array $args ) { + public function filter_http_request_args( array $args ) { $this->http_request_args = $args; return $args; } @@ -42,7 +42,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_redirect_on_301() { + public function test_redirect_on_301() { // 5 : 5 & 301. $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) ); @@ -54,7 +54,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_redirect_on_302() { + public function test_redirect_on_302() { // 5 : 5 & 302. $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) ); @@ -68,7 +68,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_redirect_on_301_no_redirect() { + public function test_redirect_on_301_no_redirect() { // 5 > 0 & 301. $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) ); @@ -82,7 +82,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_redirect_on_302_no_redirect() { + public function test_redirect_on_302_no_redirect() { // 5 > 0 & 302. $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); @@ -94,7 +94,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_redirections_equal() { + public function test_redirections_equal() { // 5 - 5. $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) ); @@ -106,7 +106,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_no_head_redirections() { + public function test_no_head_redirections() { // No redirections on HEAD request. $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) ); @@ -120,7 +120,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_redirect_on_head() { + public function test_redirect_on_head() { // Redirections on HEAD request when Requested. $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, @@ -138,7 +138,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_redirections_greater() { + public function test_redirections_greater() { // 10 > 5. $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) ); @@ -149,7 +149,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_redirections_greater_edgecase() { + public function test_redirections_greater_edgecase() { // 6 > 5 (close edge case). $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) ); @@ -160,7 +160,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_redirections_less_edgecase() { + public function test_redirections_less_edgecase() { // 4 < 5 (close edge case). $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) ); @@ -173,7 +173,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_redirections_zero_redirections_specified() { + public function test_redirections_zero_redirections_specified() { // 0 redirections asked for, should return the document? $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); @@ -189,7 +189,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_location_header_on_201() { + public function test_location_header_on_201() { // Prints PASS on initial load, FAIL if the client follows the specified redirection. $res = wp_remote_request( $this->redirection_script . '?201-location=true' ); @@ -206,7 +206,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * @covers ::wp_remote_request * @covers ::wp_remote_retrieve_body */ - function test_no_redirection_on_PUT() { + public function test_no_redirection_on_PUT() { $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?201-location=1'; // Test 301 - POST to POST. @@ -228,7 +228,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_send_headers() { + public function test_send_headers() { // Test that the headers sent are received by the server. $headers = array( 'test1' => 'test', @@ -263,7 +263,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { /** * @covers ::wp_remote_request */ - function test_file_stream() { + public function test_file_stream() { $url = $this->file_stream_url; $size = 153204; $res = wp_remote_request( @@ -293,7 +293,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_file_stream_limited_size() { + public function test_file_stream_limited_size() { $url = $this->file_stream_url; $size = 10000; $res = wp_remote_request( @@ -324,7 +324,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_request_limited_size() { + public function test_request_limited_size() { $url = $this->file_stream_url; $size = 10000; @@ -351,7 +351,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * @covers ::wp_remote_post * @covers ::wp_remote_retrieve_body */ - function test_post_redirect_to_method_300( $response_code, $method ) { + public function test_post_redirect_to_method_300( $response_code, $method ) { $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1'; $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); @@ -393,7 +393,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * @covers ::wp_remote_get * @covers ::wp_remote_retrieve_body */ - function test_ip_url_with_host_header() { + public function test_ip_url_with_host_header() { $ip = gethostbyname( 'api.wordpress.org' ); $url = 'http://' . $ip . '/core/tests/1.0/redirection.php?print-pass=1'; $args = array( @@ -418,7 +418,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_head */ - function test_https_url_without_ssl_verification() { + public function test_https_url_without_ssl_verification() { $url = 'https://wordpress.org/'; $args = array( 'sslverify' => false, @@ -445,7 +445,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * @covers ::wp_remote_get * @covers ::wp_remote_retrieve_body */ - function test_multiple_location_headers() { + public function test_multiple_location_headers() { $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1'; $res = wp_remote_head( $url, array( 'timeout' => 30 ) ); @@ -468,7 +468,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * @covers ::wp_remote_get * @covers ::wp_remote_retrieve_body */ - function test_cookie_handling() { + public function test_cookie_handling() { $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=1'; $res = wp_remote_get( $url ); @@ -485,7 +485,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_get */ - function test_ssl() { + public function test_ssl() { if ( ! wp_http_supports( array( 'ssl' ) ) ) { $this->fail( 'This installation of PHP does not support SSL.' ); } @@ -501,7 +501,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { * * @covers ::wp_remote_request */ - function test_url_with_double_slashes_path() { + public function test_url_with_double_slashes_path() { $url = $this->redirection_script . '?rt=' . 0; $path = parse_url( $url, PHP_URL_PATH ); diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index c31803dead..43ec8fd12c 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -9,7 +9,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { /** * @covers ::wp_remote_head */ - function test_head_request() { + public function test_head_request() { // This URL gives a direct 200 response. $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_head( $url ); @@ -28,7 +28,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { /** * @covers ::wp_remote_head */ - function test_head_redirect() { + public function test_head_redirect() { // This URL will 301 redirect. $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_head( $url ); @@ -40,7 +40,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { /** * @covers ::wp_remote_head */ - function test_head_404() { + public function test_head_404() { $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; $response = wp_remote_head( $url ); @@ -53,7 +53,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_headers * @covers ::wp_remote_retrieve_response_code */ - function test_get_request() { + public function test_get_request() { $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_get( $url ); @@ -75,7 +75,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_headers * @covers ::wp_remote_retrieve_response_code */ - function test_get_redirect() { + public function test_get_redirect() { // This will redirect to asdftestblog1.files.wordpress.com. $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; @@ -94,7 +94,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { /** * @covers ::wp_remote_get */ - function test_get_redirect_limit_exceeded() { + public function test_get_redirect_limit_exceeded() { // This will redirect to asdftestblog1.files.wordpress.com. $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; @@ -113,7 +113,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_cookie * @covers ::wp_remote_retrieve_cookie_value */ - function test_get_response_cookies() { + public function test_get_response_cookies() { $url = 'https://login.wordpress.org/wp-login.php'; $response = wp_remote_head( $url ); @@ -146,7 +146,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_cookies * @covers ::wp_remote_retrieve_cookie */ - function test_get_response_cookies_with_wp_http_cookie_object() { + public function test_get_response_cookies_with_wp_http_cookie_object() { $url = 'http://example.org'; $response = wp_remote_get( @@ -182,7 +182,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_cookies * @covers ::wp_remote_retrieve_cookie */ - function test_get_response_cookies_with_name_value_array() { + public function test_get_response_cookies_with_name_value_array() { $url = 'http://example.org'; $response = wp_remote_get( @@ -214,7 +214,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { * @covers ::wp_remote_retrieve_cookie * @covers WP_Http */ - function test_get_cookie_host_only() { + public function test_get_cookie_host_only() { // Emulate WP_Http::request() internals. $requests_response = new Requests_Response(); diff --git a/tests/phpunit/tests/http/http.php b/tests/phpunit/tests/http/http.php index 1ece726d04..c22c87d55c 100644 --- a/tests/phpunit/tests/http/http.php +++ b/tests/phpunit/tests/http/http.php @@ -13,12 +13,12 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { * * @covers WP_Http::make_absolute_url */ - function test_make_absolute_url( $relative_url, $absolute_url, $expected ) { + public function test_make_absolute_url( $relative_url, $absolute_url, $expected ) { $actual = WP_Http::make_absolute_url( $relative_url, $absolute_url ); $this->assertSame( $expected, $actual ); } - function make_absolute_url_testcases() { + public function make_absolute_url_testcases() { // 0: The Location header, 1: The current URL, 3: The expected URL. return array( // Absolute URL provided. @@ -74,12 +74,12 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { * * @covers ::wp_parse_url */ - function test_wp_parse_url( $url, $expected ) { + public function test_wp_parse_url( $url, $expected ) { $actual = wp_parse_url( $url ); $this->assertSame( $expected, $actual ); } - function parse_url_testcases() { + public function parse_url_testcases() { // 0: The URL, 1: The expected resulting structure. return array( array( @@ -187,7 +187,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { * * @covers ::wp_parse_url */ - function test_wp_parse_url_with_default_component() { + public function test_wp_parse_url_with_default_component() { $actual = wp_parse_url( self::FULL_TEST_URL, -1 ); $this->assertSame( array( @@ -211,12 +211,12 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { * * @covers ::wp_parse_url */ - function test_wp_parse_url_with_component( $url, $component, $expected ) { + public function test_wp_parse_url_with_component( $url, $component, $expected ) { $actual = wp_parse_url( $url, $component ); $this->assertSame( $expected, $actual ); } - function parse_url_component_testcases() { + public function parse_url_component_testcases() { // 0: The URL, 1: The requested component, 2: The expected resulting structure. return array( array( self::FULL_TEST_URL, PHP_URL_SCHEME, 'http' ), @@ -328,13 +328,13 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { * @covers ::wp_parse_url * @covers ::_get_component_from_parsed_url_array */ - function test_get_component_from_parsed_url_array( $url, $component, $expected ) { + public function test_get_component_from_parsed_url_array( $url, $component, $expected ) { $parts = wp_parse_url( $url ); $actual = _get_component_from_parsed_url_array( $parts, $component ); $this->assertSame( $expected, $actual ); } - function get_component_from_parsed_url_array_testcases() { + public function get_component_from_parsed_url_array_testcases() { // 0: A URL, 1: PHP URL constant, 2: The expected result. return array( array( @@ -369,12 +369,12 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { * * @covers ::_wp_translate_php_url_constant_to_key */ - function test_wp_translate_php_url_constant_to_key( $input, $expected ) { + public function test_wp_translate_php_url_constant_to_key( $input, $expected ) { $actual = _wp_translate_php_url_constant_to_key( $input ); $this->assertSame( $expected, $actual ); } - function wp_translate_php_url_constant_to_key_testcases() { + public function wp_translate_php_url_constant_to_key_testcases() { // 0: PHP URL constant, 1: The expected result. return array( array( PHP_URL_SCHEME, 'scheme' ), diff --git a/tests/phpunit/tests/http/wpRemoteRetrieveHeaders.php b/tests/phpunit/tests/http/wpRemoteRetrieveHeaders.php index 75165dc6a0..9d4390ae54 100644 --- a/tests/phpunit/tests/http/wpRemoteRetrieveHeaders.php +++ b/tests/phpunit/tests/http/wpRemoteRetrieveHeaders.php @@ -9,7 +9,7 @@ class Tests_HTTP_wpRemoteRetrieveHeaders extends WP_UnitTestCase { /** * Valid response */ - function test_remote_retrieve_headers_valid_response() { + public function test_remote_retrieve_headers_valid_response() { $headers = 'headers_data'; $response = array( 'headers' => $headers ); @@ -20,7 +20,7 @@ class Tests_HTTP_wpRemoteRetrieveHeaders extends WP_UnitTestCase { /** * Response is a WP_Error */ - function test_remote_retrieve_headers_is_error() { + public function test_remote_retrieve_headers_is_error() { $response = new WP_Error( 'Some error' ); $result = wp_remote_retrieve_headers( $response ); @@ -30,7 +30,7 @@ class Tests_HTTP_wpRemoteRetrieveHeaders extends WP_UnitTestCase { /** * Response does not contain 'headers' */ - function test_remote_retrieve_headers_invalid_response() { + public function test_remote_retrieve_headers_invalid_response() { $response = array( 'no_headers' => 'set' ); $result = wp_remote_retrieve_headers( $response ); diff --git a/tests/phpunit/tests/image/dimensions.php b/tests/phpunit/tests/image/dimensions.php index bbab2d3b39..5820f64ae7 100644 --- a/tests/phpunit/tests/image/dimensions.php +++ b/tests/phpunit/tests/image/dimensions.php @@ -6,7 +6,7 @@ * @group upload */ class Tests_Image_Dimensions extends WP_UnitTestCase { - function test_400x400_no_crop() { + public function test_400x400_no_crop() { // Landscape: resize 640x480 to fit 400x400: 400x300. $out = image_resize_dimensions( 640, 480, 400, 400, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -18,7 +18,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); } - function test_400x0_no_crop() { + public function test_400x0_no_crop() { // Landscape: resize 640x480 to fit 400w: 400x300. $out = image_resize_dimensions( 640, 480, 400, 0, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -30,7 +30,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); } - function test_0x400_no_crop() { + public function test_0x400_no_crop() { // Landscape: resize 640x480 to fit 400h: 533x400. $out = image_resize_dimensions( 640, 480, 0, 400, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -42,7 +42,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); } - function test_800x800_no_crop() { + public function test_800x800_no_crop() { // Landscape: resize 640x480 to fit 800x800. $out = image_resize_dimensions( 640, 480, 800, 800, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -54,7 +54,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertFalse( $out ); } - function test_800x0_no_crop() { + public function test_800x0_no_crop() { // Landscape: resize 640x480 to fit 800w. $out = image_resize_dimensions( 640, 480, 800, 0, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -66,7 +66,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertFalse( $out ); } - function test_0x800_no_crop() { + public function test_0x800_no_crop() { // Landscape: resize 640x480 to fit 800h. $out = image_resize_dimensions( 640, 480, 0, 800, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -80,7 +80,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { // Cropped versions. - function test_400x400_crop() { + public function test_400x400_crop() { // Landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0). $out = image_resize_dimensions( 640, 480, 400, 400, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -92,7 +92,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out ); } - function test_400x0_crop() { + public function test_400x0_crop() { // Landscape: resize 640x480 to fit 400w: 400x300. $out = image_resize_dimensions( 640, 480, 400, 0, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -104,7 +104,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); } - function test_0x400_crop() { + public function test_0x400_crop() { // Landscape: resize 640x480 to fit 400h: 533x400. $out = image_resize_dimensions( 640, 480, 0, 400, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -116,7 +116,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); } - function test_400x500_crop() { + public function test_400x500_crop() { // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0). $out = image_resize_dimensions( 640, 480, 400, 500, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. @@ -128,7 +128,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { $this->assertSame( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out ); } - function test_640x480() { + public function test_640x480() { // Crop 640x480 to fit 640x480 (no change). $out = image_resize_dimensions( 640, 480, 640, 480, true ); $this->assertFalse( $out ); @@ -156,7 +156,7 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { /** * @ticket 19393 */ - function test_crop_anchors() { + public function test_crop_anchors() { // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop. // src_x = 0 (left), src_y = 0 (top). $out = image_resize_dimensions( 640, 480, 400, 500, array( 'left', 'top' ) ); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index b90c9f25f7..488731a0e8 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -45,7 +45,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { return $mime_type; } - function test_is_image_positive() { + public function test_is_image_positive() { // These are all image files recognized by PHP. $files = array( 'test-image-cmyk.jpg', @@ -75,7 +75,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { } } - function test_is_image_negative() { + public function test_is_image_negative() { // These are actually image files but aren't recognized or usable by PHP. $files = array( 'test-image.pct', @@ -88,7 +88,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { } } - function test_is_displayable_image_positive() { + public function test_is_displayable_image_positive() { // These are all usable in typical web browsers. $files = array( 'test-image.gif', @@ -122,7 +122,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { } } - function test_is_displayable_image_negative() { + public function test_is_displayable_image_negative() { // These are image files but aren't suitable for web pages because of compatibility or size issues. $files = array( // 'test-image-cmyk.jpg', Allowed in r9727. @@ -147,7 +147,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { /** * @ticket 50833 */ - function test_is_gd_image_invalid_types() { + public function test_is_gd_image_invalid_types() { $this->assertFalse( is_gd_image( new stdClass() ) ); $this->assertFalse( is_gd_image( array() ) ); $this->assertFalse( is_gd_image( null ) ); @@ -161,7 +161,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { * @ticket 50833 * @requires extension gd */ - function test_is_gd_image_valid_types() { + public function test_is_gd_image_valid_types() { $this->assertTrue( is_gd_image( imagecreate( 5, 5 ) ) ); } @@ -426,7 +426,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->assertInstanceOf( 'WP_Error', $file ); } - function mock_image_editor( $editors ) { + public function mock_image_editor( $editors ) { return array( 'WP_Image_Editor_Mock' ); } @@ -638,7 +638,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { } } - function filter_fallback_intermediate_image_sizes( $fallback_sizes, $metadata ) { + public function filter_fallback_intermediate_image_sizes( $fallback_sizes, $metadata ) { // Add the 'test-size' to the list of fallback sizes. $fallback_sizes[] = 'test-size'; diff --git a/tests/phpunit/tests/image/header.php b/tests/phpunit/tests/image/header.php index 87dd50bce6..6b480a953c 100644 --- a/tests/phpunit/tests/image/header.php +++ b/tests/phpunit/tests/image/header.php @@ -8,12 +8,12 @@ require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php'; class Tests_Image_Header extends WP_UnitTestCase { public $custom_image_header; - function set_up() { + public function set_up() { parent::set_up(); $this->custom_image_header = new Custom_Image_Header( '__return_null' ); } - function test_header_image_has_correct_dimensions_with_max_width() { + public function test_header_image_has_correct_dimensions_with_max_width() { global $_wp_theme_features; $_wp_theme_features['custom-header'][0]['max-width'] = 1600; @@ -33,7 +33,7 @@ class Tests_Image_Header extends WP_UnitTestCase { } - function test_header_image_has_correct_dimensions_with_fixed() { + public function test_header_image_has_correct_dimensions_with_fixed() { global $_wp_theme_features; unset( $_wp_theme_features['custom-header'][0]['max-width'] ); @@ -53,7 +53,7 @@ class Tests_Image_Header extends WP_UnitTestCase { } - function test_header_image_has_correct_dimensions_with_flex_height() { + public function test_header_image_has_correct_dimensions_with_flex_height() { global $_wp_theme_features; unset( $_wp_theme_features['custom-header'][0]['max-width'] ); @@ -73,7 +73,7 @@ class Tests_Image_Header extends WP_UnitTestCase { } - function test_header_image_has_correct_dimensions_with_flex_width() { + public function test_header_image_has_correct_dimensions_with_flex_width() { global $_wp_theme_features; unset( $_wp_theme_features['custom-header'][0]['max-width'] ); @@ -93,7 +93,7 @@ class Tests_Image_Header extends WP_UnitTestCase { } - function test_header_image_has_correct_dimensions_with_flex_width_and_height() { + public function test_header_image_has_correct_dimensions_with_flex_width_and_height() { global $_wp_theme_features; $_wp_theme_features['custom-header'][0]['max-width'] = 1800; @@ -113,7 +113,7 @@ class Tests_Image_Header extends WP_UnitTestCase { } - function test_create_attachment_object() { + public function test_create_attachment_object() { $id = wp_insert_attachment( array( 'post_status' => 'publish', @@ -132,7 +132,7 @@ class Tests_Image_Header extends WP_UnitTestCase { $this->assertSame( 'image/jpeg', $object['post_mime_type'] ); } - function test_insert_cropped_attachment() { + public function test_insert_cropped_attachment() { $id = wp_insert_attachment( array( 'post_status' => 'publish', @@ -154,7 +154,7 @@ class Tests_Image_Header extends WP_UnitTestCase { /** * @ticket 21819 */ - function test_check_get_previous_crop() { + public function test_check_get_previous_crop() { $id = wp_insert_attachment( array( 'post_status' => 'publish', diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index cf5b3888fe..b67e795163 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -5,7 +5,7 @@ * @group upload */ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { - function tear_down() { + public function tear_down() { $this->remove_added_uploads(); remove_image_size( 'test-size' ); @@ -22,7 +22,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { return parent::_make_attachment( $upload, $parent_post_id ); } - function test_make_intermediate_size_no_size() { + public function test_make_intermediate_size_no_size() { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 0, false ); $this->assertFalse( $image ); @@ -31,7 +31,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @requires function imagejpeg */ - function test_make_intermediate_size_width() { + public function test_make_intermediate_size_width() { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false ); $this->assertIsArray( $image ); @@ -40,7 +40,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @requires function imagejpeg */ - function test_make_intermediate_size_height() { + public function test_make_intermediate_size_height() { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false ); $this->assertIsArray( $image ); @@ -49,7 +49,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @requires function imagejpeg */ - function test_make_intermediate_size_successful() { + public function test_make_intermediate_size_successful() { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true ); unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' ); @@ -66,7 +66,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 52867 * @requires function imagejpeg */ - function test_image_editor_output_format_filter() { + public function test_image_editor_output_format_filter() { add_filter( 'image_editor_output_format', static function() { @@ -92,7 +92,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 17626 * @requires function imagejpeg */ - function test_get_intermediate_sizes_by_name() { + public function test_get_intermediate_sizes_by_name() { add_image_size( 'test-size', 330, 220, true ); $file = DIR_TESTDATA . '/images/waffles.jpg'; @@ -113,7 +113,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 17626 * @requires function imagejpeg */ - function test_get_intermediate_sizes_by_array_exact() { + public function test_get_intermediate_sizes_by_array_exact() { // Only one dimention match shouldn't return false positive (see: #17626). add_image_size( 'test-size', 330, 220, true ); add_image_size( 'false-height', 330, 400, true ); @@ -135,7 +135,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 17626 * @requires function imagejpeg */ - function test_get_intermediate_sizes_by_array_nearest() { + public function test_get_intermediate_sizes_by_array_nearest() { // If an exact size is not found, it should be returned. // If not, find nearest size that is larger (see: #17626). add_image_size( 'test-size', 450, 300, true ); @@ -158,7 +158,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 17626 * @requires function imagejpeg */ - function test_get_intermediate_sizes_by_array_nearest_false() { + public function test_get_intermediate_sizes_by_array_nearest_false() { // If an exact size is not found, it should be returned. // If not, find nearest size that is larger, otherwise return false (see: #17626). add_image_size( 'false-height', 330, 100, true ); @@ -180,7 +180,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 17626 * @requires function imagejpeg */ - function test_get_intermediate_sizes_by_array_zero_height() { + public function test_get_intermediate_sizes_by_array_zero_height() { // Generate random width. $random_w = rand( 300, 400 ); @@ -209,7 +209,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @ticket 34087 * @requires function imagejpeg */ - function test_get_intermediate_sizes_by_array_zero_width() { + public function test_get_intermediate_sizes_by_array_zero_width() { // 202 is the smallest height that will trigger a miss for 'false-height'. $height = 202; diff --git a/tests/phpunit/tests/image/meta.php b/tests/phpunit/tests/image/meta.php index a54120967b..39e68b33c3 100644 --- a/tests/phpunit/tests/image/meta.php +++ b/tests/phpunit/tests/image/meta.php @@ -28,7 +28,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { stream_wrapper_unregister( 'testimagemeta' ); } - function test_exif_d70() { + public function test_exif_d70() { // Exif from a Nikon D70. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0008.jpg' ); @@ -44,7 +44,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { $this->assertSame( '', $out['title'] ); } - function test_exif_d70_mf() { + public function test_exif_d70_mf() { // Exif from a Nikon D70 - manual focus lens, so some data is unavailable. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG' ); @@ -61,7 +61,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { // $this->assertSame( array( 'Flowers' ), $out['keywords'] ); } - function test_exif_d70_iptc() { + public function test_exif_d70_iptc() { // Exif from a Nikon D70 with IPTC data added later. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0007.jpg' ); @@ -77,7 +77,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { $this->assertSame( 'IPTC Headline', $out['title'] ); } - function test_exif_fuji() { + public function test_exif_fuji() { // Exif from a Fuji FinePix S5600 (thanks Mark). $out = wp_read_image_metadata( DIR_TESTDATA . '/images/a2-small.jpg' ); @@ -97,7 +97,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { /** * @ticket 6571 */ - function test_exif_error() { + public function test_exif_error() { // https://core.trac.wordpress.org/ticket/6571 // This triggers a warning mesage when reading the Exif block. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/waffles.jpg' ); @@ -114,7 +114,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { $this->assertSame( '', $out['title'] ); } - function test_exif_no_data() { + public function test_exif_no_data() { // No Exif data in this image (from burningwell.org). $out = wp_read_image_metadata( DIR_TESTDATA . '/images/canola.jpg' ); @@ -133,7 +133,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { /** * @ticket 9417 */ - function test_utf8_iptc_tags() { + public function test_utf8_iptc_tags() { // Trilingual UTF-8 text in the ITPC caption-abstract field. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/test-image-iptc.jpg' ); diff --git a/tests/phpunit/tests/image/resize.php b/tests/phpunit/tests/image/resize.php index 1261600875..12cf8eb7ad 100644 --- a/tests/phpunit/tests/image/resize.php +++ b/tests/phpunit/tests/image/resize.php @@ -20,7 +20,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase return array( $this->editor_engine ); } - function test_resize_jpg() { + public function test_resize_jpg() { $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 ); $this->assertSame( 'test-image-25x25.jpg', wp_basename( $image ) ); @@ -32,7 +32,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_png() { + public function test_resize_png() { $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.png', 25, 25 ); if ( ! is_string( $image ) ) { // WP_Error, stop GLib-GObject-CRITICAL assertion. @@ -48,7 +48,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_gif() { + public function test_resize_gif() { $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.gif', 25, 25 ); if ( ! is_string( $image ) ) { // WP_Error, stop GLib-GObject-CRITICAL assertion. @@ -64,7 +64,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_webp() { + public function test_resize_webp() { $file = DIR_TESTDATA . '/images/test-image.webp'; $editor = wp_get_image_editor( $file ); @@ -82,7 +82,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_larger() { + public function test_resize_larger() { // image_resize() should refuse to make an image larger. $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 100, 100 ); @@ -90,7 +90,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase $this->assertSame( 'error_getting_dimensions', $image->get_error_code() ); } - function test_resize_thumb_128x96() { + public function test_resize_thumb_128x96() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 ); $this->assertSame( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) ); @@ -102,7 +102,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_thumb_128x0() { + public function test_resize_thumb_128x0() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 ); $this->assertSame( '2007-06-17DSC_4173-128x193.jpg', wp_basename( $image ) ); @@ -114,7 +114,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_thumb_0x96() { + public function test_resize_thumb_0x96() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 ); $this->assertSame( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) ); @@ -126,7 +126,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_thumb_150x150_crop() { + public function test_resize_thumb_150x150_crop() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true ); $this->assertSame( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $image ) ); @@ -138,7 +138,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_thumb_150x100_crop() { + public function test_resize_thumb_150x100_crop() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true ); $this->assertSame( '2007-06-17DSC_4173-150x100.jpg', wp_basename( $image ) ); @@ -150,7 +150,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase unlink( $image ); } - function test_resize_thumb_50x150_crop() { + public function test_resize_thumb_50x150_crop() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true ); $this->assertSame( '2007-06-17DSC_4173-50x150.jpg', wp_basename( $image ) ); diff --git a/tests/phpunit/tests/image/siteIcon.php b/tests/phpunit/tests/image/siteIcon.php index 1123b06bb3..369aed06f9 100644 --- a/tests/phpunit/tests/image/siteIcon.php +++ b/tests/phpunit/tests/image/siteIcon.php @@ -12,23 +12,23 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { public $attachment_id = 0; - function set_up() { + public function set_up() { parent::set_up(); $this->wp_site_icon = new WP_Site_Icon(); } - function tear_down() { - $this->_remove_custom_logo(); + public function tear_down() { + $this->remove_custom_logo(); $this->remove_added_uploads(); parent::tear_down(); } - function _remove_custom_logo() { + private function remove_custom_logo() { remove_theme_mod( 'custom_logo' ); } - function test_intermediate_image_sizes() { + public function test_intermediate_image_sizes() { $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() ); $sizes = array(); @@ -39,8 +39,8 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $this->assertSame( $sizes, $image_sizes ); } - function test_intermediate_image_sizes_with_filter() { - add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); + public function test_intermediate_image_sizes_with_filter() { + add_filter( 'site_icon_image_sizes', array( $this, 'custom_test_sizes' ) ); $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() ); $sizes = array(); @@ -57,10 +57,10 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { // Remove custom size. unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] ); // Remove the filter we added. - remove_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); + remove_filter( 'site_icon_image_sizes', array( $this, 'custom_test_sizes' ) ); } - function test_additional_sizes() { + public function test_additional_sizes() { $image_sizes = $this->wp_site_icon->additional_sizes( array() ); $sizes = array(); @@ -75,8 +75,8 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $this->assertSame( $sizes, $image_sizes ); } - function test_additional_sizes_with_filter() { - add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); + public function test_additional_sizes_with_filter() { + add_filter( 'site_icon_image_sizes', array( $this, 'custom_test_sizes' ) ); $image_sizes = $this->wp_site_icon->additional_sizes( array() ); $sizes = array(); @@ -98,8 +98,8 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] ); } - function test_create_attachment_object() { - $attachment_id = $this->_insert_attachment(); + public function test_create_attachment_object() { + $attachment_id = $this->insert_attachment(); $parent_url = get_post( $attachment_id )->guid; $cropped = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url ); @@ -112,8 +112,8 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $this->assertSame( $object['guid'], $cropped ); } - function test_insert_cropped_attachment() { - $attachment_id = $this->_insert_attachment(); + public function test_insert_cropped_attachment() { + $attachment_id = $this->insert_attachment(); $parent_url = get_post( $attachment_id )->guid; $cropped = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url ); @@ -124,8 +124,8 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $this->assertGreaterThan( 0, $cropped_id ); } - function test_delete_attachment_data() { - $attachment_id = $this->_insert_attachment(); + public function test_delete_attachment_data() { + $attachment_id = $this->insert_attachment(); update_option( 'site_icon', $attachment_id ); wp_delete_attachment( $attachment_id, true ); @@ -136,8 +136,8 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { /** * @ticket 34368 */ - function test_get_post_metadata() { - $attachment_id = $this->_insert_attachment(); + public function test_get_post_metadata() { + $attachment_id = $this->insert_attachment(); update_option( 'site_icon', $attachment_id ); $this->wp_site_icon->get_post_metadata( '', $attachment_id, '_some_post_meta', true ); @@ -149,13 +149,13 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { wp_delete_attachment( $attachment_id, true ); } - function _custom_test_sizes( $sizes ) { + public function custom_test_sizes( $sizes ) { $sizes[] = 321; return $sizes; } - function _insert_attachment() { + private function insert_attachment() { if ( $this->attachment_id ) { return $this->attachment_id; } diff --git a/tests/phpunit/tests/image/size.php b/tests/phpunit/tests/image/size.php index 0466cd066f..60819b41b5 100644 --- a/tests/phpunit/tests/image/size.php +++ b/tests/phpunit/tests/image/size.php @@ -7,7 +7,7 @@ */ class Tests_Image_Size extends WP_UnitTestCase { - function test_constrain_dims_zero() { + public function test_constrain_dims_zero() { // No constraint - should have no effect. $out = wp_constrain_dimensions( 640, 480, 0, 0 ); $this->assertSame( array( 640, 480 ), $out ); @@ -22,7 +22,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertSame( array( 118, 177 ), $out ); } - function test_constrain_dims_smaller() { + public function test_constrain_dims_smaller() { // Image size is smaller than the constraint - no effect. $out = wp_constrain_dimensions( 500, 600, 1024, 768 ); $this->assertSame( array( 500, 600 ), $out ); @@ -34,7 +34,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertSame( array( 500, 600 ), $out ); } - function test_constrain_dims_equal() { + public function test_constrain_dims_equal() { // Image size is equal to the constraint - no effect. $out = wp_constrain_dimensions( 1024, 768, 1024, 768 ); $this->assertSame( array( 1024, 768 ), $out ); @@ -46,7 +46,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertSame( array( 1024, 768 ), $out ); } - function test_constrain_dims_larger() { + public function test_constrain_dims_larger() { // Image size is larger than the constraint - result should be constrained. $out = wp_constrain_dimensions( 1024, 768, 500, 600 ); $this->assertSame( array( 500, 375 ), $out ); @@ -68,7 +68,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertSame( array( 200, 533 ), $out ); } - function test_constrain_dims_boundary() { + public function test_constrain_dims_boundary() { // One dimension is larger than the constraint, one smaller - result should be constrained. $out = wp_constrain_dimensions( 1024, 768, 500, 800 ); $this->assertSame( array( 500, 375 ), $out ); @@ -87,7 +87,7 @@ class Tests_Image_Size extends WP_UnitTestCase { /** * @expectedDeprecated wp_shrink_dimensions */ - function test_shrink_dimensions_default() { + public function test_shrink_dimensions_default() { $out = wp_shrink_dimensions( 640, 480 ); $this->assertSame( array( 128, 96 ), $out ); @@ -98,7 +98,7 @@ class Tests_Image_Size extends WP_UnitTestCase { /** * @expectedDeprecated wp_shrink_dimensions */ - function test_shrink_dimensions_smaller() { + public function test_shrink_dimensions_smaller() { // Image size is smaller than the constraint - no effect. $out = wp_shrink_dimensions( 500, 600, 1024, 768 ); $this->assertSame( array( 500, 600 ), $out ); @@ -110,7 +110,7 @@ class Tests_Image_Size extends WP_UnitTestCase { /** * @expectedDeprecated wp_shrink_dimensions */ - function test_shrink_dimensions_equal() { + public function test_shrink_dimensions_equal() { // Image size is equal to the constraint - no effect. $out = wp_shrink_dimensions( 500, 600, 500, 600 ); $this->assertSame( array( 500, 600 ), $out ); @@ -122,7 +122,7 @@ class Tests_Image_Size extends WP_UnitTestCase { /** * @expectedDeprecated wp_shrink_dimensions */ - function test_shrink_dimensions_larger() { + public function test_shrink_dimensions_larger() { // Image size is larger than the constraint - result should be constrained. $out = wp_shrink_dimensions( 1024, 768, 500, 600 ); $this->assertSame( array( 500, 375 ), $out ); @@ -134,7 +134,7 @@ class Tests_Image_Size extends WP_UnitTestCase { /** * @expectedDeprecated wp_shrink_dimensions */ - function test_shrink_dimensions_boundary() { + public function test_shrink_dimensions_boundary() { // One dimension is larger than the constraint, one smaller - result should be constrained. $out = wp_shrink_dimensions( 1024, 768, 500, 800 ); $this->assertSame( array( 500, 375 ), $out ); @@ -150,7 +150,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertSame( array( 525, 700 ), $out ); } - function test_constrain_size_for_editor_thumb() { + public function test_constrain_size_for_editor_thumb() { $out = image_constrain_size_for_editor( 600, 400, 'thumb' ); $this->assertSame( array( 150, 100 ), $out ); @@ -158,7 +158,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $this->assertSame( array( 64, 64 ), $out ); } - function test_constrain_size_for_editor_medium() { + public function test_constrain_size_for_editor_medium() { // Default max width is 500, no constraint on height. global $content_width; @@ -185,7 +185,7 @@ class Tests_Image_Size extends WP_UnitTestCase { $content_width = $_content_width; } - function test_constrain_size_for_editor_full() { + public function test_constrain_size_for_editor_full() { global $content_width; $_content_width = $content_width; diff --git a/tests/phpunit/tests/import/import.php b/tests/phpunit/tests/import/import.php index a5ebcfe137..1053b01dbb 100644 --- a/tests/phpunit/tests/import/import.php +++ b/tests/phpunit/tests/import/import.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/base.php'; * @group import */ class Tests_Import_Import extends WP_Import_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); if ( ! defined( 'WP_IMPORTING' ) ) { @@ -33,7 +33,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { } } - function test_small_import() { + public function test_small_import() { global $wpdb; $authors = array( @@ -201,7 +201,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertCount( 1, $cats ); } - function test_double_import() { + public function test_double_import() { $authors = array( 'admin' => false, 'editor' => false, @@ -242,7 +242,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 1, $comment_count->total_comments ); } - function test_ordering_of_importers() { + public function test_ordering_of_importers() { global $wp_importers; $_wp_importers = $wp_importers; // Preserve global state. $wp_importers = array( diff --git a/tests/phpunit/tests/import/parser.php b/tests/phpunit/tests/import/parser.php index 72f76fb2d2..40ed789ac6 100644 --- a/tests/phpunit/tests/import/parser.php +++ b/tests/phpunit/tests/import/parser.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/base.php'; * @group import */ class Tests_Import_Parser extends WP_Import_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); if ( ! defined( 'WP_IMPORTING' ) ) { @@ -24,7 +24,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php'; } - function test_malformed_wxr() { + public function test_malformed_wxr() { $file = DIR_TESTDATA . '/export/malformed.xml'; // Regex based parser cannot detect malformed XML. @@ -36,7 +36,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { } } - function test_invalid_wxr() { + public function test_invalid_wxr() { $f1 = DIR_TESTDATA . '/export/missing-version-tag.xml'; $f2 = DIR_TESTDATA . '/export/invalid-version-tag.xml'; @@ -50,7 +50,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { } } - function test_wxr_version_1_1() { + public function test_wxr_version_1_1() { $file = DIR_TESTDATA . '/export/valid-wxr-1.1.xml'; foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { @@ -143,7 +143,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { } } - function test_wxr_version_1_0() { + public function test_wxr_version_1_0() { $file = DIR_TESTDATA . '/export/valid-wxr-1.0.xml'; foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { @@ -237,7 +237,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { * * @link https://core.trac.wordpress.org/ticket/15203 */ - function test_escaped_cdata_closing_sequence() { + public function test_escaped_cdata_closing_sequence() { $file = DIR_TESTDATA . '/export/crazy-cdata-escaped.xml'; foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { @@ -270,7 +270,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { * Ensure that the regex parser can still parse invalid CDATA blocks (i.e. those * with "]]>" unescaped within a CDATA section). */ - function test_unescaped_cdata_closing_sequence() { + public function test_unescaped_cdata_closing_sequence() { $file = DIR_TESTDATA . '/export/crazy-cdata.xml'; $parser = new WXR_Parser_Regex; diff --git a/tests/phpunit/tests/import/postmeta.php b/tests/phpunit/tests/import/postmeta.php index f50d96f511..0abd7f0a9d 100644 --- a/tests/phpunit/tests/import/postmeta.php +++ b/tests/phpunit/tests/import/postmeta.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/base.php'; * @group import */ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); if ( ! defined( 'WP_IMPORTING' ) ) { @@ -24,14 +24,14 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php'; } - function test_serialized_postmeta_no_cdata() { + public function test_serialized_postmeta_no_cdata() { $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-no-cdata.xml', array( 'johncoswell' => 'john' ) ); $expected['special_post_title'] = 'A special title'; $expected['is_calendar'] = ''; $this->assertSame( $expected, get_post_meta( 122, 'post-options', true ) ); } - function test_utw_postmeta() { + public function test_utw_postmeta() { $this->_import_wp( DIR_TESTDATA . '/export/test-utw-post-meta-import.xml', array( 'johncoswell' => 'john' ) ); $classy = new StdClass(); @@ -80,7 +80,7 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { /** * @ticket 9633 */ - function test_serialized_postmeta_with_cdata() { + public function test_serialized_postmeta_with_cdata() { $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) ); // HTML in the CDATA should work with old WordPress version. @@ -94,7 +94,7 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { /** * @ticket 11574 */ - function test_serialized_postmeta_with_evil_stuff_in_cdata() { + public function test_serialized_postmeta_with_evil_stuff_in_cdata() { $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) ); // Evil content in the CDATA. $this->assertSame( 'evil', get_post_meta( 10, 'evil', true ) ); diff --git a/tests/phpunit/tests/includes/factory.php b/tests/phpunit/tests/includes/factory.php index 62e9aedd86..c1ab1c2a0d 100644 --- a/tests/phpunit/tests/includes/factory.php +++ b/tests/phpunit/tests/includes/factory.php @@ -1,28 +1,28 @@ category_factory = new WP_UnitTest_Factory_For_Term( null, 'category' ); } - function test_create_creates_a_category() { + public function test_create_creates_a_category() { $id = $this->category_factory->create(); $this->assertTrue( (bool) get_term_by( 'id', $id, 'category' ) ); } - function test_get_object_by_id_gets_an_object() { + public function test_get_object_by_id_gets_an_object() { $id = $this->category_factory->create(); $this->assertTrue( (bool) $this->category_factory->get_object_by_id( $id ) ); } - function test_get_object_by_id_gets_an_object_with_the_same_name() { + public function test_get_object_by_id_gets_an_object_with_the_same_name() { $id = $this->category_factory->create( array( 'name' => 'Boo' ) ); $object = $this->category_factory->get_object_by_id( $id ); $this->assertSame( 'Boo', $object->name ); } - function test_the_taxonomy_argument_overrules_the_factory_taxonomy() { + public function test_the_taxonomy_argument_overrules_the_factory_taxonomy() { $term_factory = new WP_UnitTest_Factory_For_term( null, 'category' ); $id = $term_factory->create( array( 'taxonomy' => 'post_tag' ) ); $term = get_term( $id, 'post_tag' ); diff --git a/tests/phpunit/tests/includes/helpers.php b/tests/phpunit/tests/includes/helpers.php index a2baf75089..74bd8e4afa 100644 --- a/tests/phpunit/tests/includes/helpers.php +++ b/tests/phpunit/tests/includes/helpers.php @@ -7,7 +7,7 @@ class Tests_TestHelpers extends WP_UnitTestCase { /** * @ticket 30522 */ - function data_assertSameSets() { + public function data_assertSameSets() { return array( array( array( 1, 2, 3 ), // Test expected. @@ -51,7 +51,7 @@ class Tests_TestHelpers extends WP_UnitTestCase { * @dataProvider data_assertSameSets * @ticket 30522 */ - function test_assertSameSets( $expected, $actual, $exception ) { + public function test_assertSameSets( $expected, $actual, $exception ) { if ( $exception ) { try { $this->assertSameSets( $expected, $actual ); @@ -68,7 +68,7 @@ class Tests_TestHelpers extends WP_UnitTestCase { /** * @ticket 30522 */ - function data_assertSameSetsWithIndex() { + public function data_assertSameSetsWithIndex() { return array( array( array( 1, 2, 3 ), // Test expected. @@ -207,7 +207,7 @@ class Tests_TestHelpers extends WP_UnitTestCase { * @dataProvider data_assertSameSetsWithIndex * @ticket 30522 */ - function test_assertSameSetsWithIndex( $expected, $actual, $exception ) { + public function test_assertSameSetsWithIndex( $expected, $actual, $exception ) { if ( $exception ) { try { $this->assertSameSetsWithIndex( $expected, $actual ); diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 11434d37e8..7f5bb646d1 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -14,7 +14,7 @@ class Tests_Kses extends WP_UnitTestCase { * @param string $string Test string for kses. * @param string $expect_string Expected result after passing through kses. */ - function test_wp_filter_post_kses_address( $string, $expect_string ) { + public function test_wp_filter_post_kses_address( $string, $expect_string ) { global $allowedposttags; $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); @@ -28,7 +28,7 @@ class Tests_Kses extends WP_UnitTestCase { * @type string $expect_string Expected result after passing through kses. * } */ - function data_wp_filter_post_kses_address() { + public function data_wp_filter_post_kses_address() { $attributes = array( 'class' => 'classname', 'id' => 'id', @@ -63,7 +63,7 @@ class Tests_Kses extends WP_UnitTestCase { * @param string $expect_string Expected result after passing through kses. * @return void */ - function test_wp_filter_post_kses_a( $string, $expect_string ) { + public function test_wp_filter_post_kses_a( $string, $expect_string ) { global $allowedposttags; $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); @@ -77,7 +77,7 @@ class Tests_Kses extends WP_UnitTestCase { * @type string $expect_string Expected result after passing through kses. * } */ - function data_wp_filter_post_kses_a() { + public function data_wp_filter_post_kses_a() { $attributes = array( 'class' => 'classname', 'id' => 'id', @@ -120,7 +120,7 @@ class Tests_Kses extends WP_UnitTestCase { * @param string $context Context to use for parsing source. * @param string $expected Expected output following KSES parsing. */ - function test_wp_kses_video( $source, $context, $expected ) { + public function test_wp_kses_video( $source, $context, $expected ) { $actual = wp_kses( $source, $context ); $this->assertSame( $expected, $actual ); } @@ -134,7 +134,7 @@ class Tests_Kses extends WP_UnitTestCase { * @type string $expected Expected output following KSES parsing. * } */ - function data_wp_kses_video() { + public function data_wp_kses_video() { return array( // Set 0: Valid post object params in post context. array( @@ -171,7 +171,7 @@ class Tests_Kses extends WP_UnitTestCase { * @param string $expect_string Expected result after passing through kses. * @return void */ - function test_wp_filter_post_kses_abbr( $string, $expect_string ) { + public function test_wp_filter_post_kses_abbr( $string, $expect_string ) { global $allowedposttags; $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); @@ -185,7 +185,7 @@ class Tests_Kses extends WP_UnitTestCase { * @type string $expect_string Expected result after passing through kses. * } */ - function data_wp_filter_post_kses_abbr() { + public function data_wp_filter_post_kses_abbr() { $attributes = array( 'class' => 'classname', 'id' => 'id', @@ -204,7 +204,7 @@ class Tests_Kses extends WP_UnitTestCase { return $data; } - function test_feed_links() { + public function test_feed_links() { global $allowedposttags; $content = <<assertSame( $expected, wp_kses( $content, $allowedposttags ) ); } - function test_wp_kses_bad_protocol() { + public function test_wp_kses_bad_protocol() { $bad = array( 'dummy:alert(1)', 'javascript:alert(1)', @@ -474,7 +474,7 @@ EOF; } } - function _wp_kses_allowed_html_filter( $html, $context ) { + public function wp_kses_allowed_html_filter( $html, $context ) { if ( 'post' === $context ) { return array( 'a' => array( 'href' => true ) ); } else { @@ -523,17 +523,17 @@ EOF; $this->assertSame( $custom_tags, wp_kses_allowed_html( $custom_tags ) ); - add_filter( 'wp_kses_allowed_html', array( $this, '_wp_kses_allowed_html_filter' ), 10, 2 ); + add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html_filter' ), 10, 2 ); $this->assertSame( array( 'a' => array( 'href' => true ) ), wp_kses_allowed_html( 'post' ) ); $this->assertSame( array( 'a' => array( 'href' => false ) ), wp_kses_allowed_html( 'data' ) ); - remove_filter( 'wp_kses_allowed_html', array( $this, '_wp_kses_allowed_html_filter' ) ); + remove_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html_filter' ) ); $this->assertSame( $allowedposttags, wp_kses_allowed_html( 'post' ) ); $this->assertSame( $allowedtags, wp_kses_allowed_html( 'data' ) ); } - function test_hyphenated_tag() { + public function test_hyphenated_tag() { $string = 'Alot of hyphens.'; $custom_tags = array( 'hyphenated-tag' => array( @@ -568,13 +568,13 @@ EOF; * @ticket 28506 * @dataProvider data_ctrl_removal */ - function test_ctrl_removal( $input, $output ) { + public function test_ctrl_removal( $input, $output ) { global $allowedposttags; return $this->assertSame( $output, wp_kses( $input, $allowedposttags ) ); } - function data_ctrl_removal() { + public function data_ctrl_removal() { return array( array( "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\X1C\x1D\x1E\x1F", @@ -605,13 +605,13 @@ EOF; * @ticket 28699 * @dataProvider data_slash_zero_removal */ - function test_slash_zero_removal( $input, $output ) { + public function test_slash_zero_removal( $input, $output ) { global $allowedposttags; return $this->assertSame( $output, wp_kses( $input, $allowedposttags ) ); } - function data_slash_zero_removal() { + public function data_slash_zero_removal() { return array( array( 'This \\0 should be no big deal.', @@ -657,11 +657,11 @@ EOF; * * @dataProvider data_hair_parse */ - function test_hair_parse( $input, $output ) { + public function test_hair_parse( $input, $output ) { return $this->assertSame( $output, wp_kses_hair_parse( $input ) ); } - function data_hair_parse() { + public function data_hair_parse() { return array( array( 'title="hello" href="#" id="my_id" ', @@ -723,11 +723,11 @@ EOF; * * @dataProvider data_attr_parse */ - function test_attr_parse( $input, $output ) { + public function test_attr_parse( $input, $output ) { return $this->assertSame( $output, wp_kses_attr_parse( $input ) ); } - function data_attr_parse() { + public function data_attr_parse() { return array( array( '', @@ -781,11 +781,11 @@ EOF; * * @dataProvider data_one_attr */ - function test_one_attr( $element, $input, $output ) { + public function test_one_attr( $element, $input, $output ) { return $this->assertSame( $output, wp_kses_one_attr( $input, $element ) ); } - function data_one_attr() { + public function data_one_attr() { return array( array( 'a', @@ -858,7 +858,7 @@ EOF; /** * @ticket 34063 */ - function test_bdo() { + public function test_bdo() { global $allowedposttags; $input = '

    This is a BDO tag. Weird, right?

    '; @@ -869,7 +869,7 @@ EOF; /** * @ticket 35079 */ - function test_ol_reversed() { + public function test_ol_reversed() { global $allowedposttags; $input = '
    1. Item 1
    2. Item 2
    3. Item 3
    '; @@ -880,7 +880,7 @@ EOF; /** * @ticket 40680 */ - function test_wp_kses_attr_no_attributes_allowed_with_empty_array() { + public function test_wp_kses_attr_no_attributes_allowed_with_empty_array() { $element = 'foo'; $attribute = 'title="foo" class="bar"'; @@ -890,7 +890,7 @@ EOF; /** * @ticket 40680 */ - function test_wp_kses_attr_no_attributes_allowed_with_true() { + public function test_wp_kses_attr_no_attributes_allowed_with_true() { $element = 'foo'; $attribute = 'title="foo" class="bar"'; @@ -900,7 +900,7 @@ EOF; /** * @ticket 40680 */ - function test_wp_kses_attr_single_attribute_is_allowed() { + public function test_wp_kses_attr_single_attribute_is_allowed() { $element = 'foo'; $attribute = 'title="foo" class="bar"'; @@ -910,7 +910,7 @@ EOF; /** * @ticket 43312 */ - function test_wp_kses_attr_no_attributes_allowed_with_false() { + public function test_wp_kses_attr_no_attributes_allowed_with_false() { $element = 'foo'; $attribute = 'title="foo" class="bar"'; @@ -1116,7 +1116,7 @@ EOF; * * @ticket 33121 */ - function test_wp_kses_attr_data_attribute_is_allowed() { + public function test_wp_kses_attr_data_attribute_is_allowed() { $test = '
    Pens and pencils
    '; $expected = '
    Pens and pencils
    '; @@ -1128,7 +1128,7 @@ EOF; * * @ticket 33121 */ - function test_wildcard_requires_hyphen_after_prefix() { + public function test_wildcard_requires_hyphen_after_prefix() { $allowed_html = array( 'div' => array( 'data-*' => true, @@ -1149,7 +1149,7 @@ EOF; * * @ticket 33121 */ - function test_wildcard_allows_two_hyphens() { + public function test_wildcard_allows_two_hyphens() { $allowed_html = array( 'div' => array( 'data-*' => true, @@ -1171,7 +1171,7 @@ EOF; * * @ticket 33121 */ - function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) { + public function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) { $allowed_html = array( 'div' => array( $wildcard_attribute => true, @@ -1192,7 +1192,7 @@ EOF; * [0] The prefix being tested. * [1] The outcome of `wp_kses_attr_check` for the prefix. */ - function data_wildcard_attribute_prefixes() { + public function data_wildcard_attribute_prefixes() { return array( // Ends correctly. array( 'data-*', true ), @@ -1218,7 +1218,7 @@ EOF; * @param $input string The style attribute saved in the editor. * @param $expected string The sanitized style attribute. */ - function test_kses_style_attr_with_url( $input, $expected ) { + public function test_kses_style_attr_with_url( $input, $expected ) { $actual = safecss_filter_attr( $input ); $this->assertSame( $expected, $actual ); @@ -1229,7 +1229,7 @@ EOF; * * @return array Nested array of input, expected pairs. */ - function data_kses_style_attr_with_url() { + public function data_kses_style_attr_with_url() { return array( /* * Valid use cases. @@ -1462,7 +1462,7 @@ EOF; * * @ticket 50731 */ - function test_wp_kses_img_tag_standard_attributes() { + public function test_wp_kses_img_tag_standard_attributes() { $html = array( 'assertSame( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) ); $this->assertSame( 'before-last-bar', before_last_bar( 'before-last-bar|after-bar' ) ); $this->assertSame( 'first-before-bar|second-before-bar', before_last_bar( 'first-before-bar|second-before-bar|after-last-bar' ) ); @@ -54,7 +54,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 35950 */ - function test_get_available_languages() { + public function test_get_available_languages() { $array = get_available_languages(); $this->assertIsArray( $array ); @@ -68,7 +68,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 35284 */ - function test_wp_get_installed_translations_for_core() { + public function test_wp_get_installed_translations_for_core() { $installed_translations = wp_get_installed_translations( 'core' ); $this->assertIsArray( $installed_translations ); $textdomains_expected = array( 'admin', 'admin-network', 'continents-cities', 'default' ); @@ -90,7 +90,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 35294 */ - function test_wp_dropdown_languages() { + public function test_wp_dropdown_languages() { $args = array( 'id' => 'foo', 'name' => 'bar', @@ -112,7 +112,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 38632 */ - function test_wp_dropdown_languages_site_default() { + public function test_wp_dropdown_languages_site_default() { $args = array( 'id' => 'foo', 'name' => 'bar', @@ -136,7 +136,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44494 */ - function test_wp_dropdown_languages_exclude_en_us() { + public function test_wp_dropdown_languages_exclude_en_us() { $args = array( 'id' => 'foo', 'name' => 'bar', @@ -154,7 +154,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 38632 */ - function test_wp_dropdown_languages_en_US_selected() { + public function test_wp_dropdown_languages_en_US_selected() { $args = array( 'id' => 'foo', 'name' => 'bar', @@ -176,7 +176,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * Add site default language to ja_JP in dropdown */ - function test_wp_dropdown_languages_site_default_ja_JP() { + public function test_wp_dropdown_languages_site_default_ja_JP() { $args = array( 'id' => 'foo', 'name' => 'bar', @@ -200,7 +200,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * Select dropdown language from de_DE to ja_JP */ - function test_wp_dropdown_languages_ja_JP_selected() { + public function test_wp_dropdown_languages_ja_JP_selected() { $args = array( 'id' => 'foo', 'name' => 'bar', @@ -224,7 +224,7 @@ class Tests_L10n extends WP_UnitTestCase { * * @return array */ - function wp_dropdown_languages_filter() { + private function wp_dropdown_languages_filter() { return array( 'de_DE' => array( 'language' => 'de_DE', @@ -247,7 +247,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 35284 */ - function test_wp_get_pomo_file_data() { + public function test_wp_get_pomo_file_data() { $file = DIR_TESTDATA . '/pomo/empty.po'; $array = wp_get_pomo_file_data( $file ); $this->assertArrayHasKey( 'POT-Creation-Date', $array ); @@ -273,7 +273,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_excerpt_should_be_counted_by_words() { + public function test_length_of_excerpt_should_be_counted_by_words() { global $post; switch_to_locale( 'en_US' ); @@ -297,7 +297,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_excerpt_should_be_counted_by_chars() { + public function test_length_of_excerpt_should_be_counted_by_chars() { global $post; switch_to_locale( 'ja_JP' ); @@ -321,7 +321,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_excerpt_should_be_counted_by_chars_in_japanese() { + public function test_length_of_excerpt_should_be_counted_by_chars_in_japanese() { global $post; switch_to_locale( 'ja_JP' ); @@ -345,7 +345,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_excerpt_rss_should_be_counted_by_words() { + public function test_length_of_excerpt_rss_should_be_counted_by_words() { global $post; switch_to_locale( 'en_US' ); @@ -369,7 +369,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_excerpt_rss_should_be_counted_by_chars() { + public function test_length_of_excerpt_rss_should_be_counted_by_chars() { global $post; switch_to_locale( 'ja_JP' ); @@ -394,7 +394,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_draft_should_be_counted_by_words() { + public function test_length_of_draft_should_be_counted_by_words() { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; switch_to_locale( 'en_US' ); @@ -418,7 +418,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_draft_should_be_counted_by_chars() { + public function test_length_of_draft_should_be_counted_by_chars() { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; switch_to_locale( 'ja_JP' ); @@ -442,7 +442,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_draft_should_be_counted_by_chars_in_japanese() { + public function test_length_of_draft_should_be_counted_by_chars_in_japanese() { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; switch_to_locale( 'ja_JP' ); @@ -466,7 +466,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_comment_excerpt_should_be_counted_by_words() { + public function test_length_of_comment_excerpt_should_be_counted_by_words() { switch_to_locale( 'en_US' ); $args = array( @@ -484,7 +484,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_comment_excerpt_should_be_counted_by_chars() { + public function test_length_of_comment_excerpt_should_be_counted_by_chars() { switch_to_locale( 'ja_JP' ); $args = array( @@ -502,7 +502,7 @@ class Tests_L10n extends WP_UnitTestCase { /** * @ticket 44541 */ - function test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese() { + public function test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese() { switch_to_locale( 'ja_JP' ); $args = array( diff --git a/tests/phpunit/tests/l10n/loadTextdomain.php b/tests/phpunit/tests/l10n/loadTextdomain.php index 1381e211bd..079a4aec49 100644 --- a/tests/phpunit/tests/l10n/loadTextdomain.php +++ b/tests/phpunit/tests/l10n/loadTextdomain.php @@ -109,13 +109,13 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase { /** * @ticket 21319 */ - function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() { + public function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() { $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); __( 'just some string', 'wp-tests-domain' ); $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); } - function test_override_load_textdomain_noop() { + public function test_override_load_textdomain_noop() { add_filter( 'override_load_textdomain', '__return_true' ); $load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ); remove_filter( 'override_load_textdomain', '__return_true' ); @@ -124,10 +124,10 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase { $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); } - function test_override_load_textdomain_non_existent_mofile() { - add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 ); + public function test_override_load_textdomain_non_existent_mofile() { + add_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain_filter' ), 10, 3 ); $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' ); - remove_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ) ); + remove_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain_filter' ) ); $is_textdomain_loaded = is_textdomain_loaded( 'wp-tests-domain' ); unload_textdomain( 'wp-tests-domain' ); @@ -138,10 +138,10 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase { $this->assertFalse( $is_textdomain_loaded_after ); } - function test_override_load_textdomain_custom_mofile() { - add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 ); + public function test_override_load_textdomain_custom_mofile() { + add_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain_filter' ), 10, 3 ); $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' ); - remove_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ) ); + remove_filter( 'override_load_textdomain', array( $this, 'override_load_textdomain_filter' ) ); $is_textdomain_loaded = is_textdomain_loaded( 'wp-tests-domain' ); unload_textdomain( 'wp-tests-domain' ); @@ -158,7 +158,7 @@ class Tests_L10n_LoadTextdomain extends WP_UnitTestCase { * @param string $file Path to the MO file. * @return bool */ - function _override_load_textdomain_filter( $override, $domain, $file ) { + public function override_load_textdomain_filter( $override, $domain, $file ) { global $l10n; if ( ! is_readable( $file ) ) { diff --git a/tests/phpunit/tests/l10n/translateSettingsUsingI18nSchema.php b/tests/phpunit/tests/l10n/translateSettingsUsingI18nSchema.php index e555e6bb38..94588491fa 100644 --- a/tests/phpunit/tests/l10n/translateSettingsUsingI18nSchema.php +++ b/tests/phpunit/tests/l10n/translateSettingsUsingI18nSchema.php @@ -10,14 +10,14 @@ class Tests_L10n_TranslateSettingsUsingI18nSchema extends WP_UnitTestCase { * * @return string */ - function filter_set_locale_to_polish() { + public function filter_set_locale_to_polish() { return 'pl_PL'; } /** * @ticket 53238 */ - function test_translate_settings_using_i18n_schema() { + public function test_translate_settings_using_i18n_schema() { $textdomain = 'notice'; add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) ); diff --git a/tests/phpunit/tests/link.php b/tests/phpunit/tests/link.php index fca11da463..f3216c17ee 100644 --- a/tests/phpunit/tests/link.php +++ b/tests/phpunit/tests/link.php @@ -4,29 +4,29 @@ */ class Tests_Link extends WP_UnitTestCase { - function _get_pagenum_link_cb( $url ) { + public function get_pagenum_link_cb( $url ) { return $url . '/WooHoo'; } /** * @ticket 8847 */ - function test_get_pagenum_link_case_insensitivity() { + public function test_get_pagenum_link_case_insensitivity() { $old_req_uri = $_SERVER['REQUEST_URI']; $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - add_filter( 'home_url', array( $this, '_get_pagenum_link_cb' ) ); + add_filter( 'home_url', array( $this, 'get_pagenum_link_cb' ) ); $_SERVER['REQUEST_URI'] = '/woohoo'; $paged = get_pagenum_link( 2 ); - remove_filter( 'home_url', array( $this, '_get_pagenum_link_cb' ) ); + remove_filter( 'home_url', array( $this, 'get_pagenum_link_cb' ) ); $this->assertSame( $paged, home_url( '/WooHoo/page/2/' ) ); $_SERVER['REQUEST_URI'] = $old_req_uri; } - function test_wp_get_shortlink() { + public function test_wp_get_shortlink() { $post_id = self::factory()->post->create(); $post_id2 = self::factory()->post->create(); @@ -70,7 +70,7 @@ class Tests_Link extends WP_UnitTestCase { $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink() ); } - function test_wp_get_shortlink_with_page() { + public function test_wp_get_shortlink_with_page() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); // Basic case. @@ -85,7 +85,7 @@ class Tests_Link extends WP_UnitTestCase { /** * @ticket 26871 */ - function test_wp_get_shortlink_with_home_page() { + public function test_wp_get_shortlink_with_home_page() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $post_id ); diff --git a/tests/phpunit/tests/link/getAdjacentPost.php b/tests/phpunit/tests/link/getAdjacentPost.php index 2954732ef2..505d52a1dc 100644 --- a/tests/phpunit/tests/link/getAdjacentPost.php +++ b/tests/phpunit/tests/link/getAdjacentPost.php @@ -89,7 +89,7 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase { /** * @ticket 22112 */ - function test_get_adjacent_post_exclude_self_term() { + public function test_get_adjacent_post_exclude_self_term() { // Bump term_taxonomy to mimic shared term offsets. global $wpdb; $wpdb->insert( diff --git a/tests/phpunit/tests/load/wpConvertHrToBytes.php b/tests/phpunit/tests/load/wpConvertHrToBytes.php index 70487cb449..8275d260e4 100644 --- a/tests/phpunit/tests/load/wpConvertHrToBytes.php +++ b/tests/phpunit/tests/load/wpConvertHrToBytes.php @@ -17,7 +17,7 @@ class Tests_Load_wpConvertHrToBytes extends WP_UnitTestCase { * @param int|string $value The value passed to wp_convert_hr_to_bytes(). * @param int $expected The expected output of wp_convert_hr_to_bytes(). */ - function test_wp_convert_hr_to_bytes( $value, $expected ) { + public function test_wp_convert_hr_to_bytes( $value, $expected ) { $this->assertSame( $expected, wp_convert_hr_to_bytes( $value ) ); } @@ -31,7 +31,7 @@ class Tests_Load_wpConvertHrToBytes extends WP_UnitTestCase { * } * } */ - function data_wp_convert_hr_to_bytes() { + public function data_wp_convert_hr_to_bytes() { $array = array( // Integer input. array( -1, -1 ), // = no memory limit. diff --git a/tests/phpunit/tests/load/wpIsIniValueChangeable.php b/tests/phpunit/tests/load/wpIsIniValueChangeable.php index 1a27e60db3..f92ea43d51 100644 --- a/tests/phpunit/tests/load/wpIsIniValueChangeable.php +++ b/tests/phpunit/tests/load/wpIsIniValueChangeable.php @@ -18,7 +18,7 @@ class Tests_Load_wpIsIniValueChangeable extends WP_UnitTestCase { * @param string $setting The setting passed to wp_is_ini_value_changeable(). * @param bool $expected The expected output of wp_convert_hr_to_bytes(). */ - function test_wp_is_ini_value_changeable( $setting, $expected ) { + public function test_wp_is_ini_value_changeable( $setting, $expected ) { $this->assertSame( $expected, wp_is_ini_value_changeable( $setting ) ); } @@ -32,7 +32,7 @@ class Tests_Load_wpIsIniValueChangeable extends WP_UnitTestCase { * } * } */ - function data_wp_is_ini_value_changeable() { + public function data_wp_is_ini_value_changeable() { $array = array( array( 'memory_limit', true ), // PHP_INI_ALL. array( 'log_errors', true ), // PHP_INI_ALL. diff --git a/tests/phpunit/tests/mail.php b/tests/phpunit/tests/mail.php index 54fe8794e3..66a613234b 100644 --- a/tests/phpunit/tests/mail.php +++ b/tests/phpunit/tests/mail.php @@ -4,12 +4,12 @@ * @group mail */ class Tests_Mail extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); reset_phpmailer_instance(); } - function tear_down() { + public function tear_down() { reset_phpmailer_instance(); parent::tear_down(); } @@ -22,12 +22,12 @@ class Tests_Mail extends WP_UnitTestCase { * all variables, which means that following tests would fail. To solve this issue we set `$this->Encoding` * back to 8bit in `MockPHPMailer::preSend`. */ - function test_wp_mail_break_it() { + public function test_wp_mail_break_it() { $content = str_repeat( 'A', 1000 ); $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Looong line testing', $content ) ); } - function test_wp_mail_custom_boundaries() { + public function test_wp_mail_custom_boundaries() { $to = 'user@example.com'; $subject = 'Test email with custom boundaries'; $headers = '' . "\n"; @@ -88,7 +88,7 @@ class Tests_Mail extends WP_UnitTestCase { /** * @ticket 17305 */ - function test_wp_mail_rfc2822_addresses() { + public function test_wp_mail_rfc2822_addresses() { $to = 'Name '; $from = 'Another Name '; $cc = 'The Carbon Guy '; @@ -118,7 +118,7 @@ class Tests_Mail extends WP_UnitTestCase { /** * @ticket 17305 */ - function test_wp_mail_multiple_rfc2822_to_addresses() { + public function test_wp_mail_multiple_rfc2822_to_addresses() { $to = 'Name , Another Name '; $subject = 'RFC2822 Testing'; $message = 'My RFC822 Test Message'; @@ -135,7 +135,7 @@ class Tests_Mail extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } - function test_wp_mail_multiple_to_addresses() { + public function test_wp_mail_multiple_to_addresses() { $to = 'address@tld.com, another_address@different-tld.com'; $subject = 'RFC2822 Testing'; $message = 'My RFC822 Test Message'; @@ -151,7 +151,7 @@ class Tests_Mail extends WP_UnitTestCase { /** * @ticket 18463 */ - function test_wp_mail_to_address_no_name() { + public function test_wp_mail_to_address_no_name() { $to = ''; $subject = 'RFC2822 Testing'; $message = 'My RFC822 Test Message'; @@ -166,7 +166,7 @@ class Tests_Mail extends WP_UnitTestCase { /** * @ticket 23642 */ - function test_wp_mail_return_value() { + public function test_wp_mail_return_value() { // No errors. $this->assertTrue( wp_mail( 'valid@address.com', 'subject', 'body' ) ); @@ -289,11 +289,11 @@ class Tests_Mail extends WP_UnitTestCase { $this->assertSame( 1, substr_count( $mailer->get_sent()->header, $expected ) ); } - function wp_mail_quoted_printable( $mailer ) { + public function wp_mail_quoted_printable( $mailer ) { $mailer->Encoding = 'quoted-printable'; } - function wp_mail_set_text_message( $mailer ) { + public function wp_mail_set_text_message( $mailer ) { $mailer->AltBody = 'Wörld'; } @@ -309,7 +309,7 @@ class Tests_Mail extends WP_UnitTestCase { * * @ticket 28039 */ - function test_wp_mail_content_transfer_encoding_in_quoted_printable_multipart() { + public function test_wp_mail_content_transfer_encoding_in_quoted_printable_multipart() { add_action( 'phpmailer_init', array( $this, 'wp_mail_quoted_printable' ) ); add_action( 'phpmailer_init', array( $this, 'wp_mail_set_text_message' ) ); @@ -411,7 +411,7 @@ class Tests_Mail extends WP_UnitTestCase { /** * @ticket 50720 */ - function test_phpmailer_validator() { + public function test_phpmailer_validator() { $phpmailer = $GLOBALS['phpmailer']; $this->assertTrue( $phpmailer->validateAddress( 'foo@192.168.1.1' ), 'Assert PHPMailer accepts IP address email addresses' ); } diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 1be2526ff4..0483f0c084 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -56,7 +56,7 @@ class Tests_Media extends WP_UnitTestCase { parent::tear_down_after_class(); } - function set_up() { + public function set_up() { parent::set_up(); $this->caption = 'A simple caption.'; $this->alternate_caption = 'Alternate caption.'; @@ -76,13 +76,13 @@ CAP; ); } - function test_img_caption_shortcode_added() { + public function test_img_caption_shortcode_added() { global $shortcode_tags; $this->assertSame( 'img_caption_shortcode', $shortcode_tags['caption'] ); $this->assertSame( 'img_caption_shortcode', $shortcode_tags['wp_caption'] ); } - function test_img_caption_shortcode_with_empty_params() { + public function test_img_caption_shortcode_with_empty_params() { $result = img_caption_shortcode( array() ); $this->assertSame( '', $result ); } @@ -90,7 +90,7 @@ CAP; /** * @ticket 33981 */ - function test_img_caption_shortcode_with_empty_params_but_content() { + public function test_img_caption_shortcode_with_empty_params_but_content() { $result = img_caption_shortcode( array(), $this->caption ); $this->assertSame( $this->caption, $result ); } @@ -98,8 +98,8 @@ CAP; /** * @ticket 33981 */ - function test_img_caption_shortcode_short_circuit_filter() { - add_filter( 'img_caption_shortcode', array( $this, '_return_alt_caption' ) ); + public function test_img_caption_shortcode_short_circuit_filter() { + add_filter( 'img_caption_shortcode', array( $this, 'return_alt_caption' ) ); $result = img_caption_shortcode( array(), $this->caption ); $this->assertSame( $this->alternate_caption, $result ); @@ -108,14 +108,14 @@ CAP; /** * Filter used in test_img_caption_shortcode_short_circuit_filter() */ - function _return_alt_caption() { + public function return_alt_caption() { return $this->alternate_caption; } /** * @ticket 33981 */ - function test_img_caption_shortcode_empty_width() { + public function test_img_caption_shortcode_empty_width() { $result = img_caption_shortcode( array( 'width' => 0, @@ -128,7 +128,7 @@ CAP; /** * @ticket 33981 */ - function test_img_caption_shortcode_empty_caption() { + public function test_img_caption_shortcode_empty_caption() { $result = img_caption_shortcode( array( 'caption' => '', @@ -140,7 +140,7 @@ CAP; /** * @ticket 33981 */ - function test_img_caption_shortcode_empty_caption_and_content() { + public function test_img_caption_shortcode_empty_caption_and_content() { $result = img_caption_shortcode( array( 'caption' => '', @@ -150,7 +150,7 @@ CAP; $this->assertSame( $this->caption, $result ); } - function test_img_caption_shortcode_with_old_format() { + public function test_img_caption_shortcode_with_old_format() { $result = img_caption_shortcode( array( 'width' => 20, @@ -169,7 +169,7 @@ CAP; } } - function test_img_caption_shortcode_with_old_format_id_and_align() { + public function test_img_caption_shortcode_with_old_format_id_and_align() { $result = img_caption_shortcode( array( 'width' => 20, @@ -183,7 +183,7 @@ CAP; $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); } - function test_img_caption_shortcode_with_old_format_and_class() { + public function test_img_caption_shortcode_with_old_format_and_class() { $result = img_caption_shortcode( array( 'width' => 20, @@ -195,7 +195,7 @@ CAP; } - function test_new_img_caption_shortcode_with_html_caption() { + public function test_new_img_caption_shortcode_with_html_caption() { $result = img_caption_shortcode( array( 'width' => 20, @@ -207,7 +207,7 @@ CAP; $this->assertSame( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) ); } - function test_new_img_caption_shortcode_new_format() { + public function test_new_img_caption_shortcode_new_format() { $result = img_caption_shortcode( array( 'width' => 20 ), $this->img_content . $this->html_content @@ -219,7 +219,7 @@ CAP; $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); } - function test_new_img_caption_shortcode_new_format_and_linked_image() { + public function test_new_img_caption_shortcode_new_format_and_linked_image() { $linked_image = "
    {$this->img_content}"; $result = img_caption_shortcode( array( 'width' => 20 ), @@ -232,7 +232,7 @@ CAP; $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); } - function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { + public function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { $linked_image = "{$this->img_content}"; $result = img_caption_shortcode( array( 'width' => 20 ), @@ -248,7 +248,7 @@ CAP; /** * @ticket 34595 */ - function test_img_caption_shortcode_has_aria_describedby() { + public function test_img_caption_shortcode_has_aria_describedby() { $result = img_caption_shortcode( array( 'width' => 20, @@ -260,7 +260,7 @@ CAP; $this->assertSame( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) ); } - function test_add_remove_oembed_provider() { + public function test_add_remove_oembed_provider() { wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); $this->assertFalse( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); @@ -269,7 +269,7 @@ CAP; /** * @ticket 23776 */ - function test_autoembed_empty() { + public function test_autoembed_empty() { global $wp_embed; $content = ''; @@ -283,7 +283,7 @@ CAP; * * @group external-http */ - function test_autoembed_no_paragraphs_around_urls() { + public function test_autoembed_no_paragraphs_around_urls() { global $wp_embed; $content = <<assertSame( $content, $result ); } - function data_autoembed() { + public function data_autoembed() { return array( // Should embed. @@ -362,13 +362,13 @@ https://w.org', /** * @dataProvider data_autoembed */ - function test_autoembed( $content, $result = null ) { + public function test_autoembed( $content, $result = null ) { $wp_embed = new Test_Autoembed; $this->assertSame( $wp_embed->autoembed( $content ), $result ? $result : $content ); } - function test_wp_prepare_attachment_for_js() { + public function test_wp_prepare_attachment_for_js() { // Attachment without media. $id = wp_insert_attachment( array( @@ -422,7 +422,7 @@ https://w.org', /** * @ticket 38965 */ - function test_wp_prepare_attachment_for_js_without_image_sizes() { + public function test_wp_prepare_attachment_for_js_without_image_sizes() { // Create the attachement post. $id = wp_insert_attachment( array( @@ -453,7 +453,7 @@ https://w.org', * @ticket 19067 * @expectedDeprecated wp_convert_bytes_to_hr */ - function test_wp_convert_bytes_to_hr() { + public function test_wp_convert_bytes_to_hr() { $kb = 1024; $mb = $kb * 1024; $gb = $mb * 1024; @@ -491,7 +491,7 @@ https://w.org', /** * @ticket 22960 */ - function test_get_attached_images() { + public function test_get_attached_images() { $post_id = self::factory()->post->create(); $attachment_id = self::factory()->attachment->create_object( $this->img_name, @@ -509,7 +509,7 @@ https://w.org', /** * @ticket 22960 */ - function test_post_galleries_images() { + public function test_post_galleries_images() { $ids1 = array(); $ids1_srcs = array(); foreach ( range( 1, 3 ) as $i ) { @@ -560,7 +560,7 @@ BLOB; /** * @ticket 39304 */ - function test_post_galleries_images_without_global_post() { + public function test_post_galleries_images_without_global_post() { // Set up an unattached image. $this->factory->attachment->create_object( array( @@ -585,7 +585,7 @@ BLOB; /** * @ticket 39304 */ - function test_post_galleries_ignores_global_post() { + public function test_post_galleries_ignores_global_post() { $global_post_id = $this->factory->post->create( array( 'post_content' => 'Global Post', @@ -620,7 +620,7 @@ BLOB; /** * @ticket 39304 */ - function test_post_galleries_respects_id_attrs() { + public function test_post_galleries_respects_id_attrs() { $post_id = $this->factory->post->create( array( 'post_content' => 'No gallery defined', @@ -659,7 +659,7 @@ BLOB; /** * @ticket 22960 */ - function test_post_gallery_images() { + public function test_post_gallery_images() { $ids1 = array(); $ids1_srcs = array(); foreach ( range( 1, 3 ) as $i ) { @@ -707,7 +707,7 @@ BLOB; $this->assertSame( $srcs, $ids1_srcs ); } - function test_get_media_embedded_in_content() { + public function test_get_media_embedded_in_content() { $object = << @@ -771,7 +771,7 @@ CONTENT; $this->assertSame( $contents, $matches ); } - function test_get_media_embedded_in_content_order() { + public function test_get_media_embedded_in_content_order() { $audio = <<
    @@ -62,7 +62,7 @@ EOF; $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); } - function test_the_content_shortcode() { + public function test_the_content_shortcode() { $post_content = <<assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); } - function test_the_content_shortcode_paragraph() { + public function test_the_content_shortcode_paragraph() { $post_content = <<assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); } - function test_the_content_attribute_filtering() { + public function test_the_content_attribute_filtering() { kses_init_filters(); // http://bpr3.org/?p=87 @@ -152,7 +152,7 @@ EOF; kses_remove_filters(); } - function test_the_content_attribute_value_with_colon() { + public function test_the_content_attribute_value_with_colon() { kses_init_filters(); // http://bpr3.org/?p=87 diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 6622813ef9..29267e429a 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -8,7 +8,7 @@ class Tests_Post_Query extends WP_UnitTestCase { /** * @group taxonomy */ - function test_category__and_var() { + public function test_category__and_var() { $q = new WP_Query(); $term_id = self::factory()->category->create( @@ -50,7 +50,7 @@ class Tests_Post_Query extends WP_UnitTestCase { * @ticket 28099 * @group taxonomy */ - function test_empty_category__in() { + public function test_empty_category__in() { $cat_id = self::factory()->category->create(); $post_id = self::factory()->post->create(); wp_set_post_categories( $post_id, $cat_id ); @@ -79,7 +79,7 @@ class Tests_Post_Query extends WP_UnitTestCase { /** * @ticket 22448 */ - function test_the_posts_filter() { + public function test_the_posts_filter() { // Create posts and clear their caches. $post_ids = self::factory()->post->create_many( 4 ); foreach ( $post_ids as $post_id ) { @@ -117,7 +117,7 @@ class Tests_Post_Query extends WP_UnitTestCase { /** * Use with the_posts filter, appends a post and adds some custom data. */ - function the_posts_filter( $posts ) { + public function the_posts_filter( $posts ) { $posts[] = clone $posts[0]; // Add some custom data to each post. @@ -128,7 +128,7 @@ class Tests_Post_Query extends WP_UnitTestCase { return $posts; } - function test_post__in_ordering() { + public function test_post__in_ordering() { $post_id1 = self::factory()->post->create( array( 'post_type' => 'page', @@ -210,7 +210,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $this->assertSame( $ordered, wp_list_pluck( $q->posts, 'ID' ) ); } - function test_post__in_attachment_ordering() { + public function test_post__in_attachment_ordering() { $post_id = self::factory()->post->create(); $att_ids = array(); $file = DIR_TESTDATA . '/images/canola.jpg'; @@ -308,7 +308,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $this->assertSame( $ordered, wp_list_pluck( $q->posts, 'post_name' ) ); } - function test_post_status() { + public function test_post_status() { $statuses1 = get_post_stati(); $this->assertContains( 'auto-draft', $statuses1 ); @@ -331,7 +331,7 @@ class Tests_Post_Query extends WP_UnitTestCase { /** * @ticket 17065 */ - function test_orderby_array() { + public function test_orderby_array() { global $wpdb; $q1 = new WP_Query( @@ -367,7 +367,7 @@ class Tests_Post_Query extends WP_UnitTestCase { /** * @ticket 17065 */ - function test_order() { + public function test_order() { global $wpdb; $q1 = new WP_Query( @@ -407,7 +407,7 @@ class Tests_Post_Query extends WP_UnitTestCase { /** * @ticket 29629 */ - function test_orderby() { + public function test_orderby() { // 'rand' is a valid value. $q = new WP_Query( array( 'orderby' => 'rand' ) ); $this->assertStringContainsString( 'ORDER BY RAND()', $q->request ); diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index 840597c4a9..35e43f18ae 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -15,7 +15,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { self::$author_user_id = $factory->user->create( array( 'role' => 'author' ) ); } - function set_up() { + public function set_up() { parent::set_up(); $this->post_type = rand_str( 20 ); } @@ -26,7 +26,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 20982 * @ticket 16215 */ - function test_revision_restore_updates_edit_last_post_meta() { + public function test_revision_restore_updates_edit_last_post_meta() { // Create a post as Author. wp_set_current_user( self::$author_user_id ); $post = get_default_post_to_edit( 'post', true ); @@ -69,7 +69,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 7392 * @ticket 9843 */ - function test_revision_dont_save_revision_if_unchanged() { + public function test_revision_dont_save_revision_if_unchanged() { $post = get_default_post_to_edit( 'post', true ); $post_id = $post->ID; @@ -139,7 +139,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * @ticket 7392 * @ticket 9843 */ - function test_revision_force_save_revision_even_if_unchanged() { + public function test_revision_force_save_revision_even_if_unchanged() { add_filter( 'wp_save_post_revision_check_for_changes', '__return_false' ); $post = get_default_post_to_edit( 'post', true ); @@ -214,7 +214,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_view_caps_post() { + public function test_revision_view_caps_post() { $post_id = self::factory()->post->create( array( 'post_type' => 'post', @@ -247,7 +247,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_restore_caps_post() { + public function test_revision_restore_caps_post() { $post_id = self::factory()->post->create( array( 'post_type' => 'post', @@ -278,7 +278,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_diff_caps_post() { + public function test_revision_diff_caps_post() { $post_id = self::factory()->post->create( array( 'post_type' => 'post', @@ -316,7 +316,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_view_caps_cpt() { + public function test_revision_view_caps_cpt() { register_post_type( $this->post_type, array( @@ -358,7 +358,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_restore_caps_cpt() { + public function test_revision_restore_caps_cpt() { register_post_type( $this->post_type, array( @@ -404,7 +404,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_restore_caps_before_publish() { + public function test_revision_restore_caps_before_publish() { register_post_type( $this->post_type, array( @@ -464,7 +464,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { * * @ticket 16847 */ - function test_revision_diff_caps_cpt() { + public function test_revision_diff_caps_cpt() { register_post_type( $this->post_type, array( @@ -509,7 +509,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { /** * @ticket 26042 */ - function test_wp_get_post_revisions_should_order_by_post_date() { + public function test_wp_get_post_revisions_should_order_by_post_date() { global $wpdb; $post = self::factory()->post->create_and_get( @@ -545,7 +545,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { /** * @ticket 26042 */ - function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() { + public function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() { $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', diff --git a/tests/phpunit/tests/post/slashes.php b/tests/phpunit/tests/post/slashes.php index 2b06ca5414..c0654770b6 100644 --- a/tests/phpunit/tests/post/slashes.php +++ b/tests/phpunit/tests/post/slashes.php @@ -14,7 +14,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { self::$post_id = $factory->post->create(); } - function set_up() { + public function set_up() { parent::set_up(); wp_set_current_user( self::$author_id ); @@ -33,7 +33,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { /** * Tests the controller function that expects slashed data. */ - function test_edit_post() { + public function test_edit_post() { $post_id = self::$post_id; $_POST = array(); @@ -70,7 +70,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. */ - function test_wp_insert_post() { + public function test_wp_insert_post() { $post_id = wp_insert_post( array( 'post_status' => 'publish', @@ -106,7 +106,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects slashed data. */ - function test_wp_update_post() { + public function test_wp_update_post() { $post_id = self::$post_id; wp_update_post( @@ -141,7 +141,7 @@ class Tests_Post_Slashes extends WP_UnitTestCase { /** * @ticket 27550 */ - function test_wp_trash_untrash() { + public function test_wp_trash_untrash() { $post = array( 'post_title' => $this->slash_1, 'post_content' => $this->slash_3, diff --git a/tests/phpunit/tests/post/template.php b/tests/phpunit/tests/post/template.php index da741c5f5e..c30f31fba2 100644 --- a/tests/phpunit/tests/post/template.php +++ b/tests/phpunit/tests/post/template.php @@ -5,7 +5,7 @@ */ class Tests_Post_Template extends WP_UnitTestCase { - function test_wp_link_pages() { + public function test_wp_link_pages() { $contents = array( 'One', 'Two', 'Three' ); $content = implode( '', $contents ); $post_id = self::factory()->post->create( array( 'post_content' => $content ) ); @@ -131,7 +131,7 @@ class Tests_Post_Template extends WP_UnitTestCase { $this->assertSame( $pagelink, $output ); } - function test_wp_dropdown_pages() { + public function test_wp_dropdown_pages() { $none = wp_dropdown_pages( array( 'echo' => 0 ) ); $this->assertEmpty( $none ); diff --git a/tests/phpunit/tests/post/thumbnails.php b/tests/phpunit/tests/post/thumbnails.php index cea33de9ae..58ac548584 100644 --- a/tests/phpunit/tests/post/thumbnails.php +++ b/tests/phpunit/tests/post/thumbnails.php @@ -31,7 +31,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { parent::tear_down_after_class(); } - function test_has_post_thumbnail() { + public function test_has_post_thumbnail() { $this->assertFalse( has_post_thumbnail( self::$post ) ); $this->assertFalse( has_post_thumbnail( self::$post->ID ) ); $this->assertFalse( has_post_thumbnail() ); @@ -53,7 +53,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { $this->assertTrue( has_post_thumbnail() ); } - function test_get_post_thumbnail_id() { + public function test_get_post_thumbnail_id() { $this->assertSame( 0, get_post_thumbnail_id( self::$post ) ); $this->assertSame( 0, get_post_thumbnail_id( self::$post->ID ) ); $this->assertFalse( get_post_thumbnail_id() ); @@ -68,7 +68,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { $this->assertSame( self::$attachment_id, get_post_thumbnail_id() ); } - function test_update_post_thumbnail_cache() { + public function test_update_post_thumbnail_cache() { set_post_thumbnail( self::$post, self::$attachment_id ); $query = new WP_Query( @@ -89,7 +89,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 12235 */ - function test_get_the_post_thumbnail_caption() { + public function test_get_the_post_thumbnail_caption() { $this->assertSame( '', get_the_post_thumbnail_caption() ); $caption = 'This is a caption.'; @@ -113,7 +113,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 12235 */ - function test_get_the_post_thumbnail_caption_empty() { + public function test_get_the_post_thumbnail_caption_empty() { $post_id = self::factory()->post->create(); $attachment_id = self::factory()->attachment->create_object( 'image.jpg', @@ -133,7 +133,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 12235 */ - function test_the_post_thumbnail_caption() { + public function test_the_post_thumbnail_caption() { $caption = 'This is a caption.'; $post_id = self::factory()->post->create(); @@ -153,7 +153,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { the_post_thumbnail_caption( $post_id ); } - function test_get_the_post_thumbnail() { + public function test_get_the_post_thumbnail() { $this->assertSame( '', get_the_post_thumbnail() ); $this->assertSame( '', get_the_post_thumbnail( self::$post ) ); set_post_thumbnail( self::$post, self::$attachment_id ); @@ -174,7 +174,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { $this->assertSame( $expected, get_the_post_thumbnail() ); } - function test_the_post_thumbnail() { + public function test_the_post_thumbnail() { $this->expectOutputString( '' ); the_post_thumbnail(); @@ -202,7 +202,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 33070 */ - function test_get_the_post_thumbnail_url() { + public function test_get_the_post_thumbnail_url() { $this->assertFalse( has_post_thumbnail( self::$post ) ); $this->assertFalse( get_the_post_thumbnail_url() ); $this->assertFalse( get_the_post_thumbnail_url( self::$post ) ); @@ -220,7 +220,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 33070 */ - function test_get_the_post_thumbnail_url_with_invalid_post() { + public function test_get_the_post_thumbnail_url_with_invalid_post() { set_post_thumbnail( self::$post, self::$attachment_id ); $this->assertNotFalse( get_the_post_thumbnail_url( self::$post->ID ) ); @@ -234,7 +234,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 33070 */ - function test_the_post_thumbnail_url() { + public function test_the_post_thumbnail_url() { $GLOBALS['post'] = self::$post; $this->expectOutputString( '' ); @@ -249,7 +249,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 12922 */ - function test__wp_preview_post_thumbnail_filter() { + public function test__wp_preview_post_thumbnail_filter() { $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; $GLOBALS['post'] = self::$post; @@ -269,7 +269,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 37697 */ - function test__wp_preview_post_thumbnail_filter_secondary_post() { + public function test__wp_preview_post_thumbnail_filter_secondary_post() { $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; $secondary_post = self::factory()->post->create( @@ -295,7 +295,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 12922 */ - function test_insert_post_with_post_thumbnail() { + public function test_insert_post_with_post_thumbnail() { $post_id = wp_insert_post( array( 'ID' => self::$post->ID, @@ -326,7 +326,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 37658 */ - function test_insert_attachment_with_post_thumbnail() { + public function test_insert_attachment_with_post_thumbnail() { // Audio files support featured images. $post_id = wp_insert_post( array( @@ -365,7 +365,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { /** * @ticket 39030 */ - function test_post_thumbnail_size_filter_simple() { + public function test_post_thumbnail_size_filter_simple() { $this->current_size_filter_data = 'medium'; add_filter( 'post_thumbnail_size', array( $this, 'filter_post_thumbnail_size' ), 10, 2 ); @@ -386,7 +386,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { * @ticket 39030 * @dataProvider data_post_thumbnail_size_filter_complex */ - function test_post_thumbnail_size_filter_complex( $which_post, $expected ) { + public function test_post_thumbnail_size_filter_complex( $which_post, $expected ) { $this->current_size_filter_data = array( self::$post->ID => 'medium', self::$different_post->ID => 'thumbnail', @@ -408,14 +408,14 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { $this->assertSame( $expected, $result ); } - function data_post_thumbnail_size_filter_complex() { + public function data_post_thumbnail_size_filter_complex() { return array( array( 0, 'medium' ), array( 1, 'thumbnail' ), ); } - function filter_post_thumbnail_size( $size, $post_id ) { + public function filter_post_thumbnail_size( $size, $post_id ) { if ( is_array( $this->current_size_filter_data ) && isset( $this->current_size_filter_data[ $post_id ] ) ) { return $this->current_size_filter_data[ $post_id ]; } @@ -427,7 +427,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { return $size; } - function filter_set_post_thumbnail_size_result( $html, $post_id, $post_thumbnail_id, $size ) { + public function filter_set_post_thumbnail_size_result( $html, $post_id, $post_thumbnail_id, $size ) { $this->current_size_filter_result = $size; return $html; diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index a6631d7880..449467cf1d 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -18,13 +18,13 @@ class Tests_Post_Types extends WP_UnitTestCase { * * @since 4.5.0 */ - function set_up() { + public function set_up() { parent::set_up(); $this->post_type = rand_str( 20 ); } - function test_register_post_type() { + public function test_register_post_type() { $this->assertNull( get_post_type_object( 'foo' ) ); register_post_type( 'foo' ); @@ -42,7 +42,7 @@ class Tests_Post_Types extends WP_UnitTestCase { /** * @ticket 48558 */ - function test_register_post_type_return_value() { + public function test_register_post_type_return_value() { $this->assertInstanceOf( 'WP_Post_Type', register_post_type( 'foo' ) ); } @@ -51,7 +51,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * * @expectedIncorrectUsage register_post_type */ - function test_register_post_type_with_too_long_name() { + public function test_register_post_type_with_too_long_name() { // Post type too long. $this->assertInstanceOf( 'WP_Error', register_post_type( 'abcdefghijklmnopqrstuvwxyz0123456789' ) ); } @@ -61,7 +61,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * * @expectedIncorrectUsage register_post_type */ - function test_register_post_type_with_empty_name() { + public function test_register_post_type_with_empty_name() { // Post type too short. $this->assertInstanceOf( 'WP_Error', register_post_type( '' ) ); } @@ -70,7 +70,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 35985 * @covers ::register_post_type */ - function test_register_post_type_exclude_from_search_should_default_to_opposite_value_of_public() { + public function test_register_post_type_exclude_from_search_should_default_to_opposite_value_of_public() { /* * 'public' Default is false * 'exclude_from_search' Default is null (opposite 'public') @@ -84,7 +84,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 35985 * @covers ::register_post_type */ - function test_register_post_type_publicly_queryable_should_default_to_value_of_public() { + public function test_register_post_type_publicly_queryable_should_default_to_value_of_public() { /* * 'public' Default is false * 'publicly_queryable' Default is null ('public') @@ -98,7 +98,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 35985 * @covers ::register_post_type */ - function test_register_post_type_show_ui_should_default_to_value_of_public() { + public function test_register_post_type_show_ui_should_default_to_value_of_public() { /* * 'public' Default is false * 'show_ui' Default is null ('public') @@ -112,7 +112,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 35985 * @covers ::register_post_type */ - function test_register_post_type_show_in_menu_should_default_to_value_of_show_ui() { + public function test_register_post_type_show_in_menu_should_default_to_value_of_show_ui() { /* * 'public' Default is false * 'show_ui' Default is null ('public') @@ -131,7 +131,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 35985 * @covers ::register_post_type */ - function test_register_post_type_show_in_nav_menus_should_default_to_value_of_public() { + public function test_register_post_type_show_in_nav_menus_should_default_to_value_of_public() { /* * 'public' Default is false * 'show_in_nav_menus' Default is null ('public') @@ -145,7 +145,7 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 35985 * @covers ::register_post_type */ - function test_register_post_type_show_in_admin_bar_should_default_to_value_of_show_in_menu() { + public function test_register_post_type_show_in_admin_bar_should_default_to_value_of_show_in_menu() { /* * 'public' Default is false * 'show_in_menu' Default is null ('show_ui' > 'public') @@ -163,7 +163,7 @@ class Tests_Post_Types extends WP_UnitTestCase { $this->assertSame( $public, $args->show_in_admin_bar ); } - function test_register_taxonomy_for_object_type() { + public function test_register_taxonomy_for_object_type() { global $wp_taxonomies; register_post_type( 'bar' ); @@ -185,12 +185,12 @@ class Tests_Post_Types extends WP_UnitTestCase { _unregister_post_type( 'bar' ); } - function test_post_type_exists() { + public function test_post_type_exists() { $this->assertFalse( post_type_exists( 'notaposttype' ) ); $this->assertTrue( post_type_exists( 'post' ) ); } - function test_post_type_supports() { + public function test_post_type_supports() { $this->assertTrue( post_type_supports( 'post', 'post-formats' ) ); $this->assertFalse( post_type_supports( 'page', 'post-formats' ) ); $this->assertFalse( post_type_supports( 'notaposttype', 'post-formats' ) ); @@ -201,7 +201,7 @@ class Tests_Post_Types extends WP_UnitTestCase { /** * @ticket 21586 */ - function test_post_type_with_no_support() { + public function test_post_type_with_no_support() { register_post_type( 'foo', array( 'supports' => array() ) ); $this->assertTrue( post_type_supports( 'foo', 'editor' ) ); $this->assertTrue( post_type_supports( 'foo', 'title' ) ); @@ -216,7 +216,7 @@ class Tests_Post_Types extends WP_UnitTestCase { /** * @ticket 23302 */ - function test_post_type_with_no_feed() { + public function test_post_type_with_no_feed() { global $wp_rewrite; $old_permastruct = get_option( 'permalink_structure' ); update_option( 'permalink_structure', '%postname%' ); diff --git a/tests/phpunit/tests/post/wpAfterInsertPost.php b/tests/phpunit/tests/post/wpAfterInsertPost.php index b4a5f52d91..c81ad21387 100644 --- a/tests/phpunit/tests/post/wpAfterInsertPost.php +++ b/tests/phpunit/tests/post/wpAfterInsertPost.php @@ -100,7 +100,7 @@ class Tests_Post_wpAfterInsertPost extends WP_UnitTestCase { * @param null|WP_Post $post_before Null for new posts, the WP_Post object prior * to the update for updated posts. */ - function action_wp_after_insert_post( $post_id, $post, $update, $post_before ) { + public function action_wp_after_insert_post( $post_id, $post, $update, $post_before ) { self::$passed_post_title = $post->post_title; self::$passed_post_status = $post->post_status; diff --git a/tests/phpunit/tests/post/wpInsertPost.php b/tests/phpunit/tests/post/wpInsertPost.php index 51ade49127..c1a60753da 100644 --- a/tests/phpunit/tests/post/wpInsertPost.php +++ b/tests/phpunit/tests/post/wpInsertPost.php @@ -29,7 +29,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { $role->add_cap( 'publish_unmapped_meta_caps' ); } - static function tear_down_after_class() { + public static function tear_down_after_class() { $role = get_role( 'administrator' ); $role->remove_cap( 'publish_mapped_meta_caps' ); $role->remove_cap( 'publish_unmapped_meta_caps' ); @@ -37,7 +37,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { parent::tear_down_after_class(); } - function set_up() { + public function set_up() { parent::set_up(); register_post_type( @@ -68,7 +68,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { /** * @ticket 11863 */ - function test_trashing_a_post_should_add_trashed_suffix_to_post_name() { + public function test_trashing_a_post_should_add_trashed_suffix_to_post_name() { $trashed_about_page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -99,7 +99,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { /** * @ticket 11863 */ - function test_trashed_posts_original_post_name_should_be_reassigned_after_untrashing() { + public function test_trashed_posts_original_post_name_should_be_reassigned_after_untrashing() { $about_page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -116,7 +116,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { /** * @ticket 11863 */ - function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_of_trashed_posts_with_the_desired_slug() { + public function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_of_trashed_posts_with_the_desired_slug() { $trashed_about_page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -140,7 +140,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { /** * @ticket 11863 */ - function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name() { + public function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name() { $about_page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -174,7 +174,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * @ticket 23022 * @dataProvider data_various_post_statuses */ - function test_untrashing_a_post_should_always_restore_it_to_draft_status( $post_status ) { + public function test_untrashing_a_post_should_always_restore_it_to_draft_status( $post_status ) { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -192,7 +192,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * @ticket 23022 * @dataProvider data_various_post_statuses */ - function test_wp_untrash_post_status_filter_restores_post_to_correct_status( $post_status ) { + public function test_wp_untrash_post_status_filter_restores_post_to_correct_status( $post_status ) { add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 ); $page_id = self::factory()->post->create( @@ -215,7 +215,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * * @return array Array of test arguments. */ - function data_various_post_types() { + public function data_various_post_types() { return array( array( 'mapped_meta_caps', @@ -234,7 +234,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * * @return array Array of test arguments. */ - function data_various_post_statuses() { + public function data_various_post_statuses() { return array( array( 'draft', @@ -257,7 +257,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * @ticket 42464 * @dataProvider data_various_post_types */ - function test_contributor_cannot_set_post_slug( $post_type ) { + public function test_contributor_cannot_set_post_slug( $post_type ) { wp_set_current_user( self::$user_ids['contributor'] ); $post_id = $this->factory()->post->create( @@ -296,7 +296,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * @ticket 42464 * @dataProvider data_various_post_types */ - function test_administrator_can_set_post_slug( $post_type ) { + public function test_administrator_can_set_post_slug( $post_type ) { wp_set_current_user( self::$user_ids['administrator'] ); $post_id = $this->factory()->post->create( @@ -337,7 +337,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { * * @ticket 42464 */ - function test_administrator_cannot_set_post_slug_on_post_type_they_cannot_publish() { + public function test_administrator_cannot_set_post_slug_on_post_type_they_cannot_publish() { wp_set_current_user( self::$user_ids['administrator'] ); $post_id = $this->factory()->post->create( @@ -373,7 +373,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase { /** * @ticket 25347 */ - function test_scheduled_post_with_a_past_date_should_be_published() { + public function test_scheduled_post_with_a_past_date_should_be_published() { $now = new DateTimeImmutable( 'now', new DateTimeZone( 'UTC' ) ); diff --git a/tests/phpunit/tests/post/wpListPages.php b/tests/phpunit/tests/post/wpListPages.php index 80cb68658a..f59585a71c 100644 --- a/tests/phpunit/tests/post/wpListPages.php +++ b/tests/phpunit/tests/post/wpListPages.php @@ -115,7 +115,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { } } - function test_wp_list_pages_default() { + public function test_wp_list_pages_default() { $args = array( 'echo' => false, ); @@ -146,7 +146,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_depth() { + public function test_wp_list_pages_depth() { $args = array( 'echo' => false, 'depth' => 1, @@ -160,7 +160,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_show_date() { + public function test_wp_list_pages_show_date() { $args = array( 'echo' => false, 'depth' => 1, @@ -176,7 +176,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_date_format() { + public function test_wp_list_pages_date_format() { $args = array( 'echo' => false, 'show_date' => true, @@ -210,7 +210,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_child_of() { + public function test_wp_list_pages_child_of() { $args = array( 'echo' => false, 'child_of' => self::$parent_2, @@ -224,7 +224,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_exclude() { + public function test_wp_list_pages_exclude() { $args = array( 'echo' => false, 'exclude' => self::$parent_2, @@ -252,7 +252,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_title_li() { + public function test_wp_list_pages_title_li() { $args = array( 'echo' => false, 'depth' => 1, @@ -267,7 +267,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_echo() { + public function test_wp_list_pages_echo() { $args = array( 'echo' => true, 'depth' => 1, @@ -282,7 +282,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { wp_list_pages( $args ); } - function test_wp_list_pages_authors() { + public function test_wp_list_pages_authors() { $args = array( 'echo' => false, 'authors' => self::$author, @@ -294,7 +294,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_number() { + public function test_wp_list_pages_number() { $args = array( 'echo' => false, 'number' => 1, @@ -307,7 +307,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_sort_column() { + public function test_wp_list_pages_sort_column() { $args = array( 'echo' => false, 'depth' => 1, @@ -323,7 +323,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_link_before() { + public function test_wp_list_pages_link_before() { $args = array( 'echo' => false, 'link_before' => 'BEFORE', @@ -355,7 +355,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_link_after() { + public function test_wp_list_pages_link_after() { $args = array( 'echo' => false, 'link_after' => 'AFTER', @@ -388,7 +388,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { } - function test_wp_list_pages_include() { + public function test_wp_list_pages_include() { $args = array( 'echo' => false, 'include' => self::$parent_1 . ',' . self::$parent_3, @@ -401,7 +401,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_exclude_tree() { + public function test_wp_list_pages_exclude_tree() { $args = array( 'echo' => false, 'exclude_tree' => self::$parent_2 . ',' . self::$parent_3, @@ -419,7 +419,7 @@ class Tests_Post_wpListPages extends WP_UnitTestCase { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - function test_wp_list_pages_discarded_whitespace() { + public function test_wp_list_pages_discarded_whitespace() { $args = array( 'echo' => false, 'item_spacing' => 'discard', diff --git a/tests/phpunit/tests/post/wpPublishPost.php b/tests/phpunit/tests/post/wpPublishPost.php index e8514cde3e..609ae7570a 100644 --- a/tests/phpunit/tests/post/wpPublishPost.php +++ b/tests/phpunit/tests/post/wpPublishPost.php @@ -26,7 +26,7 @@ class Tests_Post_wpPublishPost extends WP_UnitTestCase { * * @ticket 51292 */ - function test_wp_publish_post_respects_current_categories() { + public function test_wp_publish_post_respects_current_categories() { $post_id = self::$auto_draft_id; $category_id = $this->factory->term->create( array( 'taxonomy' => 'category' ) ); wp_set_post_categories( $post_id, $category_id ); @@ -47,7 +47,7 @@ class Tests_Post_wpPublishPost extends WP_UnitTestCase { * @covers ::wp_publish_post * @ticket 51292 */ - function test_wp_publish_post_adds_default_category() { + public function test_wp_publish_post_adds_default_category() { $post_id = self::$auto_draft_id; wp_publish_post( $post_id ); @@ -67,7 +67,7 @@ class Tests_Post_wpPublishPost extends WP_UnitTestCase { * @covers ::wp_publish_post * @ticket 51292 */ - function test_wp_publish_post_adds_default_category_when_tagged() { + public function test_wp_publish_post_adds_default_category_when_tagged() { $post_id = self::$auto_draft_id; $tag_id = $this->factory->term->create( array( 'taxonomy' => 'post_tag' ) ); wp_set_post_tags( $post_id, array( $tag_id ) ); @@ -88,7 +88,7 @@ class Tests_Post_wpPublishPost extends WP_UnitTestCase { * @covers ::wp_publish_post * @ticket 51292 */ - function test_wp_publish_post_respects_current_terms() { + public function test_wp_publish_post_respects_current_terms() { // Create custom taxonomy to test with. register_taxonomy( 'tax_51292', @@ -123,7 +123,7 @@ class Tests_Post_wpPublishPost extends WP_UnitTestCase { * @covers ::wp_publish_post * @ticket 51292 */ - function test_wp_publish_post_adds_default_term() { + public function test_wp_publish_post_adds_default_term() { // Create custom taxonomy to test with. register_taxonomy( 'tax_51292', diff --git a/tests/phpunit/tests/post/wpUniquePostSlug.php b/tests/phpunit/tests/post/wpUniquePostSlug.php index b19d8591ae..6d279bbbd5 100644 --- a/tests/phpunit/tests/post/wpUniquePostSlug.php +++ b/tests/phpunit/tests/post/wpUniquePostSlug.php @@ -92,7 +92,7 @@ class Tests_Post_wpUniquePostSlug extends WP_UnitTestCase { /** * @ticket 18962 */ - function test_wp_unique_post_slug_with_hierarchy_and_attachments() { + public function test_wp_unique_post_slug_with_hierarchy_and_attachments() { register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); $args = array( diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php index 4032c62571..8dfd3fb200 100644 --- a/tests/phpunit/tests/query.php +++ b/tests/phpunit/tests/query.php @@ -2,7 +2,7 @@ class Tests_Query extends WP_UnitTestCase { - function set_up() { + public function set_up() { parent::set_up(); $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); @@ -12,7 +12,7 @@ class Tests_Query extends WP_UnitTestCase { /** * @ticket 24785 */ - function test_nested_loop_reset_postdata() { + public function test_nested_loop_reset_postdata() { $post_id = self::factory()->post->create(); $nested_post_id = self::factory()->post->create(); @@ -32,7 +32,7 @@ class Tests_Query extends WP_UnitTestCase { /** * @ticket 16471 */ - function test_default_query_var() { + public function test_default_query_var() { $query = new WP_Query; $this->assertSame( '', $query->get( 'nonexistent' ) ); $this->assertFalse( $query->get( 'nonexistent', false ) ); @@ -42,7 +42,7 @@ class Tests_Query extends WP_UnitTestCase { /** * @ticket 25380 */ - function test_pre_posts_per_page() { + public function test_pre_posts_per_page() { self::factory()->post->create_many( 10 ); add_action( 'pre_get_posts', array( $this, 'filter_posts_per_page' ) ); @@ -52,19 +52,19 @@ class Tests_Query extends WP_UnitTestCase { $this->assertSame( 30, get_query_var( 'posts_per_page' ) ); } - function filter_posts_per_page( &$query ) { + public function filter_posts_per_page( &$query ) { $query->set( 'posts_per_rss', 30 ); } /** * @ticket 26627 */ - function test_tag_queried_object() { + public function test_tag_queried_object() { $slug = 'tag-slug-26627'; self::factory()->tag->create( array( 'slug' => $slug ) ); $tag = get_term_by( 'slug', $slug, 'post_tag' ); - add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); + add_action( 'pre_get_posts', array( $this, 'tag_queried_object' ), 11 ); $this->go_to( get_term_link( $tag ) ); @@ -75,10 +75,10 @@ class Tests_Query extends WP_UnitTestCase { $this->assertCount( 1, get_query_var( 'tag_slug__in' ) ); $this->assertEquals( get_queried_object(), $tag ); - remove_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); + remove_action( 'pre_get_posts', array( $this, 'tag_queried_object' ), 11 ); } - function _tag_queried_object( &$query ) { + public function tag_queried_object( &$query ) { $tag = get_term_by( 'slug', 'tag-slug-26627', 'post_tag' ); $this->assertTrue( $query->is_tag() ); $this->assertTrue( $query->is_archive() ); diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 46f6b9e285..4ef661b21a 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -14,7 +14,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { protected $page_ids; protected $post_ids; - function set_up() { + public function set_up() { parent::set_up(); update_option( 'comments_per_page', 5 ); @@ -25,12 +25,12 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { create_initial_taxonomies(); } - function test_home() { + public function test_home() { $this->go_to( '/' ); $this->assertQueryTrue( 'is_home', 'is_front_page' ); } - function test_page_on_front() { + public function test_page_on_front() { $page_on_front = self::factory()->post->create( array( 'post_type' => 'page', @@ -56,18 +56,18 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { delete_option( 'page_for_posts' ); } - function test_404() { + public function test_404() { $this->go_to( '/notapage' ); $this->assertQueryTrue( 'is_404' ); } - function test_permalink() { + public function test_permalink() { $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); $this->go_to( get_permalink( $post_id ) ); $this->assertQueryTrue( 'is_single', 'is_singular' ); } - function test_post_comments_feed() { + public function test_post_comments_feed() { $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); self::factory()->comment->create_post_comments( $post_id, 2 ); $this->go_to( get_post_comments_feed_link( $post_id ) ); @@ -75,20 +75,20 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } - function test_post_comments_feed_with_no_comments() { + public function test_post_comments_feed_with_no_comments() { $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); $this->go_to( get_post_comments_feed_link( $post_id ) ); $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed' ); } - function test_attachment_comments_feed() { + public function test_attachment_comments_feed() { $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); self::factory()->comment->create_post_comments( $attachment_id, 2 ); $this->go_to( get_post_comments_feed_link( $attachment_id ) ); $this->assertQueryTrue( 'is_feed', 'is_attachment', 'is_single', 'is_singular', 'is_comment_feed' ); } - function test_page() { + public function test_page() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -99,7 +99,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertQueryTrue( 'is_page', 'is_singular' ); } - function test_parent_page() { + public function test_parent_page() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -111,7 +111,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertQueryTrue( 'is_page', 'is_singular' ); } - function test_child_page_1() { + public function test_child_page_1() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -130,7 +130,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertQueryTrue( 'is_page', 'is_singular' ); } - function test_child_page_2() { + public function test_child_page_2() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -157,7 +157,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1' - function test_page_trackback() { + public function test_page_trackback() { $page_ids = array(); $page_id = self::factory()->post->create( array( @@ -195,7 +195,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' - function test_page_feed() { + public function test_page_feed() { $page_ids = array(); $page_id = self::factory()->post->create( array( @@ -233,7 +233,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } } - function test_page_feed_with_no_comments() { + public function test_page_feed_with_no_comments() { $page_ids = array(); $page_id = self::factory()->post->create( array( @@ -271,7 +271,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' - function test_page_feed_atom() { + public function test_page_feed_atom() { $page_ids = array(); $page_id = self::factory()->post->create( array( @@ -311,7 +311,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' - function test_page_page_2() { + public function test_page_page_2() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -330,7 +330,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' - function test_page_page_2_no_slash() { + public function test_page_page_2_no_slash() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -349,7 +349,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' - function test_pagination_of_posts_page() { + public function test_pagination_of_posts_page() { $page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -380,7 +380,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', // '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', - function test_main_feed_2() { + public function test_main_feed_2() { self::factory()->post->create(); // @test_404 $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); @@ -398,7 +398,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } - function test_main_feed() { + public function test_main_feed() { self::factory()->post->create(); // @test_404 $types = array( 'rss2', 'rss', 'atom' ); foreach ( $types as $type ) { @@ -408,7 +408,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', - function test_paged() { + public function test_paged() { update_option( 'posts_per_page', 2 ); self::factory()->post->create_many( 5 ); for ( $i = 2; $i <= 3; $i++ ) { @@ -419,7 +419,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', // 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', - function test_main_comments_feed() { + public function test_main_comments_feed() { $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); self::factory()->comment->create_post_comments( $post_id, 2 ); @@ -445,7 +445,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', // 'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', - function test_search_feed() { + public function test_search_feed() { // Check the long form. $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); foreach ( $types as $type ) { @@ -462,7 +462,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', - function test_search_paged() { + public function test_search_paged() { update_option( 'posts_per_page', 2 ); self::factory()->post->create_many( 3, array( 'post_title' => 'test' ) ); $this->go_to( '/search/test/page/2/' ); @@ -470,7 +470,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'search/(.+)/?$' => 'index.php?s=$matches[1]', - function test_search() { + public function test_search() { $this->go_to( '/search/test/' ); $this->assertQueryTrue( 'is_search' ); } @@ -478,14 +478,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 13961 */ - function test_search_encoded_chars() { + public function test_search_encoded_chars() { $this->go_to( '/search/F%C3%BCnf%2Bbar/' ); $this->assertSame( get_query_var( 's' ), 'Fünf+bar' ); } // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', - function test_category_feed() { + public function test_category_feed() { self::factory()->term->create( array( 'name' => 'cat-a', @@ -509,7 +509,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', - function test_category_paged() { + public function test_category_paged() { update_option( 'posts_per_page', 2 ); self::factory()->post->create_many( 3 ); $this->go_to( '/category/uncategorized/page/2/' ); @@ -517,7 +517,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', - function test_category() { + public function test_category() { self::factory()->term->create( array( 'name' => 'cat-a', @@ -530,7 +530,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', - function test_tag_feed() { + public function test_tag_feed() { self::factory()->term->create( array( 'name' => 'tag-a', @@ -553,7 +553,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', - function test_tag_paged() { + public function test_tag_paged() { update_option( 'posts_per_page', 2 ); $post_ids = self::factory()->post->create_many( 3 ); foreach ( $post_ids as $post_id ) { @@ -564,7 +564,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]', - function test_tag() { + public function test_tag() { $term_id = self::factory()->term->create( array( 'name' => 'Tag Named A', @@ -589,7 +589,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', - function test_author_feed() { + public function test_author_feed() { self::factory()->user->create( array( 'user_login' => 'user-a' ) ); // Check the long form. $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); @@ -607,7 +607,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', - function test_author_paged() { + public function test_author_paged() { update_option( 'posts_per_page', 2 ); $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); self::factory()->post->create_many( 3, array( 'post_author' => $user_id ) ); @@ -616,14 +616,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]', - function test_author() { + public function test_author() { $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); self::factory()->post->create( array( 'post_author' => $user_id ) ); $this->go_to( '/author/user-a/' ); $this->assertQueryTrue( 'is_archive', 'is_author' ); } - function test_author_with_no_posts() { + public function test_author_with_no_posts() { $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); $this->go_to( '/author/user-a/' ); $this->assertQueryTrue( 'is_archive', 'is_author' ); @@ -631,7 +631,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', - function test_ymd_feed() { + public function test_ymd_feed() { self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); // Check the long form. $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); @@ -649,7 +649,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]', - function test_ymd_paged() { + public function test_ymd_paged() { update_option( 'posts_per_page', 2 ); self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to( '/2007/09/04/page/2/' ); @@ -657,7 +657,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', - function test_ymd() { + public function test_ymd() { self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to( '/2007/09/04/' ); $this->assertQueryTrue( 'is_archive', 'is_day', 'is_date' ); @@ -665,7 +665,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', - function test_ym_feed() { + public function test_ym_feed() { self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); // Check the long form. $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); @@ -683,7 +683,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', - function test_ym_paged() { + public function test_ym_paged() { update_option( 'posts_per_page', 2 ); self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to( '/2007/09/page/2/' ); @@ -691,7 +691,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]', - function test_ym() { + public function test_ym() { self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to( '/2007/09/' ); $this->assertQueryTrue( 'is_archive', 'is_date', 'is_month' ); @@ -699,7 +699,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', - function test_y_feed() { + public function test_y_feed() { self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); // Check the long form. $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); @@ -717,7 +717,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', - function test_y_paged() { + public function test_y_paged() { update_option( 'posts_per_page', 2 ); self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to( '/2007/page/2/' ); @@ -725,14 +725,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/?$' => 'index.php?year=$matches[1]', - function test_y() { + public function test_y() { self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); $this->go_to( '/2007/' ); $this->assertQueryTrue( 'is_archive', 'is_date', 'is_year' ); } // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', - function test_post_trackback() { + public function test_post_trackback() { $post_id = self::factory()->post->create(); $permalink = get_permalink( $post_id ); $this->go_to( "{$permalink}trackback/" ); @@ -741,7 +741,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', - function test_post_comment_feed() { + public function test_post_comment_feed() { $post_id = self::factory()->post->create(); $permalink = get_permalink( $post_id ); // Check the long form. @@ -760,7 +760,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', - function test_post_paged_short() { + public function test_post_paged_short() { $post_id = self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00', @@ -775,7 +775,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { } // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', - function test_post_attachment() { + public function test_post_attachment() { $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); $permalink = get_attachment_link( $post_id ); $this->go_to( $permalink ); @@ -793,7 +793,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @expectedIncorrectUsage WP_Date_Query */ - function test_bad_dates() { + public function test_bad_dates() { $this->go_to( '/2013/13/13/' ); $this->assertQueryTrue( 'is_404' ); @@ -801,7 +801,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertQueryTrue( 'is_404' ); } - function test_post_type_archive_with_tax_query() { + public function test_post_type_archive_with_tax_query() { delete_option( 'rewrite_rules' ); $cpt_name = 'ptawtq'; @@ -832,7 +832,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_tax_query' ) ); } - function pre_get_posts_with_tax_query( &$query ) { + public function pre_get_posts_with_tax_query( &$query ) { $term = get_term_by( 'slug', 'tag-slug', 'post_tag' ); $query->set( 'tax_query', @@ -846,7 +846,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { ); } - function test_post_type_array() { + public function test_post_type_array() { delete_option( 'rewrite_rules' ); $cpt_name = 'thearray'; @@ -874,11 +874,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) ); } - function pre_get_posts_with_type_array( &$query ) { + public function pre_get_posts_with_type_array( &$query ) { $query->set( 'post_type', array( 'post', 'thearray' ) ); } - function test_is_single() { + public function test_is_single() { $post_id = self::factory()->post->create(); $this->go_to( "/?p=$post_id" ); @@ -898,7 +898,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 16802 */ - function test_is_single_with_parent() { + public function test_is_single_with_parent() { // Use custom hierarchical post type. $post_type = 'test_hierarchical'; @@ -1005,7 +1005,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 38225 */ - function test_is_single_with_attachment() { + public function test_is_single_with_attachment() { $post_id = self::factory()->post->create(); $attachment_id = self::factory()->attachment->create_object( @@ -1025,7 +1025,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertTrue( $q->is_attachment ); } - function test_is_page() { + public function test_is_page() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); $this->go_to( "/?page_id=$post_id" ); @@ -1045,7 +1045,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 16802 */ - function test_is_page_with_parent() { + public function test_is_page_with_parent() { $parent_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -1079,7 +1079,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertFalse( is_page( 'foo' ) ); } - function test_is_attachment() { + public function test_is_attachment() { $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); $this->go_to( "/?attachment_id=$post_id" ); @@ -1236,7 +1236,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->assertFalse( $q->is_page( $p2 ) ); } - function test_is_page_template() { + public function test_is_page_template() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); update_post_meta( $post_id, '_wp_page_template', 'example.php' ); $this->go_to( "/?page_id=$post_id" ); @@ -1246,7 +1246,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 31271 */ - function test_is_page_template_default() { + public function test_is_page_template_default() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); $this->go_to( "/?page_id=$post_id" ); $this->assertTrue( is_page_template( 'default' ) ); @@ -1256,7 +1256,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 31271 */ - function test_is_page_template_array() { + public function test_is_page_template_array() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); update_post_meta( $post_id, '_wp_page_template', 'example.php' ); $this->go_to( "/?page_id=$post_id" ); @@ -1267,7 +1267,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 18375 */ - function test_is_page_template_other_post_type() { + public function test_is_page_template_other_post_type() { $post_id = self::factory()->post->create( array( 'post_type' => 'post' ) ); update_post_meta( $post_id, '_wp_page_template', 'example.php' ); $this->go_to( get_post_permalink( $post_id ) ); @@ -1278,7 +1278,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { /** * @ticket 39211 */ - function test_is_page_template_not_singular() { + public function test_is_page_template_not_singular() { global $wpdb; // We need a non-post that shares an ID with a post assigned a template. diff --git a/tests/phpunit/tests/query/isTerm.php b/tests/phpunit/tests/query/isTerm.php index 23b00d34a5..0527201ce2 100644 --- a/tests/phpunit/tests/query/isTerm.php +++ b/tests/phpunit/tests/query/isTerm.php @@ -22,7 +22,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { protected $tag; protected $tax; - function set_up() { + public function set_up() { parent::set_up(); $GLOBALS['wp_the_query'] = new WP_Query(); @@ -63,7 +63,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { add_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); } - function test_tag_action_tax() { + public function test_tag_action_tax() { // Tag with taxonomy added. $this->go_to( home_url( '/tag/tag-slug/' ) ); $this->assertQueryTrue( 'is_tag', 'is_archive' ); @@ -74,7 +74,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertEquals( get_queried_object(), $this->tag ); } - function test_tag_query_cat_action_tax() { + public function test_tag_query_cat_action_tax() { // Tag + category with taxonomy added. $this->go_to( home_url( "/tag/tag-slug/?cat=$this->cat_id" ) ); $this->assertQueryTrue( 'is_category', 'is_tag', 'is_archive' ); @@ -86,7 +86,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertEquals( get_queried_object(), $this->cat ); } - function test_tag_query_cat_query_tax_action_tax() { + public function test_tag_query_cat_query_tax_action_tax() { // Tag + category + tax with taxonomy added. $this->go_to( home_url( "/tag/tag-slug/?cat=$this->cat_id&testtax=tax-slug2" ) ); $this->assertQueryTrue( 'is_category', 'is_tag', 'is_tax', 'is_archive' ); @@ -99,7 +99,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertEquals( get_queried_object(), $this->cat ); } - function test_cat_action_tax() { + public function test_cat_action_tax() { // Category with taxonomy added. $this->go_to( home_url( '/category/cat-slug/' ) ); $this->assertQueryTrue( 'is_category', 'is_archive' ); @@ -113,9 +113,9 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { /** * @ticket 26627 */ - function test_cat_uncat_action_tax() { + public function test_cat_uncat_action_tax() { // Category with taxonomy added. - add_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 ); + add_action( 'pre_get_posts', array( $this, 'cat_uncat_action_tax' ), 11 ); $this->go_to( home_url( '/category/uncategorized/' ) ); $this->assertQueryTrue( 'is_category', 'is_archive' ); @@ -125,10 +125,10 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertNotEmpty( get_query_var( 'term_id' ) ); $this->assertEquals( get_queried_object(), $this->uncat ); - remove_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 ); + remove_action( 'pre_get_posts', array( $this, 'cat_uncat_action_tax' ), 11 ); } - function _cat_uncat_action_tax( &$query ) { + public function cat_uncat_action_tax( &$query ) { $this->assertTrue( $query->is_category() ); $this->assertTrue( $query->is_archive() ); $this->assertNotEmpty( $query->get( 'category_name' ) ); @@ -139,7 +139,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { /** * @ticket 26728 */ - function test_tax_action_tax() { + public function test_tax_action_tax() { // Taxonomy with taxonomy added. $this->go_to( home_url( '/testtax/tax-slug2/' ) ); $this->assertQueryTrue( 'is_tax', 'is_archive' ); @@ -149,7 +149,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertEquals( get_queried_object(), get_term( $this->tax_id, 'testtax' ) ); } - function test_tax_query_tag_action_tax() { + public function test_tax_query_tag_action_tax() { // Taxonomy + tag with taxonomy added. $this->go_to( home_url( "/testtax/tax-slug2/?tag_id=$this->tag_id" ) ); $this->assertQueryTrue( 'is_tag', 'is_tax', 'is_archive' ); @@ -160,7 +160,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertEquals( get_queried_object(), $this->tag ); } - function test_tax_query_cat_action_tax() { + public function test_tax_query_cat_action_tax() { // Taxonomy + category with taxonomy added. $this->go_to( home_url( "/testtax/tax-slug2/?cat=$this->cat_id" ) ); $this->assertQueryTrue( 'is_category', 'is_tax', 'is_archive' ); @@ -171,7 +171,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $this->assertEquals( get_queried_object(), $this->cat ); } - function pre_get_posts_tax_category_tax_query( &$query ) { + public function pre_get_posts_tax_category_tax_query( &$query ) { $query->set( 'tax_query', array( diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index 1a690b49f3..bf653d378a 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -294,14 +294,14 @@ class Tests_Query_Results extends WP_UnitTestCase { self::$post_ids[] = self::$child_four; } - function set_up() { + public function set_up() { parent::set_up(); unset( $this->q ); $this->q = new WP_Query(); } - function test_query_default() { + public function test_query_default() { $posts = $this->q->query( '' ); // The output should be the most recent 10 posts as listed here. @@ -321,7 +321,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } - function test_query_tag_a() { + public function test_query_tag_a() { $posts = $this->q->query( 'tag=tag-a' ); // There are 4 posts with Tag A. @@ -332,7 +332,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( 'tags-a-b-c', $posts[3]->post_name ); } - function test_query_tag_b() { + public function test_query_tag_b() { $posts = $this->q->query( 'tag=tag-b' ); // There are 4 posts with Tag A. @@ -346,7 +346,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 21779 */ - function test_query_tag_nun() { + public function test_query_tag_nun() { $posts = $this->q->query( 'tag=tag-נ' ); // There is 1 post with Tag נ. @@ -354,7 +354,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( 'tag-%d7%a0', $posts[0]->post_name ); } - function test_query_tag_id() { + public function test_query_tag_id() { $tag = tag_exists( 'tag-a' ); $posts = $this->q->query( 'tag_id=' . $tag['term_id'] ); @@ -366,7 +366,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( 'tags-a-b-c', $posts[3]->post_name ); } - function test_query_tag_slug__in() { + public function test_query_tag_slug__in() { $posts = $this->q->query( 'tag_slug__in[]=tag-b&tag_slug__in[]=tag-c' ); // There are 4 posts with either Tag B or Tag C. @@ -380,7 +380,7 @@ class Tests_Query_Results extends WP_UnitTestCase { } - function test_query_tag__in() { + public function test_query_tag__in() { $tag_a = tag_exists( 'tag-a' ); $tag_b = tag_exists( 'tag-b' ); $posts = $this->q->query( 'tag__in[]=' . $tag_a['term_id'] . '&tag__in[]=' . $tag_b['term_id'] ); @@ -395,7 +395,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( 'tags-a-b-c', $posts[5]->post_name ); } - function test_query_tag__not_in() { + public function test_query_tag__not_in() { $tag_a = tag_exists( 'tag-a' ); $posts = $this->q->query( 'tag__not_in[]=' . $tag_a['term_id'] ); @@ -417,7 +417,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } - function test_query_tag__in_but__not_in() { + public function test_query_tag__in_but__not_in() { $tag_a = tag_exists( 'tag-a' ); $tag_b = tag_exists( 'tag-b' ); $posts = $this->q->query( 'tag__in[]=' . $tag_a['term_id'] . '&tag__not_in[]=' . $tag_b['term_id'] ); @@ -430,7 +430,7 @@ class Tests_Query_Results extends WP_UnitTestCase { - function test_query_category_name() { + public function test_query_category_name() { $posts = $this->q->query( 'category_name=cat-a' ); // There are 4 posts with Cat A, we'll check for them by name. @@ -441,7 +441,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( 'cats-a-b-c', $posts[3]->post_name ); } - function test_query_cat() { + public function test_query_cat() { $cat = category_exists( 'cat-b' ); $posts = $this->q->query( "cat=$cat" ); @@ -453,7 +453,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( 'cats-a-b-c', $posts[3]->post_name ); } - function test_query_posts_per_page() { + public function test_query_posts_per_page() { $posts = $this->q->query( 'posts_per_page=5' ); $expected = array( @@ -468,7 +468,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } - function test_query_offset() { + public function test_query_offset() { $posts = $this->q->query( 'offset=2' ); $expected = array( @@ -488,7 +488,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } - function test_query_paged() { + public function test_query_paged() { $posts = $this->q->query( 'paged=2' ); $expected = array( @@ -509,7 +509,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } - function test_query_paged_and_posts_per_page() { + public function test_query_paged_and_posts_per_page() { $posts = $this->q->query( 'paged=4&posts_per_page=4' ); $expected = array( @@ -527,7 +527,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 11056 */ - function test_query_post_parent__in() { + public function test_query_post_parent__in() { // Query for first parent's children. $posts = $this->q->query( array( @@ -594,7 +594,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 11056 */ - function test_query_orderby_post_parent__in() { + public function test_query_orderby_post_parent__in() { $posts = $this->q->query( array( 'post_parent__in' => array( self::$parent_two, self::$parent_one ), @@ -617,7 +617,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 39055 */ - function test_query_orderby_post_parent__in_with_order_desc() { + public function test_query_orderby_post_parent__in_with_order_desc() { $post_parent__in_array = array( self::$parent_two, self::$parent_one ); $expected_returned_array = array( 'child-three', 'child-four', 'child-one', 'child-two' ); @@ -636,7 +636,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 39055 */ - function test_query_orderby_post__in_with_no_order_specified() { + public function test_query_orderby_post__in_with_no_order_specified() { $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); @@ -655,7 +655,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 39055 */ - function test_query_orderby_post__in_with_order_asc() { + public function test_query_orderby_post__in_with_order_asc() { $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] ); @@ -675,7 +675,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 39055 */ - function test_query_orderby_post__in_with_order_desc() { + public function test_query_orderby_post__in_with_order_desc() { $post__in_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] ); $expected_returned_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] ); @@ -696,7 +696,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 39055 */ - function test_query_orderby_post_name__in_with_order_asc() { + public function test_query_orderby_post_name__in_with_order_asc() { $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' ); $q = new WP_Query( @@ -713,7 +713,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 39055 */ - function test_query_orderby_post_name__in_with_order_desc() { + public function test_query_orderby_post_name__in_with_order_desc() { $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' ); $q = new WP_Query( @@ -732,7 +732,7 @@ class Tests_Query_Results extends WP_UnitTestCase { * @ticket 27252 * @ticket 31194 */ - function test_query_fields_integers() { + public function test_query_fields_integers() { $parents = array( (int) self::$parent_one, @@ -774,7 +774,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 28099 */ - function test_empty_post__in() { + public function test_empty_post__in() { $posts1 = $this->q->query( array() ); $this->assertNotEmpty( $posts1 ); $posts2 = $this->q->query( array( 'post__in' => array() ) ); @@ -786,7 +786,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 19198 */ - function test_exclude_from_search_empty() { + public function test_exclude_from_search_empty() { global $wp_post_types; foreach ( array_keys( $wp_post_types ) as $slug ) { $wp_post_types[ $slug ]->exclude_from_search = true; @@ -810,7 +810,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 16854 */ - function test_query_author_vars() { + public function test_query_author_vars() { $author_1 = self::factory()->user->create( array( 'user_login' => 'author1', @@ -982,7 +982,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 10935 */ - function test_query_is_date() { + public function test_query_is_date() { $this->q->query( array( 'year' => '2007', @@ -1040,7 +1040,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertFalse( $this->q->is_year ); } - function test_perm_with_status_array() { + public function test_perm_with_status_array() { global $wpdb; $this->q->query( array( @@ -1059,7 +1059,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 20308 */ - function test_post_password() { + public function test_post_password() { $one = (string) self::factory()->post->create( array( 'post_password' => '' ) ); $two = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) ); $three = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) ); @@ -1150,7 +1150,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 28611 */ - function test_duplicate_slug_in_hierarchical_post_type() { + public function test_duplicate_slug_in_hierarchical_post_type() { register_post_type( 'handbook', array( 'hierarchical' => true ) ); $post_1 = self::factory()->post->create( @@ -1185,7 +1185,7 @@ class Tests_Query_Results extends WP_UnitTestCase { /** * @ticket 29615 */ - function test_child_post_in_hierarchical_post_type_with_default_permalinks() { + public function test_child_post_in_hierarchical_post_type_with_default_permalinks() { register_post_type( 'handbook', array( 'hierarchical' => true ) ); $post_1 = self::factory()->post->create( @@ -1213,7 +1213,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertCount( 1, $result ); } - function test_title() { + public function test_title() { $title = 'Tacos are Cool'; $post_id = self::factory()->post->create( array( diff --git a/tests/phpunit/tests/query/search.php b/tests/phpunit/tests/query/search.php index 1cc35f4a21..2beda65d2f 100644 --- a/tests/phpunit/tests/query/search.php +++ b/tests/phpunit/tests/query/search.php @@ -7,7 +7,7 @@ class Tests_Query_Search extends WP_UnitTestCase { protected $q; protected $post_type; - function set_up() { + public function set_up() { parent::set_up(); $this->post_type = rand_str( 12 ); @@ -16,13 +16,13 @@ class Tests_Query_Search extends WP_UnitTestCase { $this->q = new WP_Query(); } - function tear_down() { + public function tear_down() { unset( $this->q ); parent::tear_down(); } - function get_search_results( $terms ) { + private function get_search_results( $terms ) { $args = http_build_query( array( 's' => $terms, @@ -32,7 +32,7 @@ class Tests_Query_Search extends WP_UnitTestCase { return $this->q->query( $args ); } - function test_search_order_title_relevance() { + public function test_search_order_title_relevance() { foreach ( range( 1, 7 ) as $i ) { self::factory()->post->create( array( @@ -52,14 +52,14 @@ class Tests_Query_Search extends WP_UnitTestCase { $this->assertSame( $post_id, reset( $posts )->ID ); } - function test_search_terms_query_var() { + public function test_search_terms_query_var() { $terms = 'This is a search term'; $query = new WP_Query( array( 's' => 'This is a search term' ) ); $this->assertNotEquals( explode( ' ', $terms ), $query->get( 'search_terms' ) ); $this->assertSame( array( 'search', 'term' ), $query->get( 'search_terms' ) ); } - function test_filter_stopwords() { + public function test_filter_stopwords() { $terms = 'This is a search term'; add_filter( 'wp_search_stopwords', array( $this, 'filter_wp_search_stopwords' ) ); $query = new WP_Query( array( 's' => $terms ) ); @@ -69,14 +69,14 @@ class Tests_Query_Search extends WP_UnitTestCase { $this->assertSame( array( 'This', 'is', 'search', 'term' ), $query->get( 'search_terms' ) ); } - function filter_wp_search_stopwords() { + public function filter_wp_search_stopwords() { return array(); } /** * @ticket 38099 */ - function test_disable_search_exclusion_prefix() { + public function test_disable_search_exclusion_prefix() { $title = '-HYPHENATION_TEST'; // Create a post with a title which starts with a hyphen. @@ -101,7 +101,7 @@ class Tests_Query_Search extends WP_UnitTestCase { /** * @ticket 38099 */ - function test_change_search_exclusion_prefix() { + public function test_change_search_exclusion_prefix() { $title = '#OCTOTHORPE_TEST'; // Create a post with a title that starts with a non-hyphen prefix. @@ -124,7 +124,7 @@ class Tests_Query_Search extends WP_UnitTestCase { $this->assertSame( array(), $found ); } - function filter_search_exclusion_prefix_octothorpe() { + public function filter_search_exclusion_prefix_octothorpe() { return '#'; } diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index cc8f6b81c1..cabfba7c5b 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -387,7 +387,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { * setup_postdata( $a_post ) followed by the_content() without updating global $post * should use the content of $a_post rather then the global post. */ - function test_setup_postdata_with_the_content() { + public function test_setup_postdata_with_the_content() { $post_id = self::factory()->post->create( array( 'post_content' => 'global post' ) ); $GLOBALS['post'] = get_post( $post_id ); $GLOBALS['wp_query']->post = $GLOBALS['post']; diff --git a/tests/phpunit/tests/query/verboseRewriteRules.php b/tests/phpunit/tests/query/verboseRewriteRules.php index c7f7c057b8..59ee240131 100644 --- a/tests/phpunit/tests/query/verboseRewriteRules.php +++ b/tests/phpunit/tests/query/verboseRewriteRules.php @@ -7,7 +7,7 @@ require_once __DIR__ . '/conditionals.php'; * @group rewrite */ class Tests_Query_VerbosePageRules extends Tests_Query_Conditionals { - function set_up() { + public function set_up() { parent::set_up(); $this->set_permalink_structure( '/%category%/%year%/%postname%/' ); diff --git a/tests/phpunit/tests/rest-api.php b/tests/phpunit/tests/rest-api.php index 34b414903d..acc0e7110c 100644 --- a/tests/phpunit/tests/rest-api.php +++ b/tests/phpunit/tests/rest-api.php @@ -30,7 +30,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * Checks that the main classes are loaded. */ - function test_rest_api_active() { + public function test_rest_api_active() { $this->assertTrue( class_exists( 'WP_REST_Server' ) ); $this->assertTrue( class_exists( 'WP_REST_Request' ) ); $this->assertTrue( class_exists( 'WP_REST_Response' ) ); @@ -41,7 +41,7 @@ class Tests_REST_API extends WP_UnitTestCase { * The rest_api_init hook should have been registered with init, and should * have a default priority of 10. */ - function test_init_action_added() { + public function test_init_action_added() { $this->assertSame( 10, has_action( 'init', 'rest_api_init' ) ); } @@ -263,7 +263,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * The rest_route query variable should be registered. */ - function test_rest_route_query_var() { + public function test_rest_route_query_var() { rest_api_init(); $this->assertContains( 'rest_route', $GLOBALS['wp']->public_query_vars ); } @@ -933,7 +933,7 @@ class Tests_REST_API extends WP_UnitTestCase { $this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); } - function test_rest_preload_api_request_with_method() { + public function test_rest_preload_api_request_with_method() { $rest_server = $GLOBALS['wp_rest_server']; $GLOBALS['wp_rest_server'] = null; @@ -957,7 +957,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 51636 */ - function test_rest_preload_api_request_removes_trailing_slashes() { + public function test_rest_preload_api_request_removes_trailing_slashes() { $rest_server = $GLOBALS['wp_rest_server']; $GLOBALS['wp_rest_server'] = null; @@ -982,7 +982,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 40614 */ - function test_rest_ensure_request_accepts_path_string() { + public function test_rest_ensure_request_accepts_path_string() { $request = rest_ensure_request( '/wp/v2/posts' ); $this->assertInstanceOf( 'WP_REST_Request', $request ); $this->assertSame( '/wp/v2/posts', $request->get_route() ); @@ -990,13 +990,13 @@ class Tests_REST_API extends WP_UnitTestCase { } /** - * @dataProvider _dp_rest_parse_embed_param + * @dataProvider data_rest_parse_embed_param */ public function test_rest_parse_embed_param( $expected, $embed ) { $this->assertSame( $expected, rest_parse_embed_param( $embed ) ); } - public function _dp_rest_parse_embed_param() { + public function data_rest_parse_embed_param() { return array( array( true, '' ), array( true, null ), @@ -1019,7 +1019,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 48819 * - * @dataProvider _dp_rest_filter_response_by_context + * @dataProvider data_rest_filter_response_by_context */ public function test_rest_filter_response_by_context( $schema, $data, $expected ) { $this->assertSame( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) ); @@ -1106,7 +1106,7 @@ class Tests_REST_API extends WP_UnitTestCase { $this->assertTrue( $registered ); } - public function _dp_rest_filter_response_by_context() { + public function data_rest_filter_response_by_context() { return array( 'default' => array( array( @@ -1777,7 +1777,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); } - function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() { + public function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() { $response = rest_ensure_response( new WP_Error() ); $this->assertInstanceOf( 'WP_Error', $response ); } @@ -1788,7 +1788,7 @@ class Tests_REST_API extends WP_UnitTestCase { * @param mixed $response The response passed to rest_ensure_response(). * @param mixed $expected_data The expected data a response should include. */ - function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) { + public function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) { $response_object = rest_ensure_response( $response ); $this->assertInstanceOf( 'WP_REST_Response', $response_object ); $this->assertSame( $expected_data, $response_object->get_data() ); @@ -1799,7 +1799,7 @@ class Tests_REST_API extends WP_UnitTestCase { * * @return array */ - function rest_ensure_response_data_provider() { + public function rest_ensure_response_data_provider() { return array( array( null, null ), array( array( 'chocolate' => 'cookies' ), array( 'chocolate' => 'cookies' ) ), @@ -2009,7 +2009,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 50300 * - * @dataProvider _dp_rest_is_object + * @dataProvider data_rest_is_object * * @param bool $expected Expected result of the check. * @param mixed $value The value to check. @@ -2024,7 +2024,7 @@ class Tests_REST_API extends WP_UnitTestCase { } } - public function _dp_rest_is_object() { + public function data_rest_is_object() { return array( array( true, @@ -2072,7 +2072,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 50300 * - * @dataProvider _dp_rest_sanitize_object + * @dataProvider data_rest_sanitize_object * * @param array $expected Expected sanitized version. * @param mixed $value The value to sanitize. @@ -2082,7 +2082,7 @@ class Tests_REST_API extends WP_UnitTestCase { $this->assertSame( $expected, $sanitized ); } - public function _dp_rest_sanitize_object() { + public function data_rest_sanitize_object() { return array( array( array(), @@ -2130,7 +2130,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 50300 * - * @dataProvider _dp_rest_is_array + * @dataProvider data_rest_is_array * * @param bool $expected Expected result of the check. * @param mixed $value The value to check. @@ -2145,7 +2145,7 @@ class Tests_REST_API extends WP_UnitTestCase { } } - public function _dp_rest_is_array() { + public function data_rest_is_array() { return array( array( true, @@ -2201,7 +2201,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 50300 * - * @dataProvider _dp_rest_sanitize_array + * @dataProvider data_rest_sanitize_array * * @param array $expected Expected sanitized version. * @param mixed $value The value to sanitize. @@ -2211,7 +2211,7 @@ class Tests_REST_API extends WP_UnitTestCase { $this->assertSame( $expected, $sanitized ); } - public function _dp_rest_sanitize_array() { + public function data_rest_sanitize_array() { return array( array( array(), @@ -2271,7 +2271,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 51146 * - * @dataProvider _dp_rest_is_integer + * @dataProvider data_rest_is_integer * * @param bool $expected Expected result of the check. * @param mixed $value The value to check. @@ -2286,7 +2286,7 @@ class Tests_REST_API extends WP_UnitTestCase { } } - public function _dp_rest_is_integer() { + public function data_rest_is_integer() { return array( array( true, @@ -2334,7 +2334,7 @@ class Tests_REST_API extends WP_UnitTestCase { /** * @ticket 50300 * - * @dataProvider _dp_get_best_type_for_value + * @dataProvider data_get_best_type_for_value * * @param string $expected The expected best type. * @param mixed $value The value to test. @@ -2344,7 +2344,7 @@ class Tests_REST_API extends WP_UnitTestCase { $this->assertSame( $expected, rest_get_best_type_for_value( $value, $types ) ); } - public function _dp_get_best_type_for_value() { + public function data_get_best_type_for_value() { return array( array( 'array', diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 478148ed56..c3f620c8cc 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -1278,7 +1278,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } } - function get_illegal_user_logins() { + public function get_illegal_user_logins() { return array( 'nope' ); } diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 8f54a0dc89..62697800cc 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -8,7 +8,7 @@ class Tests_Rewrite extends WP_UnitTestCase { private $home_url; - function set_up() { + public function set_up() { parent::set_up(); $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); @@ -17,7 +17,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->home_url = get_option( 'home' ); } - function tear_down() { + public function tear_down() { global $wp_rewrite; $wp_rewrite->init(); @@ -85,7 +85,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertStringContainsString( $redirect, $extra_rules_top[ $pattern ] ); } - function test_url_to_postid() { + public function test_url_to_postid() { $id = self::factory()->post->create(); $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); @@ -94,7 +94,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } - function test_url_to_postid_set_url_scheme_https_to_http() { + public function test_url_to_postid_set_url_scheme_https_to_http() { $post_id = self::factory()->post->create(); $permalink = get_permalink( $post_id ); $this->assertSame( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); @@ -104,7 +104,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertSame( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); } - function test_url_to_postid_set_url_scheme_http_to_https() { + public function test_url_to_postid_set_url_scheme_http_to_https() { $_SERVER['HTTPS'] = 'on'; $post_id = self::factory()->post->create(); @@ -124,13 +124,13 @@ class Tests_Rewrite extends WP_UnitTestCase { * @group multisite * @group ms-required */ - function test_url_to_postid_of_http_site_when_current_site_uses_https() { + public function test_url_to_postid_of_http_site_when_current_site_uses_https() { $_SERVER['HTTPS'] = 'on'; $network_home = home_url(); $this->blog_id_35531 = self::factory()->blog->create(); - add_filter( 'home_url', array( $this, '_filter_http_home_url' ), 10, 4 ); + add_filter( 'home_url', array( $this, 'filter_http_home_url' ), 10, 4 ); switch_to_blog( $this->blog_id_35531 ); @@ -141,7 +141,7 @@ class Tests_Rewrite extends WP_UnitTestCase { restore_current_blog(); // Cleanup. - remove_filter( 'home_url', array( $this, '_filter_http_home_url' ), 10 ); + remove_filter( 'home_url', array( $this, 'filter_http_home_url' ), 10 ); // Test the tests. $this->assertSame( 'http', parse_url( $permalink, PHP_URL_SCHEME ) ); @@ -160,7 +160,7 @@ class Tests_Rewrite extends WP_UnitTestCase { * @param int|null $blog_id Site ID, or null for the current site. * @return string The complete home URL including scheme and path. */ - function _filter_http_home_url( $url, $path, $orig_scheme, $_blog_id ) { + public function filter_http_home_url( $url, $path, $orig_scheme, $_blog_id ) { global $blog_id; if ( $this->blog_id_35531 === $blog_id ) { @@ -170,7 +170,7 @@ class Tests_Rewrite extends WP_UnitTestCase { return $url; } - function test_url_to_postid_custom_post_type() { + public function test_url_to_postid_custom_post_type() { delete_option( 'rewrite_rules' ); $post_type = rand_str( 12 ); @@ -182,7 +182,7 @@ class Tests_Rewrite extends WP_UnitTestCase { _unregister_post_type( $post_type ); } - function test_url_to_postid_hierarchical() { + public function test_url_to_postid_hierarchical() { $parent_id = self::factory()->post->create( array( @@ -202,7 +202,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertSame( $child_id, url_to_postid( get_permalink( $child_id ) ) ); } - function test_url_to_postid_hierarchical_with_matching_leaves() { + public function test_url_to_postid_hierarchical_with_matching_leaves() { $parent_id = self::factory()->post->create( array( @@ -245,7 +245,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertSame( $grandchild_id_2, url_to_postid( get_permalink( $grandchild_id_2 ) ) ); } - function test_url_to_postid_home_has_path() { + public function test_url_to_postid_home_has_path() { update_option( 'home', home_url( '/example/' ) ); @@ -271,7 +271,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * @ticket 30438 */ - function test_parse_request_home_path() { + public function test_parse_request_home_path() { $home_url = home_url( '/path/' ); update_option( 'home', $home_url ); @@ -291,7 +291,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * @ticket 30438 */ - function test_parse_request_home_path_with_regex_character() { + public function test_parse_request_home_path_with_regex_character() { $home_url = home_url( '/ma.ch/' ); $not_a_home_url = home_url( '/match/' ); update_option( 'home', $home_url ); @@ -328,7 +328,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * @ticket 30018 */ - function test_parse_request_home_path_non_public_type() { + public function test_parse_request_home_path_non_public_type() { register_post_type( 'foo', array( 'public' => false ) ); $url = add_query_arg( 'foo', '1', home_url() ); @@ -340,7 +340,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertSame( array(), $GLOBALS['wp']->query_vars ); } - function test_url_to_postid_dupe_path() { + public function test_url_to_postid_dupe_path() { update_option( 'home', home_url( '/example/' ) ); $id = self::factory()->post->create( @@ -360,7 +360,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * Reveals bug introduced in WP 3.0 */ - function test_url_to_postid_home_url_collision() { + public function test_url_to_postid_home_url_collision() { update_option( 'home', home_url( '/example' ) ); self::factory()->post->create( @@ -381,7 +381,7 @@ class Tests_Rewrite extends WP_UnitTestCase { * * @group ms-required */ - function test_url_to_postid_ms_home_url_collision() { + public function test_url_to_postid_ms_home_url_collision() { $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) ); switch_to_blog( $blog_id ); @@ -402,7 +402,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * @ticket 21970 */ - function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() { + public function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() { $this->set_permalink_structure( '/%postname%/' ); $page_id = self::factory()->post->create( @@ -419,7 +419,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * @ticket 34971 */ - function test_url_to_postid_static_front_page() { + public function test_url_to_postid_static_front_page() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); $this->assertSame( 0, url_to_postid( home_url() ) ); @@ -453,7 +453,7 @@ class Tests_Rewrite extends WP_UnitTestCase { /** * @ticket 21970 */ - function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() { + public function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() { $this->set_permalink_structure( '/%postname%/' ); $page_id = self::factory()->post->create( diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php index 479f6d059a..ce0b3f858d 100644 --- a/tests/phpunit/tests/shortcode.php +++ b/tests/phpunit/tests/shortcode.php @@ -6,11 +6,11 @@ class Tests_Shortcode extends WP_UnitTestCase { protected $shortcodes = array( 'test-shortcode-tag', 'footag', 'bartag', 'baztag', 'dumptag', 'hyphen', 'hyphen-foo', 'hyphen-foo-bar', 'url', 'img' ); - function set_up() { + public function set_up() { parent::set_up(); foreach ( $this->shortcodes as $shortcode ) { - add_shortcode( $shortcode, array( $this, '_shortcode_' . str_replace( '-', '_', $shortcode ) ) ); + add_shortcode( $shortcode, array( $this, 'shortcode_' . str_replace( '-', '_', $shortcode ) ) ); } $this->atts = null; @@ -19,7 +19,7 @@ class Tests_Shortcode extends WP_UnitTestCase { } - function tear_down() { + public function tear_down() { global $shortcode_tags; foreach ( $this->shortcodes as $shortcode ) { unset( $shortcode_tags[ $shortcode ] ); @@ -27,7 +27,7 @@ class Tests_Shortcode extends WP_UnitTestCase { parent::tear_down(); } - function _shortcode_test_shortcode_tag( $atts, $content = null, $tagname = null ) { + public function shortcode_test_shortcode_tag( $atts, $content = null, $tagname = null ) { $this->atts = $atts; $this->content = $content; $this->tagname = $tagname; @@ -37,13 +37,13 @@ class Tests_Shortcode extends WP_UnitTestCase { } // [footag foo="bar"] - function _shortcode_footag( $atts ) { + public function shortcode_footag( $atts ) { $foo = isset( $atts['foo'] ) ? $atts['foo'] : ''; return "foo = $foo"; } // [bartag foo="bar"] - function _shortcode_bartag( $atts ) { + public function shortcode_bartag( $atts ) { $processed_atts = shortcode_atts( array( 'foo' => 'no foo', @@ -57,11 +57,11 @@ class Tests_Shortcode extends WP_UnitTestCase { } // [baztag]content[/baztag] - function _shortcode_baztag( $atts, $content = '' ) { + public function shortcode_baztag( $atts, $content = '' ) { return 'content = ' . do_shortcode( $content ); } - function _shortcode_dumptag( $atts ) { + public function shortcode_dumptag( $atts ) { $out = ''; foreach ( $atts as $k => $v ) { $out .= "$k = $v\n"; @@ -69,23 +69,23 @@ class Tests_Shortcode extends WP_UnitTestCase { return $out; } - function _shortcode_hyphen() { + public function shortcode_hyphen() { return __FUNCTION__; } - function _shortcode_hyphen_foo() { + public function shortcode_hyphen_foo() { return __FUNCTION__; } - function _shortcode_hyphen_foo_bar() { + public function shortcode_hyphen_foo_bar() { return __FUNCTION__; } - function _shortcode_url() { + public function shortcode_url() { return 'http://www.wordpress.org/'; } - function _shortcode_img( $atts ) { + public function shortcode_img( $atts ) { $out = ' $v ) { $out .= " $k=\"$v\""; @@ -95,19 +95,19 @@ class Tests_Shortcode extends WP_UnitTestCase { return $out; } - function test_noatts() { + public function test_noatts() { do_shortcode( '[test-shortcode-tag /]' ); $this->assertSame( '', $this->atts ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_one_att() { + public function test_one_att() { do_shortcode( '[test-shortcode-tag foo="asdf" /]' ); $this->assertSame( array( 'foo' => 'asdf' ), $this->atts ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_not_a_tag() { + public function test_not_a_tag() { $out = do_shortcode( '[not-a-shortcode-tag]' ); $this->assertSame( '[not-a-shortcode-tag]', $out ); } @@ -115,17 +115,17 @@ class Tests_Shortcode extends WP_UnitTestCase { /** * @ticket 17657 */ - function test_tag_hyphen_not_tag() { + public function test_tag_hyphen_not_tag() { $out = do_shortcode( '[dumptag-notreal]' ); $this->assertSame( '[dumptag-notreal]', $out ); } - function test_tag_underscore_not_tag() { + public function test_tag_underscore_not_tag() { $out = do_shortcode( '[dumptag_notreal]' ); $this->assertSame( '[dumptag_notreal]', $out ); } - function test_tag_not_tag() { + public function test_tag_not_tag() { $out = do_shortcode( '[dumptagnotreal]' ); $this->assertSame( '[dumptagnotreal]', $out ); } @@ -133,10 +133,10 @@ class Tests_Shortcode extends WP_UnitTestCase { /** * @ticket 17657 */ - function test_tag_hyphen() { - $this->assertSame( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) ); - $this->assertSame( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) ); - $this->assertSame( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) ); + public function test_tag_hyphen() { + $this->assertSame( 'shortcode_hyphen', do_shortcode( '[hyphen]' ) ); + $this->assertSame( 'shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) ); + $this->assertSame( 'shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) ); $this->assertSame( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) ); $this->assertSame( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) ); } @@ -144,7 +144,7 @@ class Tests_Shortcode extends WP_UnitTestCase { /** * @ticket 9405 */ - function test_attr_hyphen() { + public function test_attr_hyphen() { do_shortcode( '[test-shortcode-tag foo="foo" foo-bar="foo-bar" foo-bar-="foo-bar-" -foo-bar="-foo-bar" -foo-bar-="-foo-bar-" foo-bar-baz="foo-bar-baz" -foo-bar-baz="-foo-bar-baz" foo--bar="foo--bar" /]' ); $expected_attrs = array( 'foo' => 'foo', @@ -159,7 +159,7 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( $expected_attrs, $this->atts ); } - function test_two_atts() { + public function test_two_atts() { do_shortcode( '[test-shortcode-tag foo="asdf" bar="bing" /]' ); $this->assertSame( array( @@ -171,21 +171,21 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_noatts_enclosing() { + public function test_noatts_enclosing() { do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' ); $this->assertSame( '', $this->atts ); $this->assertSame( 'content', $this->content ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_one_att_enclosing() { + public function test_one_att_enclosing() { do_shortcode( '[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]' ); $this->assertSame( array( 'foo' => 'bar' ), $this->atts ); $this->assertSame( 'content', $this->content ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_two_atts_enclosing() { + public function test_two_atts_enclosing() { do_shortcode( '[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]' ); $this->assertSame( array( @@ -198,28 +198,28 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_unclosed() { + public function test_unclosed() { $out = do_shortcode( '[test-shortcode-tag]' ); $this->assertSame( '', $out ); $this->assertSame( '', $this->atts ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_positional_atts_num() { + public function test_positional_atts_num() { $out = do_shortcode( '[test-shortcode-tag 123]' ); $this->assertSame( '', $out ); $this->assertSame( array( 0 => '123' ), $this->atts ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_positional_atts_url() { + public function test_positional_atts_url() { $out = do_shortcode( '[test-shortcode-tag https://www.youtube.com/watch?v=72xdCU__XCk]' ); $this->assertSame( '', $out ); $this->assertSame( array( 0 => 'https://www.youtube.com/watch?v=72xdCU__XCk' ), $this->atts ); $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_positional_atts_quotes() { + public function test_positional_atts_quotes() { $out = do_shortcode( '[test-shortcode-tag "something in quotes" "something else"]' ); $this->assertSame( '', $out ); $this->assertSame( @@ -232,7 +232,7 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_positional_atts_mixed() { + public function test_positional_atts_mixed() { $out = do_shortcode( '[test-shortcode-tag 123 https://wordpress.org/ 0 "foo" bar]' ); $this->assertSame( '', $out ); $this->assertSame( @@ -248,7 +248,7 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_positional_and_named_atts() { + public function test_positional_and_named_atts() { $out = do_shortcode( '[test-shortcode-tag 123 url=https://wordpress.org/ foo bar="baz"]' ); $this->assertSame( '', $out ); $this->assertSame( @@ -263,18 +263,18 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( 'test-shortcode-tag', $this->tagname ); } - function test_footag_default() { + public function test_footag_default() { $out = do_shortcode( '[footag]' ); $this->assertSame( 'foo = ', $out ); } - function test_footag_val() { + public function test_footag_val() { $val = rand_str(); $out = do_shortcode( '[footag foo="' . $val . '"]' ); $this->assertSame( 'foo = ' . $val, $out ); } - function test_nested_tags() { + public function test_nested_tags() { $out = do_shortcode( '[baztag][dumptag abc="foo" def=123 https://wordpress.org/][/baztag]' ); $expected = "content = abc = foo\ndef = 123\n0 = https://wordpress.org\n"; $this->assertSame( $expected, $out ); @@ -283,7 +283,7 @@ class Tests_Shortcode extends WP_UnitTestCase { /** * @ticket 6518 */ - function test_tag_escaped() { + public function test_tag_escaped() { $out = do_shortcode( '[[footag]] [[bartag foo="bar"]]' ); $this->assertSame( '[footag] [bartag foo="bar"]', $out ); @@ -298,7 +298,7 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( '[[footag]] [[bartag foo="bar"]]', $out ); } - function test_tag_not_escaped() { + public function test_tag_not_escaped() { // These have square brackets on either end but aren't actually escaped. $out = do_shortcode( '[[footag] [bartag foo="bar"]]' ); $this->assertSame( '[foo = foo = bar]', $out ); @@ -316,7 +316,7 @@ class Tests_Shortcode extends WP_UnitTestCase { $this->assertSame( '[[foo = foo = bar]]', $out ); } - function test_mixed_tags() { + public function test_mixed_tags() { $in = <<assertSame( @@ -372,7 +372,7 @@ EOF; /** * @ticket 6562 */ - function test_utf8_whitespace_2() { + public function test_utf8_whitespace_2() { // ZERO WIDTH SPACE: U+200B. do_shortcode( "[test-shortcode-tag foo=\"bar\" \xE2\x80\x8Babc=\"def\"]" ); $this->assertSame( @@ -388,13 +388,13 @@ EOF; /** * @ticket 14050 */ - function test_shortcode_unautop() { + public function test_shortcode_unautop() { // A blank line is added at the end, so test with it already there. $test_string = "[footag]\n"; $this->assertSame( $test_string, shortcode_unautop( wpautop( $test_string ) ) ); } - function data_test_strip_shortcodes() { + public function data_test_strip_shortcodes() { return array( array( 'before', 'before[gallery]' ), array( 'after', '[gallery]after' ), @@ -417,25 +417,25 @@ EOF; * @param string $expected Expected output. * @param string $content Content to run strip_shortcodes() on. */ - function test_strip_shortcodes( $expected, $content ) { + public function test_strip_shortcodes( $expected, $content ) { $this->assertSame( $expected, strip_shortcodes( $content ) ); } /** * @ticket 37767 */ - function test_strip_shortcodes_filter() { - add_filter( 'strip_shortcodes_tagnames', array( $this, '_filter_strip_shortcodes_tagnames' ) ); + public function test_strip_shortcodes_filter() { + add_filter( 'strip_shortcodes_tagnames', array( $this, 'filter_strip_shortcodes_tagnames' ) ); $this->assertSame( 'beforemiddle [footag]after', strip_shortcodes( 'before[gallery]middle [footag]after' ) ); - remove_filter( 'strip_shortcodes_tagnames', array( $this, '_filter_strip_shortcodes_tagnames' ) ); + remove_filter( 'strip_shortcodes_tagnames', array( $this, 'filter_strip_shortcodes_tagnames' ) ); } - function _filter_strip_shortcodes_tagnames() { + public function filter_strip_shortcodes_tagnames() { return array( 'gallery' ); } // Store passed in shortcode_atts_{$shortcode} args. - function _filter_atts( $out, $pairs, $atts ) { + public function filter_atts( $out, $pairs, $atts ) { $this->filter_atts_out = $out; $this->filter_atts_pairs = $pairs; $this->filter_atts_atts = $atts; @@ -443,7 +443,7 @@ EOF; } // Filter shortcode atts in various ways. - function _filter_atts2( $out, $pairs, $atts ) { + public function filter_atts2( $out, $pairs, $atts ) { // If foo attribute equals "foo1", change it to be default value. if ( isset( $out['foo'] ) && 'foo1' === $out['foo'] ) { $out['foo'] = $pairs['foo']; @@ -458,8 +458,8 @@ EOF; return $out; } - function test_shortcode_atts_filter_passes_original_arguments() { - add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); + public function test_shortcode_atts_filter_passes_original_arguments() { + add_filter( 'shortcode_atts_bartag', array( $this, 'filter_atts' ), 10, 3 ); do_shortcode( '[bartag foo="foo1" /]' ); $this->assertSame( @@ -478,11 +478,11 @@ EOF; ); $this->assertSame( array( 'foo' => 'foo1' ), $this->filter_atts_atts ); - remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); + remove_filter( 'shortcode_atts_bartag', array( $this, 'filter_atts' ), 10, 3 ); } - function test_shortcode_atts_filtering() { - add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); + public function test_shortcode_atts_filtering() { + add_filter( 'shortcode_atts_bartag', array( $this, 'filter_atts2' ), 10, 3 ); $out = do_shortcode( '[bartag foo="foo1" baz="baz1" /]' ); $this->assertSame( array( 'foo' => 'no foo' ), $this->filter_atts_out ); @@ -491,7 +491,7 @@ EOF; $out = do_shortcode( '[bartag foo="foo2" /]' ); $this->assertSame( 'foo = foo2', $out ); - remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); + remove_filter( 'shortcode_atts_bartag', array( $this, 'filter_atts2' ), 10, 3 ); } /** @@ -499,7 +499,7 @@ EOF; * * @ticket 22692 */ - function test_spaces_around_shortcodes() { + public function test_spaces_around_shortcodes() { $nbsp = "\xC2\xA0"; $input = array(); @@ -521,11 +521,11 @@ EOF; * * @dataProvider data_escaping */ - function test_escaping( $input, $output ) { + public function test_escaping( $input, $output ) { return $this->assertSame( $output, do_shortcode( $input ) ); } - function data_escaping() { + public function data_escaping() { return array( array( '