Kārlis Janisels
Kārlis Janisels

Reputation: 1295

How to test routes that are added dynamically by Laravel package

I want to create a package from a module that I created in my project but can't figure out how to cover the package with tests.

The package will add some routes and it should allow choosing which ones to add and what prefix to use.

I suppose it's possible by either allowing to publish a config file that would have keys like prefix or exposing Configuration class that can be used in provider's boot method, for example, \Vendor\Package\Configuration::prefix()

But I don't understand how can I write feature tests for my package. If I try to set the configuration at the start of the test and then assert that specific endpoints return 200 OK I'm getting 404 not found because the application has been fully booted at the time I apply configuration.

Is there a way to supply configuration before test case boots the application of a way to "hook into" boot process?

Upvotes: 1

Views: 268

Answers (0)

Related Questions