# Setup for WordPress testing

## Testing framework agnostic

Brain Monkey can be used with any testing framework. Examples in this page will use PHPUnit, but the concepts are applicable to any testing framework.

## Warning

The procedure below **includes** the setup needed for testing PHP functions, so there is **no** need to apply what said here and *additionally* what said in the section *PHP Functions / Setup*: steps below are enough to use all Brain Monkey features, including functions utilities.

## Setup tests

After Brain Monkey is part of the project (see *Getting Started / Installation*), to be able to use its features you need to **require vendor autoload file** before running tests (e.g. PHPUnit users will probably require it in their bootstrap file).

After that, you need to call a function *before* any test, and another *after* any test.

These two functions are:

* `Brain\Monkey\setUp()` has to be run before any test
* `Brain\Monkey\tearDown()` has to be run after any test

PHPUnit users will probably want to add these methods to a custom test case class:

```php
use PHPUnit\Framework\TestCase;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Brain\Monkey;

class MyTestCase extends TestCase {

    // Adds Mockery expectations to the PHPUnit assertions count.
    use MockeryPHPUnitIntegration;

    protected function setUp() {
        parent::setUp();
        Monkey\setUp();
    }

    protected function tearDown() {
        Monkey\tearDown();
        parent::tearDown();
    }
}
```

and then extend various test classes from it instead of directly extending `PHPUnit\Framework\TestCase`.

That's all. You are ready to use all Brain Monkey features.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://giuseppe-mazzapica.gitbook.io/brain-monkey/wordpress-specific-tools/wordpress-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
