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

Zend Container Config Test Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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');
    }
}

Implementation Patterns

  • Validate full config consistency: Run a single test that loads your entire config (e.g., config/config.php) and asserts all services defined in service_manager are resolvable. This catches broken factory signatures or missing dependencies early.
  • Isolate service resolution failures: For complex services (e.g., Doctrine repositories or custom Doctrine repositories), use assertCanCreateServiceFromFactory() to verify the factory and its dependencies instantiate correctly.
  • Test factories independently: In TDD workflows, write container config tests alongside factory development to verify that factory signatures match their expected dependencies (e.g., constructor types).
  • CI integration: Include these tests in your CI pipeline as fast, low-overhead sanity checks on config changes — no database or HTTP stack required.

Gotchas and Tips

  • Archived & unmaintained: Since the package is archived (as of 2019), ensure compatibility with your Laminas version. For Laminas 3+, it still works, but prefer laminas/laminas-servicemanager’s built-in ServiceManager::has() / get() for newer patterns.
  • Namespace and class autoloading: If factories/services reference classes not in your autoload-dev (e.g., in test/), runtime errors may occur during config loading — ensure your phpunit.xml includes all relevant paths.
  • Avoid over-mocking: The goal is real instantiation, not mocked resolution. Don’t override services with mocks unless testing specific factory behavior.
  • Handle circular dependencies: These often surface at runtime. Tests using assertCanCreateServiceFromFactory() will surface circular references as RuntimeException — use this to refactor problematic wiring.
  • Extension point: For custom container setups (e.g., PSR-11 adapters), override createContainer() in your test class to inject your own configuration aggregator.
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