Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Theme Unit Test

(Last Edited: 2020-07-31)

This step in Theme testing correlates to a WordPress export (WXR) file that you can import into a WordPress installation to test your Theme. To be clear, this is only one step in testing your Theme. See Theme testing for a full guide.

Setup

Test Environment Setup

  1. Clone the theme test data file themeunittestdata.wordpress.xml from the GitHub repository https://github.com/WPTT/theme-unit-test (last updated 30/January/2020).

Or Download a copy from https://raw.githubusercontent.com/WPTT/theme-unit-test/master/themeunittestdata.wordpress.xml

  1. Import test data into your WordPress install by going to Tools => Import => WordPress
  2. Select the XML file from your computer
  3. Click on "Upload file and import".
  4. Under "Import Attachments," check the "Download and import file attachments" box and click submit.
    Note: you may have to repeat the Import step until you see "All Done" to obtain the full list of Posts and Media.
  5. Read Becoming a reviewer, and follow the easy steps.

Test Environment Installer Package

If you want to have famous 5 minute installation package for theme unit test environment, you can find it here: https://github.com/Evinceknow/Theme-Unit-Test-Environment-for-WordPress. Setup it as WordPress main installation package.

I18N Test Data

- Japanese Test Data

WordPress Settings

Adjust WordPress settings as follows:

  • Settings -> General: set the Site Title to something fairly long, and set the Tagline to something even longer. These settings will facilitate testing how the Theme handles these values.
  • Settings -> Reading: set "Blog pages show at most" to 5. This setting will ensure that index/archive pagination is triggered.
  • Settings -> Discussion: enable Threaded Comments, at least 3 levels deep. This setting will facilitate testing of Theme comment list styling.
  • Settings -> Discussion: enable Break comments into pages, and set 5 comments per page. This setting will facilitate testing of Theme paginating link markup/styling.
  • Settings -> Media: ensure that no values are set for max width or height of Embedded media. This setting will facilitate testing of the Theme $content_width setting/implementation. Note: If you are using the most recent version of WordPress, ignore this setting as it has been removed (https://core.trac.wordpress.org/ticket/21719).
  • Settings -> Permalinks: ensure that a non-default permalink setting is selected, e.g. "Month and name". This setting will facilitate stepping through the Theme Unit Tests.

Create at least two Custom Menus:

  • Long Menu: all included Pages
  • Short Menu: a menu of 2-3 Pages

Template Hierarchy Index Pages

When viewing any Template Hierarchy Index page, including the default index page (index.php), and (if applicable) Blog Posts Index (home.php), Date Archives (archive.php), Category Archives (category.php), Tag Archives (tag.php), or Author Archives (author.php):

  • Posts display correctly, with no apparent visual problems or errors.
  • Posts display in correct order.
  • Correct number of posts display (as per setting in Settings > Reading).
  • Page navigation displays and works correctly.
  • Debugger returns no PHP errors, warnings, or notices.
  • The browser reports no JavaScript errors.

Static Front Page

If the Theme includes either a front-page.php or a home.php template file, go to Dashboard -> Settings -> Reading, and set the Front Page to display a Static Page (use any existing Page), and set the Blog Posts index to another Static Page (e.g. "Lorem Ipsum").

  • The Front Page displays properly, and as intended
  • The Blog Posts index page displays properly
  • Debugger returns no PHP errors, warnings, or notices
  • The browser reports no JavaScript errors

404 Page

  • The 404 page displays properly
  • Some content is displayed, more than merely the basic "Error 404 - Page Not Found" message - such as some helpful text, a search form, a list of Post or Pages, etc.
  • Debugger returns no PHP errors, warnings, or notices
  • The browser reports no JavaScript errors

Search Results Page

  • The Search Results page displays properly, with search query results displayed.
  • Debugger returns no PHP errors, warnings, or notices
  • The browser reports no JavaScript errors

Blog Posts Index Page

Test the following posts when viewing the Blog Posts Index page. Post Titles in the test data correlate with section titles below.

Scheduled Post

  • Should not be displayed by the Theme (status "scheduled", rather than "publish").

Draft Post

  • Should not be displayed by the Theme (status "draft", rather than "publish").

Layout Test

  • Displays properly as a "Sticky Post."
  • Page navigation links display and work properly.

Readability Test

  • Displays "Read More" link properly.
  • "Read More" link works properly (links to single post at "More" tag location).

Post Format Tests (All)

  • If Theme supports Post Format Type, Post displays as intended in the index view

Post Format Test: Gallery

  • Gallery images display as intended in the index view

Post Format Test: Image (Linked)

  • Image displays as intended in the index view
  • Image does not overflow the content area

Post Format Test: Image (Attached)

  • Image displays as intended in the index view
  • Image does not overflow the content area

Post Format Test: Video

  • Video displays as intended in the index view
  • Video does not overflow the content area

This Post Has No Body

  • Lack of body text should not adversely impact the layout.

(no title)

  • Lack of post title should not adversely impact layout.
  • Post permalink should be displayed. Making the post date a permalink is a great solution. See Twenty Ten for an example.

Many Categories & Many Tags

  • Theme must incorporate both the "Tag" and the "Category" taxonomies in some manner.
  • Large number of categories/tags should not adversely impact layout.

Protected Test With Secret Password

  • Password form should be displayed.
  • Post content should not be displayed.
  • Comments should not be displayed.
  • Once password is entered, post or excerpt displays properly.

Single Post

Test the following posts when viewing a single post (single.php). Each section title matches a post title in the test data.

Layout Test

  • Displays page navigation links properly.
  • Page navigation links work properly (link to correct page).
  • Post permalink links to Page 1.

Page 2

  • Paragraphs are styled correctly.
  • Left, Center, Right, Justify aligned paragraphs align properly.

Page 3

  • h1-h6 elements are styled (as appropriate).
  • blockquote, cite styled (as appropriate).
    • Block quotes should be indented or otherwise distinct from paragraph text.
    • If the Theme uses a background image or quote symbol, make sure displays correctly on both short and long quotes.
  • span with style and ASCII characters should display properly.
  • table, tr, th, td are styled (as appropriate).
  • dl (dt, dd), ul, ol, li styled (as appropriate).
    • Nested lists should be indented correctly.
  • The following HTML tags should be styled appropriately to ensure semantic meaning of each tag is preserved: address, a, big, cite, code, del, em, ins, kbd, pre, q, s, strong, sub, sup, tt, var.
    • Note: abbr and acronym require no special styling. Also, s may be address but was deprected with HTML 4 and can be left with no special styling as well.
  • div, span maintain proper block or inline display, and styled (as appropriate).

Readability Test

  • The content should be generally readable.
  • Styling should not negatively impact readability: foreground/background contrast, font family, font size, line height, paragraph width, paragraph spacing.

Images Test

Page 1

  • Un-Captioned Image Alignment Tests
    • Images are aligned properly: Center, Left, Right, None.
    • Check caption styles on first image.
    • Images should not have a border unless it's part of design.

Page 2

  • Captioned Image Alignment Tests
    • Images are aligned properly: Center, Left, Right, None.
    • Check caption styles on first image.
    • Images should not have a border unless it's part of design.

Page 3

  • Other Image Tests
    • Wide Image (Resized) Test
      • Image should display properly, and should be resized as specified.
      • Sidebar must not be pushed to the bottom of the page.
    • Wide Image (Not Resized) Test
      • Wide image overflows properly (such as using max-width CSS rule or overflow CSS rule).
      • Sidebar must not be pushed below content due to image overlap.
    • Thumbnails
      • Thumbnails display properly.

Page 4

  • Floats are cleared properly for floated element (thumbnail image) at the end of the Post Content.

Post Format Tests (All)

  • If Theme supports Post Format type, Post displays as intended in the single-post view.

Post Format Test: Gallery

  • Gallery displays correctly (check for spacing after gallery).
  • Gallery image thumbnails link to image post.

Post Format Test: Image (Linked)

  • Image displays as intended in single-post view.
  • Image does not overflow the content area.

Post Format Test: Image (Attached)

  • Image displays as intended in single-post view.
  • Image does not overflow the content area.

Post Format Test: Video

  • Video embeds work.
  • Embedded video does not push sidebar(s) below content due to overlap.
  • $content_width should have an appropriate value defined.

Post Format Test: Audio

  • Enclosure links work properly.

Post With Long Title

Long Post Title with long non-breaking string: If you say it loud enough, you’ll always sound precocious; Supercalifragilisticexpialidocious!

  • Test title line height.
  • Look for potential overflow issues if the theme has a small title area.

This Post Has No Body

  • Post displays properly and should not impact the layout.

(no title)

  • Post displays properly.
  • A link to the singular view of the post is recommended to be displayed. Making the post date a permalink (see Twenty Ten for an example) is a great solution.

Many Categories / Many Tags

  • Theme incorporates both the "Tag" and "Category" taxonomies in some manner.
  • Category links work correctly.
  • Categories display properly without adversely impacting design.
  • Tag links work correctly.
  • Tags display properly without adversely impacting design.

Protected Test With Secret Password

  • Password input form displays properly.
  • When correct password (secret) is entered, the post and comments are displayed.

Comment Test

  • Comments are displayed correctly.
  • Threaded comments display correctly.
  • Comment pagination displays correctly.
  • Author comment is styled (as appropriate).
  • User avatars are displayed properly.
  • Comment form displays properly for both logged in/logged out users.
  • When logged in as admin, edit links are displayed and work correctly.
  • HTML is displayed properly in comments, especially lists and block quotes.

Comments Disabled

  • Comment form does not display.
  • "Comments are disabled" notice is displayed.

Many Trackbacks

  • All trackbacks are displayed properly, with no overlap.

Pages

Test the following pages (page.php) by viewing the page that matches the section titles below.

Page With Comments

  • Tags, Categories, and Post date/time stamp should not be displayed.
  • Comment list and comment reply form are displayed.

Page With Comments Disabled

  • Comment list and comment reply form are not displayed.
  • No "Comments Disabled" message should be displayed.
  • Layout not adversely impacted by minimal page content.

Parent Page / Child Page 1 / Child Page 2

  • Extra credit for displaying parent and/or child when viewing pages within hierarchy.

Clearing Floats

  • The last item in this page's content is a floated image. Make sure any elements after it are clearing properly.

Misc Pages

Tests for search.php and 404.php.

Search Results

  • Search results page is helpful.
  • Search query is displayed.

Not Found

  • 404 page is present, and has helpful information.

General

Menus

  • Test with a large number of categories or pages in the menu, and test with multiple levels deep in the menus.
  • If custom menus are enabled, test the layout both with custom menus enabled and with the fallback navigation menus (no custom menu enabled).

Widgets

  • All widgets display correctly.
  • The default WordPress widgets should work correctly in all widgetized areas.
  • If the Theme uses custom widgets, they should work correctly. (Custom widgets are programmatically added by the Theme to the list of available widgets in Appearance > Widgets.)
  • Test all available widgets in all available widgetized areas in the Theme layout.
  • Content that appears in widgetized areas by default (hard-coded into the sidebar, for example) should disappear when widgets are enabled from Appearance > Widgets.

Screenshot

  • The screenshot should accurately show the Theme design.
  • Make sure it doesn't show customized header colors or an uploaded logo that wouldn't appear by default.

Anchor Text and Credit Links

Theme authors should only be using links that point directly to a website specifically for the theme; an appropriate website page for the theme; or a reasonably related URL giving more information about the theme. Using anchor text for search engine gains will not be accepted.

Theme Testing

This Unit Test is just one step in Theme testing. Continue to Theme testing for the full guide.

Related Pages