Testing
When testing a package, you may encounter config access issues, especially with the magicfrom() factory method which requires config access to resolve the factory instance.
Orchestra Testbench Setup
Include the Laravel Data service provider in your package’s TestCase:Complete Test Example
Publishing Config
If your package needs custom data configuration, publish a config file:Create Package Config
Register in Service Provider
Package Structure
Recommended structure for packages using Laravel Data:Composer Dependencies
Add Laravel Data to your package’scomposer.json:
Example: Package Data Class
Testing Without Orchestra
If not using Orchestra Testbench, manually boot the service provider:The Orchestra Testbench approach is recommended as it provides a full Laravel application environment for testing.