# yireo/magento2-integration-test-helper

> Magento 2 module to support integration tests in other modules

`composer require yireo/magento2-integration-test-helper`

Canonical URL: https://packagento.com/yireo/magento2-integration-test-helper

## At a glance

- **Vendor**: yireo (https://packagento.com/yireo.md)
- **Latest version**: 0.0.23 — released 2026-06-13
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/yireo/magento2-integration-test-helper and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require yireo/magento2-integration-test-helper:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Magento 2 module to support integration tests in other modules

## README

This module adds various utilities to aid in creating integration tests for Magento 2.

### Installation
Use the following commands to install:

    composer require yireo/magento2-integration-test-helper --dev

Enable this module:

    ./bin/magento module:enable Yireo_IntegrationTestHelper
    ./bin/magento setup:upgrade

### Using this helper to enhance your tests
Parent classes:
- `\Yireo\IntegrationTestHelper\Test\Integration\AbstractTestCase`
- `\Yireo\IntegrationTestHelper\Test\Integration\GraphQlTestCase`

These classes offer some utility functions plus import numerous traits (see `Test/Integration/Traits/`) with PHPUnit assertions. For instance, the following test checks for the proper registration of your module:

```php
<?php declare(strict_types=1);

namespace Yireo\Example\Test\Integration;

use PHPUnit\Framework\TestCase;
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsEnabled;
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsRegistered;
use Yireo\IntegrationTestHelper\Test\Integration\Traits\AssertModuleIsRegisteredForReal;

class ModuleTest extends TestCase
{
    use AssertModuleIsEnabled;
    use AssertModuleIsRegistered;
    use AssertModuleIsRegisteredForReal;

    public function testIfModuleIsWorking()
    {
        $this->assertModuleIsEnabled('Yireo_Example');
        $this->assertModuleIsRegistered('Yireo_Example');
        $this->assertModuleIsRegisteredForReal('Yireo_Example');
    }
}
```

### Toggle TESTS_CLEANUP in integration tests configuration
When running integration tests, you probably want to frequently toggle the constant `TESTS_CLEANUP` from `disabled` to `enabled` to `disabled`. The following command-line easily allows for this (assuming the file is actually `dev/tests/integration/phpunit.xml` cause you shouldn't modify the `*.dist` version):

    bin/magento integration_tests:toggle_tests_cleanup

It is toggled. You can also set the value directly:

    bin/magento integration_tests:toggle_tests_cleanup enabled

### Generating the `install-config-mysql.php` return array
When installing Magento - as part of the procedure of running Integration Tests - the file `dev/tests/integration/etc/install-config-mysql.php` should return an array with all of your relevant settings, most importantly the database settings. By using the utility class `Yireo\IntegrationTestHelper\Utilities\InstallConfig` you can quickly generate the relevant output, plus details like Redis and ElasticSearch:

```php
<?php declare(strict_types=1);

use Yireo\IntegrationTestHelper\Utilities\InstallConfig;

return (new InstallConfig())
    ->addDb('mysql80_tmpfs')
    ->addRedis()
    ->addElasticSearch('elasticsearch6')
    ->get();
```

### Disable modules when installing Magento
When installing Magento - as part of the procedure of running Integration Tests - the file `dev/tests/integration/etc/install-config-mysql.php` is modified to point to your test database. There is also a flag `disable-modules` that allows you to disable specific Magento modules. Disabling modules is a benefit for performance. The utility class `Yireo\IntegrationTestHelper\Utilities\DisableModules` allows you to generate a listing of modules to disable quicker. 

In the following example, first all (!) modules that are listed in the global `app/etc/config.php` are disabled by default. But then all Magento core modules and the module `Yireo_GoogleTagManager2` are enabled (but only if they are marked as active in the global configuration):
```php
<?php declare(strict_types=1);

use Yireo\IntegrationTestHelper\Utilities\DisableModules;
use Yireo\IntegrationTestHelper\Utilities\InstallConfig;

$disableModules = (new DisableModules())
    ->disableAll()
    ->enableMagento()
    ->enableByName('Yireo_GoogleTagManager2')
    ->toString();

return (new InstallConfig())
    ->setDisableModules($disableModules)
    ->addDb('mysql80_tmpfs')
    ->addRedis()
    ->addElasticSearch('elasticsearch6')
    ->get();
```

Instead of using a hard-coded value, you might also want to set an environment variable `MAGENTO_MODULE` - for instance, in the **Run** configuration in PHPStorm. This way, you can keep the same `install-config-mysql.php` file while reusing it for various **Run** configurations:

```php
MAGENTO_MODULE=Yireo_Example
```

Note that if your module has dependencies, they need to be added to the same environment as well:

```php
MAGENTO_MODULE=Yireo_Example,Yireo_Foobar
```

If you have a lot of requirements, you can also use the `MAGENTO_MODULE_FOLDER` variable instead, which parses your own `etc/module.xml` and adds all declared modules to the whitelist:
```php
MAGENTO_MODULE_FOLDER=app/code/Yireo/Example
```

Another example, all the Magento modules are enabled by default. But then MSI and GraphQL are disabled again, while all Yireo modules are enabled:
```php
$disableModules = (new DisableModules())
    ->disableAll()
    ->enableMagento()
    ->disableMagentoInventory()
    ->disableGraphQl()
    ->enableByPattern('Yireo_')
    ->toString();
```

Note that if there would be a module `Yireo_ExampleGraphQl` then this would be first disabled with `disableGraphQl()` and then re-enabled again with `enableByPattern('Yireo_')`. The ordering of your methods matters!

_(README truncated for .md surface. Full README on https://packagento.com/yireo/magento2-integration-test-helper.)_

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [Unreleased]

### [0.0.23] - 13 June 2026
#### Fixed
- Bump constraints
- Remove AssertModuleIsRegisteredForReal usage

### [0.0.22] - 13 June 2026
#### Fixed
- Add Symfony 7 compat
- Add debugging flag to `assertModuleIs*` calls

### [0.0.21] - 22 October 2025
#### Fixed
- Add PHP 8.4 compat

### [0.0.20] - 03 September 2025
#### Fixed
- Add support for custom MODULE.json file
- Add GitHub actions

### [0.0.19] - 24 July 2025
#### Fixed
- Upgrade PHP 8.4
- Add "dev" composer keyword

### [0.0.18] - 24 July 2025
#### Fixed
- Add type hint for PHP 8.4
- Allow server port to be either string or int
- Better detection of deps of deps
- New method addSearchEngine (instead of addElasticSearch)
- Add PHP 8.4

### [0.0.17] - 2022-2025
- Previous releases

## Recent Versions

| Version | Released |
|---|---|
| 0.0.23 | 2026-06-13 |
| 0.0.22 | 2026-06-13 |
| 0.0.21 | 2025-10-22 |
| 0.0.20 | 2025-09-03 |
| 0.0.19 | 2025-07-24 |
| 0.0.18 | 2025-07-24 |
| 0.0.17 | 2025-04-17 |
| 0.0.16 | 2025-03-14 |
| 0.0.15 | 2024-10-11 |
| 0.0.14 | 2024-10-08 |

Showing 10 of 23 versions. Full release history on https://packagento.com/yireo/magento2-integration-test-helper.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | ^101.0.1\|^101.1\|^102.0\|^103.0 |
| php | 8.0.*\|\|8.1.*\|\|8.2.*\|\|8.3.*\|\|8.4.* |

### Require (dev)

| Package | Constraint |
|---|---|
| colinmollenhour/cache-backend-redis | ^1.17 |
| ext-json | * |
| ext-pcre | * |
| guzzlehttp/guzzle | ^6.0\|^7.0 |
| magento/zend-cache | ^1.16 |
| symfony/console | ^5.0\|^6.0\|^7.0 |

## Quality

Latest release (0.0.23) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | not tested |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 37 | 1 error, 36 warnings (ruleset: Magento2) — 11 auto-fixable with phpcbf |
| PHPMD | Error | 0 | phpmd produced unparseable XML output (exit=1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 7 | 7 | – | – |
| 2.4.8 | – | 7 | 7 | – |
| 2.4.9 | – | – | 7 | N/A |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | not tested |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["yireo/magento2-integration-test-helper"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

yireo is a Magento 2 vendor on Packagento. See https://packagento.com/yireo.md for their full catalogue.

