orchestral/testbench

ServiceProvider call `publishes`, but not has publish config

Closed this issue · 1 comments

  • Testbench Version: 5.20.0 (Composer is : "^4.0|^5.0")
  • Laravel Version: Only orchestra/testbench
  • PHP Version: 8.0.20 (NTS Visual C++ 2019 x64)

Description:

The provider will call:

        $this->publishes([
            __DIR__ . '/../config/gconfig.php' => config_path('gconfig.php'),
        ]);
        var_dump(config('gconfig.cache')); // print NULL
        exit;

The file is has and IDE can quick link to it.

If I manual copy to D:\...\global-config\vendor\orchestra\testbench-core\laravel\config, the config can found at config('gconfig.cache').

Steps To Reproduce:

I submit in my repo: Global Config, you can test or read it...

boot call the sub function:

https://github.com/Sun-FreePort/global-config/blob/main/src/GlobalConfigServiceProvider.php#L44-L49

    protected function registerConfig()
    {
        $this->publishes([
            __DIR__ . '/../config/gconfig.php' => config_path('gconfig.php'),
        ]);
    }

Interim, i use defineEnvironment in test, but I real want to know, how to fix it.

Not a bug with Testbench, you just add publish command to Service Provider, that doesn't load the config automatically.