Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 25, 2023
1 parent 30ee967 commit ccfbf44
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Console/ProviderMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,15 @@ protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return rtrim($this->generatorPreset()->providerNamespace(), '\\');
}
}
21 changes: 21 additions & 0 deletions tests/Feature/Console/ProviderMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace Orchestra\Canvas\Tests\Feature\Console;

use Orchestra\Canvas\Presets\Laravel;
use Orchestra\Canvas\Tests\Feature\TestCase;

class ProviderMakeCommandTest extends TestCase
{
protected $files = [
'app/Providers/FooServiceProvider.php',
'app/FooServiceProvider.php',
];

/** @test */
Expand All @@ -24,4 +26,23 @@ public function it_can_generate_service_provider_file()
'public function boot()',
], 'app/Providers/FooServiceProvider.php');
}

/** @test */
public function it_can_generate_service_provider_file_with_custom_namespace()
{
$this->instance('orchestra.canvas', new Laravel(
['namespace' => 'App', 'provider' => ['namespace' => 'App']], $this->app->basePath()
));

$this->artisan('make:provider', ['name' => 'FooServiceProvider', '--preset' => 'canvas'])
->assertSuccessful();

$this->assertFileContains([
'namespace App;',
'use Illuminate\Support\ServiceProvider;',
'class FooServiceProvider extends ServiceProvider',
'public function register()',
'public function boot()',
], 'app/FooServiceProvider.php');
}
}

0 comments on commit ccfbf44

Please sign in to comment.