From 29a328b9cb8d3100417abc1030b22c6713e63ba2 Mon Sep 17 00:00:00 2001 From: Jasper Tey Date: Fri, 22 Nov 2024 20:42:30 -0500 Subject: [PATCH] Fix for laravel 10. --- src/Commands/DomainControllerMakeCommand.php | 2 +- tests/Generator/ControllerMakeTest.php | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/Commands/DomainControllerMakeCommand.php b/src/Commands/DomainControllerMakeCommand.php index cab4763..2e50e0f 100644 --- a/src/Commands/DomainControllerMakeCommand.php +++ b/src/Commands/DomainControllerMakeCommand.php @@ -64,7 +64,7 @@ protected function buildClass($name) $replace = []; $appRootNamespace = $this->laravel->getNamespace(); - $pathToAppBaseController = parent::getPath("Http\Controllers\Controller"); + $pathToAppBaseController = app_path('Http/Controllers/Controller.php'); $baseControllerExists = $this->files->exists($pathToAppBaseController); diff --git a/tests/Generator/ControllerMakeTest.php b/tests/Generator/ControllerMakeTest.php index 3bf0448..1fb74cf 100644 --- a/tests/Generator/ControllerMakeTest.php +++ b/tests/Generator/ControllerMakeTest.php @@ -41,15 +41,8 @@ expect($contents) ->toContain("namespace {$expectedNamespace};") - ->toContain("use App\Http\Controllers\Controller;") + ->toContain("use App\Http\Controllers\Controller;".PHP_EOL."use Illuminate\Http\Request;") ->toContain('extends Controller'); - - // if (Feature::Laravel11->exists()) { - // // These assertions don't seem to pass on Laravel 10 - // expect($contents) - // ->toContain("use App\Http\Controllers\Controller;") - // ->toContain('extends Controller'); - // } })->with([ 'Invoicing:InvoiceController' => [ 'Invoicing', @@ -232,12 +225,9 @@ expect($contents = file_get_contents($expectedPath)) ->toContain("namespace {$expectedNamespace};"); - if (Feature::Laravel11->exists()) { - // These assertions don't seem to pass on Laravel 10 - expect($contents) - ->not->toContain("use App\Http\Controllers\Controller;") - ->not->toContain('extends Controller'); - } + expect($contents) + ->not->toContain("use App\Http\Controllers\Controller;") + ->not->toContain('extends Controller'); })->with([ 'Invoicing:InvoiceController' => [ 'Invoicing',