Support the ongoing development of Laravel.io →
posted 10 years ago
Testing

Unable to successfully mock Config::shouldReceive('get')->with('my_testing_param_here'); because the application boots and it will start to ask you for every single required app configuration parameter

My test started to look like this before I called it quits:

        Config::shouldReceive('offsetGet')
            ->with('database.default')
            ->andReturn('DEFAULT_DATABASE')
        ;

        Config::shouldReceive('offsetGet')
            ->with('database.connections')
            ->andReturn(['DEFAULT_DATABASE' => [
            'driver'    => 'mysql',
            'host'      => 'HOST'
            'database'  => 'DATABASE',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ]])
        ;

        Config::shouldReceive('offsetGet')->with('database.fetch');
        
        // never ending configuration parameters until the application is fully booted

This is totally untestable if you're trying to just get a Config value. Is there a shortcut method out there?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.