Weave 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
Symfony Config Test

Symfony Config Test Laravel Package

matthiasnoback/symfony-config-test

PHPUnit helpers for testing Symfony Config definitions. Provides a test case trait and assertions to validate config trees, ensuring required nodes, types, and constraints behave as expected by asserting valid and invalid configuration arrays.

View on GitHub
Deep Wiki
Context7

Library for testing user classes related to the Symfony Config Component

Frequently asked questions about Symfony Config Test
What is matthiasnoback/symfony-config-test used for?
It provides PHPUnit helpers for testing Symfony Config component definitions, especially ConfigurationInterface classes built with TreeBuilder. You can assert that configuration arrays are valid or invalid and verify processed values such as defaults and merged settings. In Laravel projects it is useful when a package or adapter uses Symfony Config rather than Laravel's native array-based config.
How do I install matthiasnoback/symfony-config-test in a Laravel project?
Install it as a development dependency with composer require --dev matthiasnoback/symfony-config-test. It requires symfony/config and a compatible PHPUnit version, so Composer may update those dev dependencies. Because it only supports tests, it should not be added to production runtime dependencies.
Does symfony-config-test work with native Laravel config files?
Not directly. Laravel's config/*.php files are plain arrays, while this package tests Symfony Config trees that implement ConfigurationInterface. To use it with Laravel-style configuration you would need a thin adapter or configuration class that builds a Symfony TreeBuilder from the relevant settings. For packages that already use Symfony Config, integration is straightforward.
Which Laravel and PHPUnit versions are supported?
The package does not target Laravel versions directly; compatibility depends on your PHP version, PHPUnit version, and symfony/config constraint. The evaluation notes PHPUnit 9.6 through 13.x and symfony/config 4.4+ or 5.0 through 5.3 as relevant ranges. Check your Laravel project's Composer constraints before installing, especially if other packages pin Symfony components.
How do I test that a required config node is missing?
Create a PHPUnit TestCase that uses ConfigurationTestCaseTrait and implement getConfiguration to return your ConfigurationInterface instance. Then call assertConfigurationIsInvalid with an empty array or the invalid configuration and optionally the expected error message. This verifies that Symfony Config rejects missing required nodes as intended.
Can it validate default values and merged configuration?
Yes. The trait includes assertions such as assertProcessedConfigurationEquals, which let you compare the fully processed configuration against an expected array. That is useful for checking defaults, environment-style overrides, and merge behavior in Symfony Config trees. It complements invalid-configuration assertions by testing the final normalized result.
How does ConfigurationTestCaseTrait work?
You add the trait to a normal PHPUnit TestCase and implement getConfiguration so the trait can obtain the configuration under test. The trait then exposes assertion methods for invalid configuration and processed configuration comparisons. This keeps configuration tests small and avoids custom boilerplate around Symfony's Config component.
Is symfony-config-test safe to use in production?
It is designed as a dev-only PHPUnit helper and does not modify application runtime behavior. You should install it with --dev and run it only in test environments. Production deployments typically exclude dev dependencies, so it should not affect runtime configuration loading.
What are alternatives for testing Laravel configuration?
For native Laravel config you can use custom PHPUnit assertions, config repository tests, or package-specific validation logic without Symfony Config. This package is the better fit when your code already implements Symfony ConfigurationInterface and uses TreeBuilder. Alternatives like symfony/yaml or plain PHPUnit assertions do not provide the same configuration-tree assertions out of the box.
How do I avoid Symfony version conflicts in a Laravel project?
Pin a symfony/config version that is compatible with your Laravel dependencies and audit Composer for conflicts before adopting the package widely. Since this is a dev dependency, isolate it from production constraints where possible. If another package already requires Symfony Config, align versions rather than adding conflicting constraints.
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.
thuraaung2493/laravel-rulecraft
cyberwizard/schedule-catchup
livetennisapi/livetennisapi-laravel
roundly-consulting/notifications-for-laravel
flightsadmin/bootstrap-starter-kit
lasserafn/laravel-intempus
likyly/sdk
tdt/input
coreation/php-shapefile
coreation/gisconverter
primix/widgets
primix/notifications
primix/actions
primix/tables
primix/details
primix/forms
primix/support
marcelgwerder/laravel-api-handler
firebrikdotcom/conveyor-laravel-broadcaster
kanata-php/conveyor-laravel-broadcaster