yiisoft/test-support
Testing utilities for Yii applications: helpers and fixtures to simplify unit and integration tests, isolate dependencies, and improve readability. Provides common test tools you can reuse across packages and projects.
This package provides foundational utilities for testing Yiisoft-based applications, particularly for integration and unit tests. Start by installing it via Composer:
composer require --dev yiisoft/test-support
The primary entry point is the Yiisoft\Test\Support\Container\ContainerTraverser and Yiisoft\Test\Support\TestCase\TestCase, which you’ll extend in your test classes. Begin by replacing your base test class with Yiisoft\Test\Support\TestCase\TestCase, which sets up a clean application container and handles reset between tests.
TestCase to get automatic container isolation. Use setUp() and tearDown() as usual—TestCase handles resetting the container state.ContainerTrait to inject container-aware functionality into non-TestCase classes (e.g., test helpers or custom fixtures).Yiisoft\Test\Support\Stub namespace classes (Stub\ClassWithDependencies, Stub\NullLogTarget, etc.) for predictable test doubles without relying on external frameworks.yiisoft/yii-web-test—test-support provides the low-level container tools that web-test builds on.TestCase, manually instantiated containers outside the test case lifecycle won’t auto-reset—always use $this->container provided by the test case.ContainerInterface::clear() or stub dependencies that cache state.yiisoft/test-support matches your yiisoft/core and yiisoft/di versions.createContainer() in your test case for custom container configurations (e.g., pre-loading config overrides or test-only providers).How can I help you explore Laravel packages today?