@secondman I don’t understand what you’re actually trying to test here?
Feb 17, 2023
6
Level 17
Remove a route for testing
I'm working on the RegistrationTest in Jetstream and I'm trying to enable/disable the Features::registration so that the page rendering in each scenario isn't skipped.
In my Pest file I created a helper to update the fortify config so the test will run if registration is enabled, but I also need to unregister the register route so the 404 assertion will return true.
Previously you could use the Auth::routes() facade method, but now that only works if you have laravel/ui installed.
My test looks like so:
it('disables the registration screen render if support is disabled', function () {
$response = $this->get('/register');
$response->assertStatus(404);
})->skip(function () {
disableRegistration(); // see next block
return Features::enabled(Features::registration());
}, 'Registration support is enabled.');
And here's my helper:
function disableRegistration()
{
$features = config('fortify.features');
// registration is always at key 0
// unless you change your config.
if ($features[0] === 'registration') {
array_shift($features);
}
config(['fortify.features' => $features]);
// NOPE, this won't work without laravel/ui
Auth::routes(['register' => false]);
}
Any ideas would be appreciated.
Please or to participate in this conversation.