Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Container Config Test Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

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.

Gotchas and Tips

  • Config caching breaks tests: Ensure config_cache_enabled is false during test execution—the test class explicitly disables caching, but any custom ApplicationConfig bootstrap may override this.
  • Factory signatures matter: If your factory’s __invoke() or __invoke(ContainerInterface, $requestedName) signature is wrong (e.g., missing type hints), tests will fail before app execution—use this to catch early.
  • Aliases vs. services: assertServiceAvailable('ServiceA') only checks existence; assertService('ServiceA', ExpectedClass::class) checks resolved type—use the latter to validate that aliases resolve to intended concrete classes.
  • Hidden dependencies: The package doesn’t validate circular dependencies or runtime failures during factory execution. For that, add integration tests for key factory logic separately.
  • CI optimization: Use --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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport