Search by

horat1us / yii2-phpunit

Horat1us

Yii 2 PHPUnit compatibility layer and enhancements

Package info

github.com/Horat1us/yii2-phpunit

pkg:composer/horat1us/yii2-phpunit

Statistics

Installs: 72

Dependents: 0

Suggesters: 0

Stars: 0

0.1.0 2026-10-26 11:38 UTC

This package is auto-updated.

Last update: 2026-10-26 12:18:08 UTC


README

Test & Lint

Yii 2 PHPUnit compatibility layer and enhancements This package includes:

  • TestLogger - will display all log messages to console
  • TestMailer - will collect all sent mails in memory
  • TestCase - base TestCase, extends PHPUnit TestCase. It will create new \yii\console\Application instance before each test and apply Yii2 fixtures. After each test it restores the error and exception handlers registered by the application.
  • MigrateFixture - Yii2 fixture that will apply migration. Use case: your package contains migrations and you need to apply it before tests.

Note: this package supposed to support old packages, that depends on it

Compatibility: tested on PHP 8.4, PHP 8.5 (PHPUnit 13). Projects on PHPUnit 9 stay on 0.0.x.

Usage

  • Install package and horat1us/yii2-phpunit as dev dependencies
composer require --dev horat1us/yii2-phpunit:^0.1
  • Configure your PHPUnit and create bootstrap file with alias to config:
<?php
// bootstrap.php

Yii::setAlias('@configFile', 'path-to-config.php');

Testing

The tests use an in-memory SQLite database (pdo_sqlite). Set DB_DSN, DB_USERNAME and DB_PASSWORD to run them against another database.

composer test

License

LICENSE

Example

See horat1us/yii2-advanced-package for details.