markhuot / craft-pest

https://craft-pest.com
Other
38 stars 11 forks source link

Return value must be of type array, craft\config\GeneralConfig returned #81

Closed jorisnoo closed 1 year ago

jorisnoo commented 1 year ago

Hi — and thank you so much for all your work on this plugin! I'm excited to use pest for testing Craft sites.

After installing the plugin, I'm running into the following error:

  • Tests\ExampleTest > get '/' → assertOk
   PHPUnit\Framework\ExceptionWrapper

  craft\services\Config::getConfigFromFile(): Return value must be of type array, craft\config\GeneralConfig returned

  at vendor/markhuot/craft-pest/src/services/Config.php:17
     13▕     {
     14▕         $original = parent::getConfigFromFile($filename);
     15▕
     16▕         if (!is_array($original) || $filename !== 'app.web') {
  ➜  17▕             return $original;
     18▕         }
     19▕
     20▕         return array_merge($original, require __DIR__ . '/../config/app.web.php');
     21▕     }

I'm using the fluent GeneralConfig::create() config in config/general.php (and haven't been able to dive into the source code in search for a solution yet, but hope it's ok to post the error message nevertheless).

jorisnoo commented 1 year ago

Ah, seems to be a duplicate of #70 🙇

markhuot commented 1 year ago

Ah, if it's a duplicate of #70 then updating to the latest alpha release should fix it!

cmalven commented 1 year ago

I'm still getting this error using 1.0.0-alpha12 when returning GeneralConfig in general.php. Is this not the latest alpha version?

d-karstens commented 1 year ago

I was encountering this error as well and managed to get it to work by changing this line https://github.com/markhuot/craft-pest/blob/master/src/craft/services/Config.php#L17 to return collect($original)->toArray(); as mentioned in the solution for #70

Hopefully this helps!

tdefilippis commented 7 months ago

In order to access the latest changes I had to run

composer require "markhuot/craft-pest":"dev-master"

What are the chances a new release could be shipped? Currently, if you install from the craft plugin page, it doesn't install latest changes in the master branch.

russback commented 4 months ago

Also came across this today on a fresh install