Closed aaronbushnell closed 1 year ago
Thanks again for your help on that PR, @markhuot!
Shoot, I should've caught this, @markhuot, but because the :array
return type got added in I get the original error again:
❯ php craft pest/test
FAIL Tests\ExampleTest
⨯ it loads the homepage
⨯ it allows an admin to sign in
---
• Tests\ExampleTest > it loads the homepage
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▕ }
Couple ways around this:
:array|BaseConfig
. But the downside, like you mentioned earlier, is an older version of Craft on PHP 7 won't have this option.<?php
namespace craft\services;
class Config extends \markhuot\craftpest\overrides\Config
{
public function getConfigFromFile(string $filename): array
{
$original = parent::getConfigFromFile($filename);
if (!is_array($original) || $filename !== 'app.web') {
return collect($original)->toArray();
}
return array_merge($original, require __DIR__ . '/../config/app.web.php');
}
}
Happy to deliver that change in a new PR if that's helpful!
If your general.php file uses the fluent-style for your config you'll get an error when running your tests:
Example config (using fluent syntax):
Changing this to the standard array-based config will allow it to work:
Example config (using arrays):