zendframework/zend-container-config-test
Common test suite for PSR-11 containers configured with a subset of zend-servicemanager/Expressive config. Extend AbstractContainerTest and add traits for aliases, factories, services, etc. Supports Aura.Di, Pimple, and zend-servicemanager. Repository abandoned; moved to laminas.
Start by installing the package into your phpunit test environment:
composer require --dev zendframework/zend-container-config-test
After installation, extend the base test class ZendTest\Container\IntegrationTestCase in your container test suite. Your first use case is validating that your application’s service configuration can be bootstrapped correctly — for example, by creating a config/services.php test to ensure all registered factories and services resolve without errors:
use ZendTest\Container\IntegrationTestCase;
class ContainerConfigTest extends IntegrationTestCase
{
protected function getConfig(): array
{
return require __DIR__ . '/../config/services.php';
}
public function testServiceConfigLoads(): void
{
$this->assertArrayHasService('MyService');
$this->assertCanCreateServiceFromFactory('MyService');
}
}
config/config.php) and asserts all services defined in service_manager are resolvable. This catches broken factory signatures or missing dependencies early.assertCanCreateServiceFromFactory() to verify the factory and its dependencies instantiate correctly.laminas/laminas-servicemanager’s built-in ServiceManager::has() / get() for newer patterns.autoload-dev (e.g., in test/), runtime errors may occur during config loading — ensure your phpunit.xml includes all relevant paths.assertCanCreateServiceFromFactory() will surface circular references as RuntimeException — use this to refactor problematic wiring.createContainer() in your test class to inject your own configuration aggregator.How can I help you explore Laravel packages today?