PHPackages                             sebkay/touchstone - 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. sebkay/touchstone

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

sebkay/touchstone
=================

A simple framework for running WordPress unit and integration tests.

4.0.0(2y ago)19555↑75%11MITPHPPHP ^8.1

Since Jun 17Pushed 2y ago2 watchersCompare

[ Source](https://github.com/SebKay/touchstone)[ Packagist](https://packagist.org/packages/sebkay/touchstone)[ RSS](/packages/sebkay-touchstone/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (21)Used By (1)

Touchstone
==========

[](#touchstone)

[![PHP](https://github.com/SebKay/touchstone/actions/workflows/php.yml/badge.svg)](https://github.com/SebKay/touchstone/actions/workflows/php.yml)

A modern wrapper around the [official WordPress testsuite](https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/). It can be used to run both Unit and Integration tests.

---

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

[](#installation)

Run the following command to install Touchstone in your project:

```
composer require sebkay/touchstone --dev
```

---

Usage
-----

[](#usage)

### 1.) Setup

[](#1-setup)

Running the setup process downloads and installs both WordPress and the official WordPress test files in your temp directory.

```
# Options
./vendor/bin/touchstone setup --db-host=[HOST] --db-socket=[SOCKET PATH] --db-name=[DATABASE NAME] --db-user=[DATABASE USERNAME] --db-pass=[DATABASE PASSWORD] skip-db-creation
```

#### Regular Connection

[](#regular-connection)

```
# Example
./vendor/bin/touchstone setup --db-host=127.0.0.1:8889 --db-name=touchstone_tests --db-user=root --db-pass=root
```

#### via a Socket

[](#via-a-socket)

```
./vendor/bin/touchstone setup --db-host=127.0.0.1:8889 --db-socket="/path/to/mysqld.sock" --db-name=touchstone_tests --db-user=root --db-pass=root
```

### 2.) Creating Tests

[](#2-creating-tests)

All your tests will need to be in the following structure from the root of your project:

```
tests/
    Unit/
        ExampleUnitTest.php
    Integration/
        ExampleIntegrationTest.php
```

All your Unit tests will need to extend the `WPTS\Tests\UnitTest` class and all your integrationt tests will need to extend the `WPTS\Tests\IntegrationTest` class.

Here's an example Unit test:

```
