laminas/laminas-container-config-test
Test helper for Laminas container configuration: validates service/container config arrays and wiring in a predictable way for unit tests. Useful for ensuring factories, aliases, and dependencies are registered correctly across your Laminas modules.
Begin by installing the package via Composer (composer require --dev laminas/laminas-container-config-test) and extending its base test class (LaminasTest\ServiceManager\Test\AbstractConfigTestCase). Your first test should validate that your config/services.php (or module config files) can bootstrap a container and resolve a core service—e.g., RouterInterface—without errors. Use assertConfig($config) to bootstrap the container, then assertServiceAvailable($name) or assertService($name, $expectedClass) to verify resolvability. Run phpunit—no container setup needed beyond your config array.
Use this package in conjunction with your existing service configuration (e.g., in config/autoload/*.local.php, module configs, or shared config files). Create dedicated test suites (e.g., Config/ContainerTest.php) that group assertions by domain: Factories, Aliases, Delegators, etc. For example:
public function testRouterAliasResolvesCorrectly(): void
{
$this->assertService('Router', \Laminas\Mvc\Router\RouteMatch::class);
}
Leverage assertServiceDelegator($name, $delegator) and assertServiceFactory($name, $factory) to verify factory/delegator wiring explicitly. When using module-based configs, pass a config array containing all relevant modules via setUpConfig() or override getConfig() to aggregate configs. For large projects, run config tests in parallel (via --process-isolation) or split them by module for granular CI feedback.
config_cache_enabled is false during test execution—the test class explicitly disables caching, but any custom ApplicationConfig bootstrap may override this.__invoke() or __invoke(ContainerInterface, $requestedName) signature is wrong (e.g., missing type hints), tests will fail before app execution—use this to catch early.assertServiceAvailable('ServiceA') only checks existence; assertService('ServiceA', ExpectedClass::class) checks resolved type—use the latter to validate that aliases resolve to intended concrete classes.--group container-config to run only config tests in CI pre-commit hooks; this suite is intentionally fast (no DB/file I/O), ideal for frequent execution.How can I help you explore Laravel packages today?