From 6d19a48da4637dc35d724c5b079241df46559e38 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 29 Dec 2024 19:42:42 +0100 Subject: [PATCH] Fix test --- src/Console/MetaCommand.php | 10 +++++++--- tests/Console/MetaCommand/MetaCommandTest.php | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index cccc0f5..7e83cda 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -251,12 +251,16 @@ class MetaCommand extends Command */ protected function loadTemplate($name) { - if (!isset($this->templates[$name])) { + if (!isset($this->templateCache[$name])) { $file = __DIR__ . '/../../php-templates/' . basename($name) . '.php'; - $this->templates[$name] = $this->files->requireOnce($file); + $value = $this->files->requireOnce($file) ?: []; + if (!$value instanceof Collection) { + $value = collect($value); + } + $this->templateCache[$name] = $value; } - return $this->templates[$name]; + return $this->templateCache[$name]; } /** diff --git a/tests/Console/MetaCommand/MetaCommandTest.php b/tests/Console/MetaCommand/MetaCommandTest.php index fad391e..116f7ae 100644 --- a/tests/Console/MetaCommand/MetaCommandTest.php +++ b/tests/Console/MetaCommand/MetaCommandTest.php @@ -27,7 +27,7 @@ class MetaCommandTest extends TestCase $mockFileSystem ->shouldReceive('getRequire') - ->andReturnUsing(function ($__path, $__data) { + ->andReturnUsing(function ($__path, $__data = []) { return (static function () use ($__path, $__data) { extract($__data, EXTR_SKIP); @@ -60,7 +60,7 @@ class MetaCommandTest extends TestCase $mockFileSystem ->shouldReceive('getRequire') - ->andReturnUsing(function ($__path, $__data) { + ->andReturnUsing(function ($__path, $__data = []) { return (static function () use ($__path, $__data) { extract($__data, EXTR_SKIP);