PHPackages                             idearia/wp-tests - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. idearia/wp-tests

ActiveLibrary[Testing &amp; Quality](/categories/testing)

idearia/wp-tests
================

A simple class to run PHPUnit tests in WordPress.

2.0.1(3y ago)11.7k↓50%GPL-3.0-or-laterPHP

Since Jun 6Pushed 3y ago2 watchersCompare

[ Source](https://github.com/Idearia/wp-tests)[ Packagist](https://packagist.org/packages/idearia/wp-tests)[ Docs](https://github.com/Idearia/wp-tests)[ RSS](/packages/idearia-wp-tests/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (0)

Defines the class `WordPressTestCase` to run PHPUnit tests in a WordPress installation, with support for logging and multisite.

Usage
=====

[](#usage)

1. Install with `composer require idearia/wp-tests --dev`.
2. Create a test case by extending `Idearia\WpTests\WordPressTestCase`.
3. When you run the test, WordPress will be automatically loaded.

Have a look in the [the example folder](examples). You'll find:

- an [example test](examples/WordPressTest.php) that creates, fetches and deletes a WordPress post;
- an [example phpunit.xml](examples/phpunit.example.xml) file with the available options.

Logging support
===============

[](#logging-support)

- To log a message to screen, call `self::print( $message )`.
- To log a message to file, call `self::log( $message )`.
- The file will be named after the test class and placed in the subfolder *tests/logs*.
- The log file will reset at each run unless you set `protected static $deleteLogFile = false;` in your test case.
- Customize the log folder via the `logsPath` environment variable.
- For further customizations, please refer to the documentation of the [Loggable trait](https://github.com/coccoinomane/phpunit-log).

Multisite support
=================

[](#multisite-support)

By default, the tests will be run on the main blog.

To run the tests on a different blog, add the `siteUrl` environment variable to your phpunit.xml file:

```

```

Then, you are free to set `siteUrl` the way you see fit:

- In a [dotenv file](https://github.com/vlucas/phpdotenv).
- When you run phpunit: `siteUrl=http://example.com/blog phpunit`.
- At the shell level: `export siteUrl=http://example.com/blog`.
- In your test case setup: `putenv( 'siteUrl=http://example.com/blog' );`.
- Hard-code it in phpunit.xml.

Custom WordPress path
=====================

[](#custom-wordpress-path)

If your WordPress installation is non-standard, you can specify a custom WordPress path by setting the `wordPressPath` environment variable. You can use both relative and absolute paths.

To set `wordPressPath` in *phpunit.xml*:

```

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~24 days

Recently: every ~32 days

Total

11

Last Release

1202d ago

Major Versions

1.8 → 2.0.02023-02-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17342951?v=4)[Idearia SRL](/maintainers/idearia)[@Idearia](https://github.com/Idearia)

---

Top Contributors

[![coccoinomane](https://avatars.githubusercontent.com/u/3920436?v=4)](https://github.com/coccoinomane "coccoinomane (7 commits)")[![HighLiuk](https://avatars.githubusercontent.com/u/65017775?v=4)](https://github.com/HighLiuk "HighLiuk (1 commits)")

---

Tags

phpunitwordpresstests

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/idearia-wp-tests/health.svg)

```
[![Health](https://phpackages.com/badges/idearia-wp-tests/health.svg)](https://phpackages.com/packages/idearia-wp-tests)
```

###  Alternatives

[whatthejeff/nyancat-phpunit-resultprinter

Nyan Cat result printer for PHPUnit

283689.8k24](/packages/whatthejeff-nyancat-phpunit-resultprinter)[wp-phpunit/wp-phpunit

WordPress core PHPUnit library

803.7M208](/packages/wp-phpunit-wp-phpunit)[yoast/wp-test-utils

PHPUnit cross-version compatibility layer for testing plugins and themes build for WordPress

632.3M52](/packages/yoast-wp-test-utils)[aik099/phpunit-mink

Library for using Mink in PHPUnit tests. Supports session sharing between tests in a test case.

72136.2k1](/packages/aik099-phpunit-mink)[phpunit/phpunit-dom-assertions

DOM assertions for PHPUnit

29343.5k11](/packages/phpunit-phpunit-dom-assertions)[janmarek/mockista

Mockista is library for mocking, which I've written, because I find mocking in PHPUnit awful.

29221.0k28](/packages/janmarek-mockista)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
