PHPackages                             10quality/wpmvc-addon-testsuite - 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. 10quality/wpmvc-addon-testsuite

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

10quality/wpmvc-addon-testsuite
===============================

Test suite for WordPress MVC (WPMVC) framework add-ons.

0404PHP

Since Feb 10Pushed 3y ago2 watchersCompare

[ Source](https://github.com/10quality/wpmvc-addon-testsuite)[ Packagist](https://packagist.org/packages/10quality/wpmvc-addon-testsuite)[ RSS](/packages/10quality-wpmvc-addon-testsuite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (4)

WordPress MVC - Addon test suite
================================

[](#wordpress-mvc---addon-test-suite)

Install
-------

[](#install)

Composer command to install as `required-dev`:

```
composer install 10quality/wpmvc-addon-testsuite --dev
```

Test Case Class
---------------

[](#test-case-class)

Instead of the default PHPUnit test case use the following:

```
use WPMVC\Addons\PHPUnit\TestCase;

class MyTest extends TestCase
{
    // Your test methods
}
```

This classs will allow you to use the following assertiong methods:

MethodParametersDescription`$this->assertDidAction``$handle` the action hook name handle.Asserts if an action ran.`$this->assertDidNotAction``$handle` the action hook name handle.Asserts if an action not ran.`$this->assertAppliedFilters``$handle` the filter hook name handle.Asserts if filters have been applied to a hook.`$this->assertNotAppliedFilters``$handle` the filter hook name handle.Asserts if filters have been not applied to a hook.`$this->assertAddedAction``$handle` the action hook name handle.Asserts if an action handler has been added for a hook.`$this->assertNotAddedAction``$handle` the action hook name handle.Asserts if no action handlers has been added for a hook.`$this->assertAddedFilter``$handle` the filter hook name handle.Asserts if a filter handler has been added for a hook.`$this->assertNotAddedFilter``$handle` the filter hook name handle.Asserts if no filter handlers has been added for a hook.`$this->assertHasRegisterStyle``$handle` the style name handle.Asserts if a style asset has been registered.`$this->assertNotHasRegisterStyle``$handle` the style hook name handle.Asserts if a style asset has not been registered.`$this->assertHasRegisterScript``$handle` the script name handle.Asserts if a script asset has been registered.`$this->assertNotHasRegisterScript``$handle` the script hook name handle.Asserts if a script asset has not been registered.`$this->assertHasEnqueueStyle``$handle` the style name handle.Asserts if a style asset has been registered.`$this->assertNotHasEnqueueStyle``$handle` the style hook name handle.Asserts if a style asset has not been registered.`$this->assertHasEnqueueScript``$handle` the script name handle.Asserts if a script asset has been enqueued.`$this->assertNotHasEnqueueScript``$handle` the script hook name handle.Asserts if a script asset has not been enqueued.`$this->assertHasCalledWP``$function` the name of a WordPress core function.Asserts if a core WordPress function has been called.`$this->assertNotHasCalledWP``$function` the name of a WordPress core function.Asserts if a core WordPress function has not been called.Example:

```
use WPMVC\Addons\PHPUnit\TestCase;

class MyTest extends TestCase
{
    public function testAction()
    {
        // Run
        do_action( 'init' );
        // Assert
        $this->assertDidAction( 'init' );
    }
}
```

### Test your addon

[](#test-your-addon)

You addon main class needs a WordPress MVC main class (bridge) instance to work correctly. The `TestCase` class include the method `getBridgeMock()` that allows you to test your addon mocking the Bridge class.

Example:

```
use WPMVC\Addons\PHPUnit\TestCase;
use MyAddon;

class MyAddonTest extends TestCase
{
    public function testInit()
    {
        // Prepare
        $bridge = $this->getBridgeMock();
        $addon = new MyAddon( $bridge );
        // Run
        $addon->init();
        // Assert
        $this->assertAddedAction( 'init' );
        $this->assertHasRegisterScript( 'my-js' );
    }
}
```

The example above tests the method `init()` of the addon class `MyAddon`, which receives the `$bridge` initialized as a mock. The example asserts that an action hook has been added and a script has been registered during the method call.

You can mock the `Bridge` for your own benefit:

```
use WPMVC\Addons\PHPUnit\TestCase;
use WPMVC\Addons\PHPUnit\Mocks\Brige;
use MyAddon;

class MyAddonTest extends TestCase
{
    public function testInit()
    {
        // Prepare
        $bridge = $this->getMockBuilder( Brige::class )
            ->disableOriginalConstructor()
            ->getMock();
        $addon = new MyAddon( $bridge );
        // Run
        $addon->init();
        // Assert
        $this->assertAddedAction( 'init' );
        $this->assertHasRegisterScript( 'my-js' );
    }
}
```

### Reset test suite data

[](#reset-test-suite-data)

You can reset test suite data by calling the function `wpmvc_addon_phpunit_reset()` inside the `setUp` or `tearDown` methods.

WordPress core functions mocked
-------------------------------

[](#wordpress-core-functions-mocked)

The following WordPress core functions are mocked and included through composer:

- `__`
- `_e`
- `add_action`
- `add_filter`
- `add_query_arg`
- `add_submenu_page`
- `admin_url`
- `apply_filters`
- `do_action`
- `esc_attr`
- `esc_html`
- `esc_html_e`
- `esc_url`
- `get_filesystem_method`
- `get_locale`
- `get_stylesheet_directory`
- `home_url`
- `request_filesystem_credentials`
- `sanitize_text_field`
- `site_url`
- `submit_button`
- `wp_enqueue_script`
- `wp_enqueue_style`
- `wp_register_script`
- `wp_register_style`
- `WP_Filesystem`

WordPress core constants mocked
-------------------------------

[](#wordpress-core-constants-mocked)

The following constants are mocked through composer if they are not defined:

- `ABSPATH`

WordPress core classes mocked
-----------------------------

[](#wordpress-core-classes-mocked)

The following WordPress classes are mocked and included through composer:

- `WP_Filesystem`

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2cdad4e398292477582ba8ec4ab02a96fa645cd620518a5bcf697cd788c96c3?d=identicon)[amostajo](/maintainers/amostajo)

---

Top Contributors

[![amostajo](https://avatars.githubusercontent.com/u/1645908?v=4)](https://github.com/amostajo "amostajo (19 commits)")

### Embed Badge

![Health badge](/badges/10quality-wpmvc-addon-testsuite/health.svg)

```
[![Health](https://phpackages.com/badges/10quality-wpmvc-addon-testsuite/health.svg)](https://phpackages.com/packages/10quality-wpmvc-addon-testsuite)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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