PHPackages                             jakehenshall/pest-plugin-wordpress - 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. jakehenshall/pest-plugin-wordpress

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

jakehenshall/pest-plugin-wordpress
==================================

The most comprehensive WordPress testing framework built on Pest PHP v4. Includes PHPStan v2.1 for static analysis, SQLite for fast testing, and 150+ helper functions. Test WordPress plugins and themes with Laravel-style syntax. Browser testing, HTTP testing, email mocking, AJAX testing, REST API helpers, test sharding, time travel, and more. Zero configuration required.

v0.1.0(4mo ago)11MITPHPPHP ^8.3.0CI passing

Since Dec 19Pushed 4mo agoCompare

[ Source](https://github.com/JakeHenshall/pest-plugin-wordpress)[ Packagist](https://packagist.org/packages/jakehenshall/pest-plugin-wordpress)[ Docs](https://github.com/jakehenshall/pest-plugin-wordpress)[ RSS](/packages/jakehenshall-pest-plugin-wordpress/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

WordPress Pest Testing Framework
================================

[](#wordpress-pest-testing-framework)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d9a19f442319e747c76946aeede97f5fb9a9c2fbe54d49203f3a406dc4940467/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a616b6568656e7368616c6c2f706573742d706c7567696e2d776f726470726573733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jakehenshall/pest-plugin-wordpress)[![Total Downloads](https://camo.githubusercontent.com/1d333436ae14903ac948c6891112d25b714d65663accb19fa76da14e6083b89c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616b6568656e7368616c6c2f706573742d706c7567696e2d776f726470726573733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jakehenshall/pest-plugin-wordpress)[![MIT License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

**The complete WordPress testing solution.** One package includes everything: Pest PHP v4, PHPStan v2.1, SQLite, MySQL support, WordPress stubs, and 150+ helper functions. Write beautiful, Laravel-style tests with zero configuration.

> **🔋 Batteries Included**: Install once, test immediately. No setup, no configuration, no additional packages needed.

```
test('creates posts and sends emails', function () {
    actingAsAdmin();

    $postId = factory()::post(['post_title' => 'Hello World']);

    fakeEmail();
    wp_mail('admin@example.com', 'New Post', 'Post created!');

    assertPostExists($postId);
    assertEmailSent('admin@example.com');
});
```

Why This Package?
-----------------

[](#why-this-package)

Testing WordPress shouldn't be complicated. This package brings the joy of testing to WordPress with:

- 🚀 **150+ Helper Functions** - Everything you need out of the box
- 🎨 **Laravel-Style Syntax** - Beautiful, expressive test code
- ⚡ **Fast** - SQLite database built-in for speed (MySQL supported too)
- 🔬 **PHPStan Built-in** - Static analysis included, no extra setup
- 🌐 **Browser Testing** - Test WordPress admin, Gutenberg, WooCommerce with real browsers
- 🔌 **Plugin Compatible** - Works with Yoast, WooCommerce, ACF
- 🌐 **WP-CLI Integration** - Native WordPress tooling
- 📦 **Complete Coverage** - REST API, AJAX, Blocks, Email, Cron, and more
- 🎯 **Pest v4 Features** - Test sharding, skip helpers, new expectations
- 🔋 **Batteries Included** - One package, zero configuration

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3.0
- Composer

That's it! Everything else (Pest, PHPStan, SQLite, WordPress stubs) is included automatically.

Installation
------------

[](#installation)

Install via Composer in your WordPress plugin or theme:

```
composer require jakehenshall/pest-plugin-wordpress --dev
```

**What you get automatically:**

- ✅ Pest PHP v4 - Complete testing framework
- ✅ PHPStan v2.1 - Static analysis with WordPress rules
- ✅ SQLite - Fast in-memory database for tests
- ✅ MySQL Support - Production-like testing
- ✅ WordPress Stubs - Full IntelliSense support
- ✅ 150+ Helper Functions - HTTP, Email, AJAX, REST API, and more
- ✅ 14 Ready-to-Use Stubs - Test examples, configs, CI/CD templates
- ✅ WP-CLI Commands - Native WordPress integration

**One package. Zero configuration. Start testing immediately.**

### Using PHPStan (Built-in)

[](#using-phpstan-built-in)

PHPStan is automatically included with WordPress-specific rules. Add to your `composer.json`:

```
{
  "scripts": {
    "phpstan": "phpstan analyse --memory-limit=2G",
    "phpstan:baseline": "phpstan analyse --memory-limit=2G --generate-baseline"
  }
}
```

Create `phpstan.neon`:

```
parameters:
    level: 6
    paths:
        - your-plugin.php
        - src
    scanFiles:
        - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
```

Run analysis:

```
composer phpstan
```

**What's included:**

- ✅ PHPStan v2.1
- ✅ WordPress-specific rules
- ✅ WordPress function stubs
- ✅ Level 6 analysis ready

Quick Start
-----------

[](#quick-start)

### 1. Install the Package

[](#1-install-the-package)

```
composer require jakehenshall/pest-plugin-wordpress --dev
```

This single command installs:

- Pest PHP v4 (testing framework)
- PHPStan v2.1 (static analysis)
- SQLite database driver
- WordPress function stubs
- All 150+ helper functions

### 2. Run Setup

[](#2-run-setup)

For a **plugin**:

```
vendor/bin/wp-pest setup plugin --plugin-slug=my-awesome-plugin
```

For a **theme**:

```
vendor/bin/wp-pest setup theme
```

Or via WP-CLI:

```
wp pest setup plugin --plugin-slug=my-plugin
```

This will:

- Create `tests/` directory structure
- Download WordPress core
- Set up SQLite database (automatically included)
- Create example tests (unit, integration, browser)
- Configure PHPUnit/Pest
- Generate `phpunit.xml` configuration
- Set up WordPress test config

**Optional:** You can also copy these stubs from `vendor/jakehenshall/pest-plugin-wordpress/stubs/`:

- `phpstan.neon.stub` - PHPStan configuration
- `phpstan-baseline.neon.stub` - PHPStan baseline
- `.gitignore.stub` - Ignore test artifacts
- `.github-workflows-tests.yml.stub` - CI/CD workflow
- `composer.json.stub` - Example project structure

### 3. Run Your Tests

[](#3-run-your-tests)

```
# Run all tests
vendor/bin/pest

# Run unit tests only
vendor/bin/pest --group=unit

# Run integration tests only
vendor/bin/pest --group=integration
```

Or via WP-CLI:

```
wp pest test all
wp pest test unit
wp pest test integration
```

### 4. Write Your First Test

[](#4-write-your-first-test)

Create `tests/Integration/MyFirstTest.php`:

```
