Skip to content

Commit 6d19a48

Browse files
committed
Fix test
1 parent aed6c0c commit 6d19a48

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/Console/MetaCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,16 @@ protected function getExpectedArguments()
251251
*/
252252
protected function loadTemplate($name)
253253
{
254-
if (!isset($this->templates[$name])) {
254+
if (!isset($this->templateCache[$name])) {
255255
$file = __DIR__ . '/../../php-templates/' . basename($name) . '.php';
256-
$this->templates[$name] = $this->files->requireOnce($file);
256+
$value = $this->files->requireOnce($file) ?: [];
257+
if (!$value instanceof Collection) {
258+
$value = collect($value);
259+
}
260+
$this->templateCache[$name] = $value;
257261
}
258262

259-
return $this->templates[$name];
263+
return $this->templateCache[$name];
260264
}
261265

262266
/**

tests/Console/MetaCommand/MetaCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testCommand(): void
2727

2828
$mockFileSystem
2929
->shouldReceive('getRequire')
30-
->andReturnUsing(function ($__path, $__data) {
30+
->andReturnUsing(function ($__path, $__data = []) {
3131
return (static function () use ($__path, $__data) {
3232
extract($__data, EXTR_SKIP);
3333

@@ -60,7 +60,7 @@ public function testUnregisterAutoloader(): void
6060

6161
$mockFileSystem
6262
->shouldReceive('getRequire')
63-
->andReturnUsing(function ($__path, $__data) {
63+
->andReturnUsing(function ($__path, $__data = []) {
6464
return (static function () use ($__path, $__data) {
6565
extract($__data, EXTR_SKIP);
6666

0 commit comments

Comments
 (0)