diff --git a/composer.json b/composer.json index 3d4941b2e..2bce92201 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,7 @@ "require": { "php": ">=8.2", "ext-json": "*", - "wikimedia/composer-merge-plugin": "^2.1", - "laravel/pint": "^1.16" + "wikimedia/composer-merge-plugin": "^2.1" }, "require-dev": { "phpunit/phpunit": "^11.0", @@ -29,6 +28,7 @@ "orchestra/testbench": "^v9.0", "friendsofphp/php-cs-fixer": "^v3.52", "laravel/framework": "^v11.0", + "laravel/pint": "^1.16", "spatie/phpunit-snapshot-assertions": "^5.0", "phpstan/phpstan": "^1.4" }, diff --git a/config/config.php b/config/config.php index 44c699e7c..c233e1329 100644 --- a/config/config.php +++ b/config/config.php @@ -168,6 +168,38 @@ ], ], + /* + |-------------------------------------------------------------------------- + | Auto Discover of Modules + |-------------------------------------------------------------------------- + | + | Here you configure auto discover of module + | This is useful for simplify module providers. + | + */ + 'auto-discover' => [ + /* + |-------------------------------------------------------------------------- + | Migrations + |-------------------------------------------------------------------------- + | + | This option for register migration automatically. + | + */ + 'migrations' => true, + + /* + |-------------------------------------------------------------------------- + | Translations + |-------------------------------------------------------------------------- + | + | This option for register lang file automatically. + | + */ + 'translations' => false, + + ], + /* |-------------------------------------------------------------------------- | Package commands diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 6706e0f2d..dcb740df1 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -6,13 +6,14 @@ use Illuminate\Console\ConfirmableTrait; use Illuminate\Console\Prohibitable; use Illuminate\Contracts\Console\PromptsForMissingInput; +use Illuminate\Support\Collection; use Nwidart\Modules\Contracts\ConfirmableCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use function Laravel\Prompts\multiselect; +use function Laravel\Prompts\multisearch; abstract class BaseCommand extends Command implements PromptsForMissingInput { @@ -29,18 +30,22 @@ abstract class BaseCommand extends Command implements PromptsForMissingInput public function __construct() { parent::__construct(); - $this->getDefinition()->addOption(new InputOption( - strtolower(self::ALL), - 'a', - InputOption::VALUE_NONE, - 'Check all Modules', - )); - - $this->getDefinition()->addArgument(new InputArgument( - 'module', - InputArgument::IS_ARRAY, - 'The name of module will be used.', - )); + $this->getDefinition()->addOption( + option: new InputOption( + name: strtolower(self::ALL), + shortcut: 'a', + mode: InputOption::VALUE_NONE, + description: 'Check all Modules', + ) + ); + + $this->getDefinition()->addArgument( + argument: new InputArgument( + name: 'module', + mode: InputArgument::IS_ARRAY, + description: 'The name of module will be used.', + ) + ); if ($this instanceof ConfirmableCommand) { $this->configureConfirmable(); @@ -98,12 +103,16 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf return; } - $selected_item = multiselect( - label : 'Select Modules', - options : [ - self::ALL, - ...$modules, - ], + $selected_item = multisearch( + label: 'Select Modules', + options: function (string $search_value) use ($modules) { + return collect([ + self::ALL, + ...$modules, + ])->when(strlen($search_value) > 0, function (Collection &$modules) use ($search_value) { + return $modules->filter(fn ($item) => str_contains(strtolower($item), strtolower($search_value))); + })->values()->toArray(); + }, required: 'You must select at least one module', ); @@ -125,11 +134,13 @@ protected function getModuleModel($name) private function configureConfirmable(): void { $this->getDefinition() - ->addOption(new InputOption( - 'force', - null, - InputOption::VALUE_NONE, - 'Force the operation to run without confirmation.', - )); + ->addOption( + option: new InputOption( + name: 'force', + shortcut: null, + mode: InputOption::VALUE_NONE, + description: 'Force the operation to run without confirmation.', + ) + ); } } diff --git a/src/Commands/Database/MigrateFreshCommand.php b/src/Commands/Database/MigrateFreshCommand.php index 94940b8aa..24a3c4639 100644 --- a/src/Commands/Database/MigrateFreshCommand.php +++ b/src/Commands/Database/MigrateFreshCommand.php @@ -55,6 +55,7 @@ public function handle(): void // run migration of root $root_paths = $this->migration_paths + ->push($this->laravel->databasePath().DIRECTORY_SEPARATOR.'migrations') ->reject(fn (string $path) => str_starts_with($path, config('modules.paths.modules'))); if ($root_paths->count() > 0) { diff --git a/src/Commands/ModuleClearCompiledCommand.php b/src/Commands/ModuleClearCompiledCommand.php new file mode 100644 index 000000000..c02cb0bf4 --- /dev/null +++ b/src/Commands/ModuleClearCompiledCommand.php @@ -0,0 +1,32 @@ +manifestPath)) { + @unlink($manifest->manifestPath); + } + + $this->components->info('Compiled module files removed successfully.'); + } +} diff --git a/src/Commands/ModuleDiscoverCommand.php b/src/Commands/ModuleDiscoverCommand.php new file mode 100644 index 000000000..f83f071cb --- /dev/null +++ b/src/Commands/ModuleDiscoverCommand.php @@ -0,0 +1,36 @@ +components->info('Discovering modules'); + + $manifest->build(); + + collect($manifest->providersArray()) + ->map(fn ($provider) => preg_match('/Modules\\\\(.*?)\\\\/', $provider, $matches) ? $matches[1] : null) + ->unique() + ->each(fn ($description) => $this->components->task($description)) + ->whenNotEmpty(fn () => $this->newLine()); + } +} diff --git a/src/Commands/stubs/controller.stub b/src/Commands/stubs/controller.stub index 04aaefd2b..610fbd341 100644 --- a/src/Commands/stubs/controller.stub +++ b/src/Commands/stubs/controller.stub @@ -3,9 +3,7 @@ namespace $CLASS_NAMESPACE$; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class $CLASS$ extends Controller { @@ -28,7 +26,7 @@ class $CLASS$ extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class $CLASS$ extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/src/Commands/stubs/event-provider.stub b/src/Commands/stubs/event-provider.stub index 4ed5a033a..f2f67fc8e 100644 --- a/src/Commands/stubs/event-provider.stub +++ b/src/Commands/stubs/event-provider.stub @@ -22,11 +22,9 @@ class $CLASS$ extends ServiceProvider /** * Configure the proper event listeners for email verification. - * - * @return void */ protected function configureEmailVerification(): void { - + // } } diff --git a/src/Commands/stubs/model.stub b/src/Commands/stubs/model.stub index ba4f52919..1d45d1dfa 100644 --- a/src/Commands/stubs/model.stub +++ b/src/Commands/stubs/model.stub @@ -4,7 +4,7 @@ namespace $NAMESPACE$; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use $MODULE_NAMESPACE$\$MODULE$\Database\Factories\$NAME$Factory; +// use $MODULE_NAMESPACE$\$MODULE$\Database\Factories\$NAME$Factory; class $CLASS$ extends Model { @@ -15,8 +15,8 @@ class $CLASS$ extends Model */ protected $fillable = $FILLABLE$; - protected static function newFactory(): $NAME$Factory - { - //return $NAME$Factory::new(); - } + // protected static function newFactory(): $NAME$Factory + // { + // // return $NAME$Factory::new(); + // } } diff --git a/src/Constants/ModuleEvent.php b/src/Constants/ModuleEvent.php new file mode 100644 index 000000000..d19c8d365 --- /dev/null +++ b/src/Constants/ModuleEvent.php @@ -0,0 +1,30 @@ +app = $app; $this->path = $path; @@ -82,76 +82,159 @@ public function __construct(Container $app, $path = null) } /** - * Add other module location. + * {@inheritDoc} + */ + public function boot(): void + { + foreach ($this->ordered() as $module) { + $module->boot(); + } + } + + /** + * {@inheritDoc} + */ + public function register(): void + { + foreach ($this->ordered() as $module) { + $module->register(); + } + } + + /** + * Creates a new Module instance * + * @param Container $app + * @param string $args * @param string $path - * @return $this */ - public function addLocation($path) + abstract protected function module(...$args): Module; + + /** + * @deprecated 10.0.11 use module() + */ + protected function createModule(...$args) { - $this->paths[] = $path; + return $this->module(...$args); + } - return $this; + /** + * Install the specified module. + */ + public function install(string $name, string $version = 'dev-master', string $type = 'composer', bool $subtree = false): Process + { + $installer = new Installer($name, $version, $type, $subtree); + + return $installer->run(); } /** - * Get all additional paths. + * {@inheritDoc} */ - public function getPaths(): array + public function all(?bool $enabled = null): array { - return $this->paths; + if (is_bool($enabled)) { + if ($enabled) { + return $this->status(true); + } + + return $this->status(false); + } + + if (!$this->config('cache.enabled')) { + return $this->scan(); + } + + return $this->formatCached($this->cached()); } /** - * Get scanned modules paths. + * @deprecated 10.0.11 use all(true) or status(true) */ - public function getScanPaths(): array + public function allEnabled(): array { - $paths = $this->paths; + return $this->status(true); + } - $paths[] = $this->getPath(); + /** + * @deprecated 10.0.11 use all(false) or status(false) + */ + public function allDisabled(): array + { + return $this->status(false); + } - if ($this->config('scan.enabled')) { - $paths = array_merge($paths, $this->config('scan.paths')); + /** + * {@inheritDoc} + */ + public function find(string $name): ?Module + { + foreach ($this->all() as $module) { + if ($module->getLowerName() === strtolower($name)) { + return $module; + } } - $paths = array_map(function ($path) { - return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); - }, $paths); + return null; + } - return $paths; + /** + * {@inheritDoc} + */ + public function findOrFail(string $name): Module + { + $module = $this->find($name); + + if ($module !== null) { + return $module; + } + + throw new ModuleNotFoundException("Module [{$name}] does not exist!"); } /** - * Creates a new Module instance - * - * @param Container $app - * @param string $args - * @param string $path - * @return \Nwidart\Modules\Module + * Get modules by the given status. */ - abstract protected function createModule(...$args); + public function status(bool $status): array + { + $modules = []; + + /** @var Module $module */ + foreach ($this->all() as $name => $module) { + if ($module->isStatus($status)) { + $modules[$name] = $module; + } + } + + return $modules; + } /** - * Get & scan all modules. - * - * @return array + * @deprecated 10.0.11 use status() */ - public function scan() + public function getByStatus($status): array { - $paths = $this->getScanPaths(); + return $this->status($status); + } + + /** + * {@inheritDoc} + */ + public function scan(): array + { + $paths = $this->scanPaths(); $modules = []; foreach ($paths as $key => $path) { - $manifests = $this->getFiles()->glob("{$path}/module.json"); + $manifests = $this->files()->glob("{$path}/module.json"); is_array($manifests) || $manifests = []; foreach ($manifests as $manifest) { $name = Json::make($manifest)->get('name'); - $modules[$name] = $this->createModule($this->app, $name, dirname($manifest)); + $modules[$name] = $this->module($this->app, $name, dirname($manifest)); } } @@ -159,42 +242,37 @@ public function scan() } /** - * Get all modules. + * {@inheritDoc} */ - public function all(): array + public function scanPaths(): array { - if (! $this->config('cache.enabled')) { - return $this->scan(); + $paths = $this->paths; + + $paths[] = $this->path(); + + if ($this->config('scan.enabled')) { + $paths = array_merge($paths, $this->config('scan.paths')); } - return $this->formatCached($this->getCached()); + $paths = array_map(function ($path) { + return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); + }, $paths); + + return $paths; } /** - * Format the cached data as array of modules. - * - * @param array $cached - * @return array + * @deprecated 10.0.11 use scanPaths() */ - protected function formatCached($cached) + public function getScanPaths(): array { - $modules = []; - - foreach ($cached as $name => $module) { - $path = $module['path']; - - $modules[$name] = $this->createModule($this->app, $name, $path); - } - - return $modules; + return $this->scanPaths(); } /** - * Get cached modules. - * - * @return array + * {@inheritDoc} */ - public function getCached() + public function cached(): array { return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { return $this->toCollection()->toArray(); @@ -202,25 +280,24 @@ public function getCached() } /** - * Get all modules as collection instance. + * @deprecated 10.0.11 use cached() */ - public function toCollection(): Collection + public function getCached(): array { - return new Collection($this->scan()); + return $this->cached(); } /** - * Get modules by status. + * Format the cached data as array of modules. */ - public function getByStatus($status): array + protected function formatCached(array $cached): array { $modules = []; - /** @var Module $module */ - foreach ($this->all() as $name => $module) { - if ($module->isStatus($status)) { - $modules[$name] = $module; - } + foreach ($cached as $name => $module) { + $path = $module['path']; + + $modules[$name] = $this->module($this->app, $name, $path); } return $modules; @@ -256,43 +333,42 @@ public function modules(?bool $enabled = null): array /** * Get list of enabled modules. + * {@inheritDoc} */ - public function allEnabled(): array + public function toCollection(): Collection { - return $this->getByStatus(true); + return new Collection($this->scan()); } /** - * Get list of disabled modules. + * Get all modules as laravel collection instance. */ - public function allDisabled(): array + public function collect(?bool $status = true): Collection { - return $this->getByStatus(false); + return new Collection($this->all((bool) $status)); } /** - * Get count from all modules. + * Get all modules as laravel collection instance. */ - public function count(): int + public function collections(?bool $status = true): Collection { - return count($this->all()); + return new Collection($this->all((bool) $status)); } /** - * Get all ordered modules. - * - * @param string $direction + * {@inheritDoc} */ - public function getOrdered($direction = 'asc'): array + public function ordered(string $sort = 'asc'): array { - $modules = $this->allEnabled(); + $modules = $this->all(true); - uasort($modules, function (Module $a, Module $b) use ($direction) { + uasort($modules, function (Module $a, Module $b) use ($sort) { if ($a->get('priority') === $b->get('priority')) { return 0; } - if ($direction === 'desc') { + if ($sort === 'desc') { return $a->get('priority') < $b->get('priority') ? 1 : -1; } @@ -303,183 +379,244 @@ public function getOrdered($direction = 'asc'): array } /** - * {@inheritDoc} + * @deprecated 10.0.11 use ordered() */ - public function getPath(): string + public function getOrdered(string $direction = 'asc'): array { - return $this->path ?: $this->config('paths.modules', base_path('Modules')); + return $this->ordered($direction); + } + + /** + * Update dependencies for the specified module. + */ + public function update(string $module): void + { + with(new Updater($this))->update($module); } /** * {@inheritDoc} */ - public function register(): void + public function delete(string $name): bool { - foreach ($this->getOrdered() as $module) { - $module->register(); - } + return $this->findOrFail($name)->delete(); } /** * {@inheritDoc} */ - public function boot(): void + public function config(string $key, ?string $default = null): mixed { - foreach ($this->getOrdered() as $module) { - $module->boot(); - } + return $this->config->get('modules.' . $key, $default); } /** * {@inheritDoc} */ - public function find(string $name) + public function count(?bool $enabled = null): int { - foreach ($this->all() as $module) { - if ($module->getLowerName() === strtolower($name)) { - return $module; + if (is_bool($enabled)) { + if ($enabled) { + return count($this->all(true)); } + + return count($this->all(false)); } + return count($this->all()); } /** - * Find a specific module, if there return that, otherwise throw exception. - * - * - * @return Module - * - * @throws ModuleNotFoundException + * {@inheritDoc} */ - public function findOrFail(string $name) + public function has(string $name): bool { - $module = $this->find($name); + return array_key_exists($name, $this->all()); + } - if ($module !== null) { - return $module; - } + /** + * Enabling a specific module. + * + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + */ + public function enable(string $name): void + { + $this->findOrFail($name)->enable(); + } - throw new ModuleNotFoundException("Module [{$name}] does not exist!"); + /** + * {@inheritDoc} + */ + public function enabled(string $name): bool + { + return $this->findOrFail($name)->isEnabled(); } /** - * Get all modules as laravel collection instance. + * @deprecated 10.0.11 use enabled() */ - public function collections($status = 1): Collection + public function isEnabled(string $name): bool { - return new Collection($this->getByStatus($status)); + return $this->enabled($name); } /** - * Get module path for a specific module. - * + * Disabling a specific module. * - * @return string + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function getModulePath($module) + public function disable(string $name): void { - try { - return $this->findOrFail($module)->getPath().'/'; - } catch (ModuleNotFoundException $e) { - return $this->getPath().'/'.Str::studly($module).'/'; - } + $this->findOrFail($name)->disable(); } /** * {@inheritDoc} */ - public function assetPath(string $module): string + public function disabled(string $name): bool { - return $this->config('paths.assets').'/'.$module; + return !$this->enabled($name); + } + + /** + * @deprecated 10.0.11 use disabled() + */ + public function isDisabled(string $name): bool + { + return $this->disabled($name); } /** * {@inheritDoc} */ - public function config(string $key, $default = null) + public function files(): Filesystem { - return $this->config->get('modules.'.$key, $default); + return $this->files; } /** - * Get storage path for module used. + * @deprecated 10.0.11 use files() */ - public function getUsedStoragePath(): string + public function getFiles(): Filesystem { - $directory = storage_path('app/modules'); - if ($this->getFiles()->exists($directory) === false) { - $this->getFiles()->makeDirectory($directory, 0777, true); - } + return $this->files(); + } - $path = storage_path('app/modules/modules.used'); - if (! $this->getFiles()->exists($path)) { - $this->getFiles()->put($path, ''); - } + /** + * {@inheritDoc} + */ + public function path(): string + { + return $this->path ?: $this->config('paths.modules', base_path('Modules')); + } - return $path; + /** + * @deprecated 10.0.11 use path() + */ + public function getPath(): string + { + return $this->path(); } /** - * Set module used for cli session. - * - * - * @throws ModuleNotFoundException + * Get all additional paths. */ - public function setUsed($name) + public function extra_paths(): array { - $module = $this->findOrFail($name); + return $this->paths; + } - $this->getFiles()->put($this->getUsedStoragePath(), $module); + /** + * @deprecated 10.0.11 use extra_paths() + */ + public function getPaths(): array + { + return $this->extra_paths(); } /** - * Forget the module used for cli session. + * {@inheritDoc} */ - public function forgetUsed() + public function modulePath($module): string { - if ($this->getFiles()->exists($this->getUsedStoragePath())) { - $this->getFiles()->delete($this->getUsedStoragePath()); + try { + return $this->findOrFail($module)->getPath() . '/'; + } catch (ModuleNotFoundException $e) { + return $this->path() . '/' . Str::studly($module) . '/'; } } /** - * Get module used for cli session. - * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + * @deprecated 10.0.11 use modulePath() */ - public function getUsedNow(): string + public function getModulePath($module): string { - return $this->findOrFail($this->getFiles()->get($this->getUsedStoragePath())); + return $this->modulePath($module); } /** - * Get laravel filesystem instance. + * Add extra module path. */ - public function getFiles(): Filesystem + public function add_path(string $path): self { - return $this->files; + $this->paths[] = $path; + + return $this; } /** - * Get module assets path. + * @deprecated 10.0.11 use add_path($path) */ - public function getAssetsPath(): string + public function addLocation(string $path): self { - return $this->config('paths.assets'); + return $this->add_path($path); + } + + /** + * Get stub path. + */ + public function stubPath(): ?string + { + if ($this->stubPath !== null) { + return $this->stubPath; + } + + if ($this->config('stubs.enabled') === true) { + return $this->config('stubs.path'); + } + + return $this->stubPath; + } + + /** + * @deprecated 10.0.11 use stubPath() + */ + public function getStubPath(): ?string + { + return $this->stubPath(); + } + + /** + * Set stub path. + */ + public function setStubPath(string $stubPath): self + { + $this->stubPath = $stubPath; + + return $this; } /** * Get asset url from a specific module. * - * @param string $asset - * * @throws InvalidAssetPath */ - public function asset($asset): string + public function asset(string $asset): string { if (Str::contains($asset, ':') === false) { throw InvalidAssetPath::missingModuleName($asset); } + [$name, $url] = explode(':', $asset); $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); @@ -492,107 +629,90 @@ public function asset($asset): string /** * {@inheritDoc} */ - public function isEnabled(string $name): bool - { - return $this->findOrFail($name)->isEnabled(); - } - - /** - * {@inheritDoc} - */ - public function isDisabled(string $name): bool + public function assetPath(string $module): string { - return ! $this->isEnabled($name); + return $this->config('paths.assets') . '/' . $module; } /** - * Enabling a specific module. - * - * @param string $name - * @return void - * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + * Get module assets path. */ - public function enable($name) + public function getAssetsPath(): string { - $this->findOrFail($name)->enable(); + return $this->config('paths.assets'); } /** - * Disabling a specific module. - * - * @param string $name - * @return void + * Get module used for cli session. * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function disable($name) + public function used(): string { - $this->findOrFail($name)->disable(); + return $this->findOrFail($this->files()->get($this->usedStoragePath())); } /** - * {@inheritDoc} + * @deprecated 10.0.11 use used() */ - public function delete(string $name): bool + public function getUsedNow(): string { - return $this->findOrFail($name)->delete(); + return $this->used(); } /** - * Update dependencies for the specified module. + * Set module used for cli session. * - * @param string $module + * @throws ModuleNotFoundException */ - public function update($module) + public function use($name) { - with(new Updater($this))->update($module); + $module = $this->findOrFail($name); + + $this->files()->put($this->usedStoragePath(), $module); } /** - * Install the specified module. - * - * @param string $name - * @param string $version - * @param string $type - * @param bool $subtree - * @return \Symfony\Component\Process\Process + * @deprecated 10.0.11 use use($name) */ - public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false) + public function setUsed($name) { - $installer = new Installer($name, $version, $type, $subtree); - - return $installer->run(); + $this->use($name); } /** - * Get stub path. - * - * @return string|null + * Get storage path for module used. */ - public function getStubPath() + public function usedStoragePath(): string { - if ($this->stubPath !== null) { - return $this->stubPath; + $directory = storage_path('app/modules'); + if ($this->files()->exists($directory) === false) { + $this->files()->makeDirectory($directory, 0777, true); } - if ($this->config('stubs.enabled') === true) { - return $this->config('stubs.path'); + $path = storage_path('app/modules/modules.used'); + if (!$this->files()->exists($path)) { + $this->files()->put($path, ''); } - return $this->stubPath; + return $path; } /** - * Set stub path. - * - * @param string $stubPath - * @return $this + * @deprecated 10.0.11 use usedStoragePath() */ - public function setStubPath($stubPath) + public function getUsedStoragePath(): string { - $this->stubPath = $stubPath; + return $this->usedStoragePath(); + } - return $this; + /** + * Forget the module used for cli session. + */ + public function forgetUsed() + { + if ($this->files()->exists($this->usedStoragePath())) { + $this->files()->delete($this->usedStoragePath()); + } } } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 8befb6287..2cf399bb3 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -4,10 +4,14 @@ use Illuminate\Config\Repository as Config; use Illuminate\Console\Command as Console; +use Illuminate\Console\View\Components\Factory; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\FileRepository; +use Nwidart\Modules\Module; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\PathNamespace; @@ -18,73 +22,54 @@ class ModuleGenerator extends Generator /** * The module name will created. - * - * @var string */ - protected $name; + protected ?string $name = null; /** * The laravel config instance. - * - * @var Config */ - protected $config; + protected ?Config $config = null; /** * The laravel filesystem instance. - * - * @var Filesystem */ - protected $filesystem; + protected ?Filesystem $filesystem = null; /** * The laravel console instance. - * - * @var Console */ - protected $console; + protected ?Console $console = null; /** * The laravel component Factory instance. - * - * @var \Illuminate\Console\View\Components\Factory */ - protected $component; + protected ?Factory $component = null; /** * The activator instance - * - * @var ActivatorInterface */ - protected $activator; + protected ?ActivatorInterface $activator = null; /** * The module instance. - * - * @var \Nwidart\Modules\Module */ - protected $module; + /*?Module*/ + protected mixed $module = null; /** * Force status. - * - * @var bool */ - protected $force = false; + protected bool $force = false; /** * set default module type. - * - * @var string */ - protected $type = 'web'; + protected string $type = 'web'; /** * Enables the module. - * - * @var bool */ - protected $isActive = false; + protected bool $isActive = false; /** * Module author @@ -119,11 +104,8 @@ public function __construct( /** * Set type. - * - * @param string $type - * @return $this */ - public function setType($type) + public function setType(string $type): self { $this->type = $type; @@ -132,11 +114,8 @@ public function setType($type) /** * Set active flag. - * - * - * @return $this */ - public function setActive(bool $active) + public function setActive(bool $active): self { $this->isActive = $active; @@ -144,32 +123,25 @@ public function setActive(bool $active) } /** - * Get the name of module will created. By default in studly case. - * - * @return string + * Get the name of module that will be created (in StudlyCase). */ - public function getName() + public function getName(): string { return Str::studly($this->name); } /** * Get the laravel config instance. - * - * @return Config */ - public function getConfig() + public function getConfig(): Config { return $this->config; } /** * Set the laravel config instance. - * - * @param Config $config - * @return $this */ - public function setConfig($config) + public function setConfig(Config $config): self { $this->config = $config; @@ -178,11 +150,8 @@ public function setConfig($config) /** * Set the modules activator - * - * - * @return $this */ - public function setActivator(ActivatorInterface $activator) + public function setActivator(ActivatorInterface $activator): self { $this->activator = $activator; @@ -191,21 +160,16 @@ public function setActivator(ActivatorInterface $activator) /** * Get the laravel filesystem instance. - * - * @return Filesystem */ - public function getFilesystem() + public function getFilesystem(): Filesystem { return $this->filesystem; } /** * Set the laravel filesystem instance. - * - * @param Filesystem $filesystem - * @return $this */ - public function setFilesystem($filesystem) + public function setFilesystem(Filesystem $filesystem): self { $this->filesystem = $filesystem; @@ -214,21 +178,16 @@ public function setFilesystem($filesystem) /** * Get the laravel console instance. - * - * @return Console */ - public function getConsole() + public function getConsole(): Console { return $this->console; } /** * Set the laravel console instance. - * - * @param Console $console - * @return $this */ - public function setConsole($console) + public function setConsole(Console $console): self { $this->console = $console; @@ -249,21 +208,16 @@ public function setComponent(\Illuminate\Console\View\Components\Factory $compon /** * Get the module instance. - * - * @return \Nwidart\Modules\Module */ - public function getModule() + public function getModule(): Module { return $this->module; } /** * Set the module instance. - * - * @param mixed $module - * @return $this */ - public function setModule($module) + public function setModule(mixed $module): self { $this->module = $module; @@ -272,10 +226,8 @@ public function setModule($module) /** * Setting the author from the command - * - * @return $this */ - public function setAuthor(?string $name = null, ?string $email = null) + public function setAuthor(?string $name = null, ?string $email = null): self { $this->author['name'] = $name; $this->author['email'] = $email; @@ -285,10 +237,8 @@ public function setAuthor(?string $name = null, ?string $email = null) /** * Installing vendor from the command - * - * @return $this */ - public function setVendor(?string $vendor = null) + public function setVendor(?string $vendor = null): self { $this->vendor = $vendor; @@ -297,31 +247,24 @@ public function setVendor(?string $vendor = null) /** * Get the list of folders will created. - * - * @return array */ - public function getFolders() + public function getFolders(): array { return $this->module->config('paths.generator'); } /** * Get the list of files will created. - * - * @return array */ - public function getFiles() + public function getFiles(): array { return $this->module->config('stubs.files'); } /** * Set force status. - * - * @param bool|int $force - * @return $this */ - public function setForce($force) + public function setForce(bool|int $force): self { $this->force = $force; @@ -335,6 +278,8 @@ public function generate(): int { $name = $this->getName(); + Event::dispatch(sprintf('modules.%s.%s', strtolower($name), ModuleEvent::CREATING)); + if ($this->module->has($name)) { if ($this->force) { $this->module->delete($name); @@ -365,6 +310,8 @@ public function generate(): int $this->component->info("Module [{$name}] created successfully."); + $this->fireEvent(ModuleEvent::CREATED); + return 0; } @@ -391,10 +338,8 @@ public function generateFolders() /** * Generate git keep to the specified path. - * - * @param string $path */ - public function generateGitKeep($path) + public function generateGitKeep(string $path) { $this->filesystem->put($path.'/.gitkeep', ''); } @@ -496,11 +441,8 @@ public function generateResources() /** * Get the contents of the specified stub file by given stub name. - * - * - * @return string */ - protected function getStubContents($stub) + protected function getStubContents($stub): string { return (new Stub( '/'.$stub.'.stub', @@ -519,11 +461,8 @@ public function getReplacements() /** * Get array replacement for the specified stub. - * - * - * @return array */ - protected function getReplacement($stub) + protected function getReplacement($stub): array { $replacements = $this->module->config('stubs.replacements'); @@ -592,40 +531,32 @@ private function cleanModuleJsonFile() /** * Get the module name in lower case. - * - * @return string */ - protected function getLowerNameReplacement() + protected function getLowerNameReplacement(): string { return strtolower($this->getName()); } /** * Get the module name in studly case. - * - * @return string */ - protected function getStudlyNameReplacement() + protected function getStudlyNameReplacement(): string { return $this->getName(); } /** * Get replacement for $VENDOR$. - * - * @return string */ - protected function getVendorReplacement() + protected function getVendorReplacement(): string { return $this->vendor ?: $this->module->config('composer.vendor'); } /** * Get replacement for $MODULE_NAMESPACE$. - * - * @return string */ - protected function getModuleNamespaceReplacement() + protected function getModuleNamespaceReplacement(): string { return str_replace('\\', '\\\\', $this->module->config('namespace') ?? $this->path_namespace($this->module->config('paths.modules'))); } @@ -644,30 +575,24 @@ private function getControllerNamespaceReplacement(): string /** * Get replacement for $AUTHOR_NAME$. - * - * @return string */ - protected function getAuthorNameReplacement() + protected function getAuthorNameReplacement(): string { return $this->author['name'] ?: $this->module->config('composer.author.name'); } /** * Get replacement for $AUTHOR_EMAIL$. - * - * @return string */ - protected function getAuthorEmailReplacement() + protected function getAuthorEmailReplacement(): string { return $this->author['email'] ?: $this->module->config('composer.author.email'); } /** * Get replacement for $APP_FOLDER_NAME$. - * - * @return string */ - protected function getAppFolderNameReplacement() + protected function getAppFolderNameReplacement(): string { return $this->module->config('paths.app_folder'); } @@ -676,4 +601,14 @@ protected function getProviderNamespaceReplacement(): string { return str_replace('\\', '\\\\', GenerateConfigReader::read('provider')->getNamespace()); } + + /** + * fire the module event. + */ + protected function fireEvent(string $event): void + { + $module = $this->module->find($this->name); + + $module->fireEvent($event); + } } diff --git a/src/Laravel/LaravelFileRepository.php b/src/Laravel/LaravelFileRepository.php index 600f298fd..20455a303 100644 --- a/src/Laravel/LaravelFileRepository.php +++ b/src/Laravel/LaravelFileRepository.php @@ -9,7 +9,7 @@ class LaravelFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function createModule(...$args) + protected function module(...$args): Module { return new Module(...$args); } diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index 7fd540e85..db8d27274 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -3,10 +3,18 @@ namespace Nwidart\Modules; use Composer\InstalledVersions; +use Illuminate\Contracts\Translation\Translator as TranslatorContract; +use Illuminate\Database\Migrations\Migrator; +use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Console\AboutCommand; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Event; +use Illuminate\Translation\Translator; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; use Nwidart\Modules\Support\Stub; +use Symfony\Component\Console\Output\NullOutput; class LaravelModulesServiceProvider extends ModulesServiceProvider { @@ -16,8 +24,20 @@ class LaravelModulesServiceProvider extends ModulesServiceProvider public function boot() { $this->registerNamespaces(); + + $this->app->singleton( + ModuleManifest::class, + fn () => new ModuleManifest( + new Filesystem(), + app(Contracts\RepositoryInterface::class)->getScanPaths(), + $this->getCachedModulePath() + ) + ); + $this->registerModules(); + $this->registerEvents(); + AboutCommand::add('Laravel-Modules', [ 'Version' => fn () => InstalledVersions::getPrettyVersion('nwidart/laravel-modules'), ]); @@ -32,6 +52,9 @@ public function register() $this->setupStubPath(); $this->registerProviders(); + $this->registerMigrations(); + $this->registerTransactions(); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules'); } @@ -74,4 +97,64 @@ protected function registerServices() }); $this->app->alias(Contracts\RepositoryInterface::class, 'modules'); } + + protected function registerMigrations(): void + { + if (! $this->app['config']->get('modules.auto-discover.migrations', true)) { + return; + } + + $this->app->resolving(Migrator::class, function (Migrator $migrator) { + $path = implode(DIRECTORY_SEPARATOR, [ + $this->app['config']->get('modules.paths.modules'), + '*', + '[Dd]atabase', + 'migrations', + ]); + + collect(glob($path, GLOB_ONLYDIR)) + ->each(function (string $path) use ($migrator) { + $migrator->path($path); + }); + }); + } + + protected function registerTransactions(): void + { + if (! $this->app['config']->get('modules.auto-discover.translations', true)) { + return; + } + $this->callAfterResolving('translator', function (TranslatorContract $translator) { + if (! $translator instanceof Translator) { + return; + } + + $path = implode(DIRECTORY_SEPARATOR, [ + $this->app['config']->get('modules.paths.modules'), + '*', + 'lang', + ]); + + collect(glob($path, GLOB_ONLYDIR)) + ->each(function (string $path) use ($translator) { + preg_match('/\/([^\/]+)\/lang/', $path, $matches); + $translator->addNamespace(strtolower($matches[1]), $path); + $translator->addJsonPath($path); + }); + }); + } + + + private function registerEvents(): void + { + Event::listen( + [ + 'modules.*.'.ModuleEvent::DELETED, + 'modules.*.'.ModuleEvent::CREATED, + 'modules.*.'.ModuleEvent::DISABLED, + 'modules.*.'.ModuleEvent::ENABLED, + ], + fn () => Artisan::call('module:clear-compiled', outputBuffer: new NullOutput) + ); + } } diff --git a/src/Lumen/LumenFileRepository.php b/src/Lumen/LumenFileRepository.php index de2b783f0..69dc095c9 100644 --- a/src/Lumen/LumenFileRepository.php +++ b/src/Lumen/LumenFileRepository.php @@ -9,7 +9,7 @@ class LumenFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function createModule(...$args) + protected function module(...$args): Module { return new Module(...$args); } diff --git a/src/Module.php b/src/Module.php index aa75af6d4..e2338360e 100644 --- a/src/Module.php +++ b/src/Module.php @@ -9,6 +9,7 @@ use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Illuminate\Translation\Translator; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; abstract class Module @@ -192,7 +193,7 @@ public function boot(): void $this->registerFiles(); } - $this->fireEvent('boot'); + $this->fireEvent(ModuleEvent::BOOT); } /** @@ -260,17 +261,15 @@ public function register(): void $this->registerFiles(); } - $this->fireEvent('register'); + $this->fireEvent(ModuleEvent::REGISTER); } /** - * Register the module event. - * - * @param string $event + * fire the module event. */ - protected function fireEvent($event): void + public function fireEvent(string $event): void { - $this->app['events']->dispatch(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]); + $this->app['events']->dispatch(sprintf('modules.%s.%s', $this->getLowerName(), $event), [$this]); } /** @@ -345,12 +344,12 @@ public function setActive(bool $active): void */ public function disable(): void { - $this->fireEvent('disabling'); + $this->fireEvent(ModuleEvent::DISABLING); $this->activator->disable($this); $this->flushCache(); - $this->fireEvent('disabled'); + $this->fireEvent(ModuleEvent::DISABLED); } /** @@ -358,12 +357,12 @@ public function disable(): void */ public function enable(): void { - $this->fireEvent('enabling'); + $this->fireEvent(ModuleEvent::ENABLING); $this->activator->enable($this); $this->flushCache(); - $this->fireEvent('enabled'); + $this->fireEvent(ModuleEvent::ENABLED); } /** @@ -371,9 +370,15 @@ public function enable(): void */ public function delete(): bool { + $this->fireEvent(ModuleEvent::DELETING); + $this->activator->delete($this); - return $this->json()->getFilesystem()->deleteDirectory($this->getPath()); + $result = $this->json()->getFilesystem()->deleteDirectory($this->getPath()); + + $this->fireEvent(ModuleEvent::DELETED); + + return $result; } /** diff --git a/src/ModuleManifest.php b/src/ModuleManifest.php new file mode 100644 index 000000000..76555bcac --- /dev/null +++ b/src/ModuleManifest.php @@ -0,0 +1,163 @@ +files = $files; + $this->paths = collect($paths); + $this->manifestPath = $manifestPath; + } + + /** + * Get all of the service provider class names for all packages. + * + * @return array + */ + public function providers() + { + return $this->config('providers'); + } + + /** + * Get all of the service provider class names for all packages. + * + * @return array + */ + public function providersArray() + { + return $this->getManifest()['providers'] ?? []; + } + + /** + * Get all of the aliases for all packages. + * + * @return array + */ + public function aliases() + { + return $this->config('aliases'); + } + + /** + * Get all of the values for all packages for the given configuration name. + * + * @param string $key + * @return array + */ + public function config($key) + { + return collect($this->getManifest())->flatMap(function ($configuration) use ($key) { + return (array) ($configuration[$key] ?? []); + })->filter()->all(); + } + + /** + * Get the current package manifest. + * + * @return array + */ + protected function getManifest() + { + if (! is_null($this->manifest)) { + return $this->manifest; + } + + if (! is_file($this->manifestPath)) { + $this->build(); + } + + return $this->manifest = is_file($this->manifestPath) ? + $this->files->getRequire($this->manifestPath) : []; + } + + /** + * Build the manifest and write it to disk. + * + * @return void + */ + public function build() + { + $providers = $this->paths + ->flatMap(function ($path) { + $manifests = $this->files->glob("{$path}/module.json"); + is_array($manifests) || $manifests = []; + + return collect($manifests) + ->map(function ($manifest) { + return $this->files->json($manifest); + }); + }) + ->sortBy(fn ($module) => $module['priority'] ?? 0) + ->pluck('providers') + ->flatten() + ->filter() + ->toArray(); + + $this->write( + [ + 'providers' => $providers, + 'eager' => $providers, + 'deferred' => [], + ] + ); + } + + /** + * Write the given manifest array to disk. + * + * @return void + * + * @throws \Exception + */ + protected function write(array $manifest) + { + if (! is_writable($dirname = dirname($this->manifestPath))) { + throw new Exception("The {$dirname} directory must be present and writable."); + } + $this->files->replace( + $this->manifestPath, + 'app->register(BootstrapServiceProvider::class); + // $this->app->register(\Nwidart\Modules\Providers\BootstrapServiceProvider::class); + + $providers = app()->make(ModuleManifest::class)->providersArray(); + + (new ProviderRepository($this->app, new Filesystem(), $this->getCachedModulePath())) + ->load($providers); + } /** @@ -75,4 +79,9 @@ protected function registerProviders() $this->app->register(ConsoleServiceProvider::class); $this->app->register(ContractsServiceProvider::class); } + + protected function getCachedModulePath() + { + return Str::replaceLast('services.php', 'modules.php', $this->app->getCachedServicesPath()); + } } diff --git a/src/Providers/BootstrapServiceProvider.php b/src/Providers/BootstrapServiceProvider.php index 82dc07d07..849ffdabf 100644 --- a/src/Providers/BootstrapServiceProvider.php +++ b/src/Providers/BootstrapServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Support\ServiceProvider; use Nwidart\Modules\Contracts\RepositoryInterface; +use Nwidart\Modules\Laravel\LaravelFileRepository; class BootstrapServiceProvider extends ServiceProvider { @@ -12,7 +13,7 @@ class BootstrapServiceProvider extends ServiceProvider */ public function boot(): void { - $this->app[RepositoryInterface::class]->boot(); + $this->getRepositoryInterface()->boot(); } /** @@ -20,6 +21,14 @@ public function boot(): void */ public function register(): void { - $this->app[RepositoryInterface::class]->register(); + $this->getRepositoryInterface()->register(); + } + + /** + * @return LaravelFileRepository + */ + public function getRepositoryInterface() + { + return $this->app[RepositoryInterface::class]; } } diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 28a2f3163..eb39dbec9 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -94,6 +94,8 @@ public static function defaultCommands(): Collection // Other Commands Commands\ComposerUpdateCommand::class, Commands\LaravelModulesV6Migrator::class, + Commands\ModuleDiscoverCommand::class, + Commands\ModuleClearCompiledCommand::class, Commands\SetupCommand::class, Commands\Database\MigrateFreshCommand::class, diff --git a/tests/Commands/Actions/ClearCompiledCommandTest.php b/tests/Commands/Actions/ClearCompiledCommandTest.php new file mode 100644 index 000000000..1f141cd2a --- /dev/null +++ b/tests/Commands/Actions/ClearCompiledCommandTest.php @@ -0,0 +1,82 @@ +finder = $this->app['files']; + $this->manifestPath = app()->make(ModuleManifest::class)->manifestPath; + $this->repository = $this->app[RepositoryInterface::class]; + } + + public function tearDown(): void + { + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + parent::tearDown(); + } + + public function test_manifest_file_clear_when_call_command() + { + $this->createModule(); + $code = $this->artisan('module:clear-compiled'); + + $this->assertFileDoesNotExist($this->manifestPath); + $this->assertSame(0, $code); + } + + public function test_manifest_file_clear_when_create_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->assertFileDoesNotExist($this->manifestPath); + } + + public function test_manifest_file_clear_when_delete_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->artisan('module:delete', ['module' => 'Foo', '--force' => true]); + + $this->assertFileDoesNotExist($this->manifestPath); + } + + public function test_manifest_file_clear_when_disable_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->artisan('module:disable', ['module' => 'Foo']); + + $this->assertFileDoesNotExist($this->manifestPath); + } + + public function test_manifest_file_clear_when_enable_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->artisan('module:enable', ['module' => 'Foo']); + + $this->assertFileDoesNotExist($this->manifestPath); + } +} diff --git a/tests/Commands/Actions/ModuleDeleteCommandTest.php b/tests/Commands/Actions/ModuleDeleteCommandTest.php index 85d454733..faba96e00 100644 --- a/tests/Commands/Actions/ModuleDeleteCommandTest.php +++ b/tests/Commands/Actions/ModuleDeleteCommandTest.php @@ -2,7 +2,9 @@ namespace Nwidart\Modules\Commands; +use Illuminate\Support\Facades\Event; use Nwidart\Modules\Activators\FileActivator; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; use Spatie\Snapshots\MatchesSnapshots; @@ -89,4 +91,44 @@ public function test_it_deletes_modules_from_status_file(): void $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); $this->assertSame(0, $code); } + + public function test_it_fires_events_when_module_deleted() + { + $module_name = 'Blog'; + + $this->createModule($module_name); + + Event::fake(); + + $code = $this->artisan('module:delete', ['module' => [$module_name], '--force' => true]); + + $this->assertSame(0, $code); + + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETING, strtolower($module_name))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETED, strtolower($module_name))); + } + + public function test_it_fires_events_when_multi_module_deleted() + { + $modules = [ + 'Foo', + 'Bar', + 'Zoo', + ]; + + foreach ($modules as $module) { + $this->createModule($module); + } + + Event::fake(); + + $code = $this->artisan('module:delete', ['--all' => true, '--force' => true]); + + $this->assertSame(0, $code); + + foreach ($modules as $module) { + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETING, strtolower($module))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETED, strtolower($module))); + } + } } diff --git a/tests/Commands/Actions/ModuleDiscoverCommandTest.php b/tests/Commands/Actions/ModuleDiscoverCommandTest.php new file mode 100644 index 000000000..f0f0a4a7e --- /dev/null +++ b/tests/Commands/Actions/ModuleDiscoverCommandTest.php @@ -0,0 +1,84 @@ +finder = $this->app['files']; + $this->manifestPath = app()->make(ModuleManifest::class)->manifestPath; + $this->repository = $this->app[RepositoryInterface::class]; + } + + public function tearDown(): void + { + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + parent::tearDown(); + } + + public function test_run_command_without_error() + { + $this->createModule(); + + $code = $this->artisan('module:discover'); + + $this->assertSame(0, $code); + } + + public function test_manifest_file_contain_new_module_provider() + { + $this->createModule('Foo'); + + $path = base_path('modules/Foo').'/module.json'; + $provider = json_decode($this->finder->get($path))->providers[0]; + + $code = $this->artisan('module:discover'); + $this->assertSame(0, $code); + + $manifest = require $this->manifestPath; + + $this->assertContains($provider, $manifest['providers'], 'provider not found in manifest file'); + $this->assertContains($provider, $manifest['eager'], 'provider not found in manifest file'); + } + + public function test_manifest_file_contain_multi_module_provider() + { + $modules = [ + 'Foo', + 'Bar', + 'Baz', + ]; + + foreach ($modules as $module) { + $this->createModule($module); + } + + $code = $this->artisan('module:discover'); + $this->assertSame(0, $code); + + $manifest = require $this->manifestPath; + + foreach ($modules as $module) { + $path = module_path($module).'/module.json'; + $provider = json_decode($this->finder->get($path))->providers[0]; + + $this->assertContains($provider, $manifest['providers'], 'provider not found in manifest file'); + $this->assertContains($provider, $manifest['eager'], 'provider not found in manifest file'); + } + } + + +} diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index d2ce2924c..6a1a1e811 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -3,7 +3,9 @@ namespace Nwidart\Modules\Tests\Commands\Make; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; @@ -44,10 +46,8 @@ public function setUp(): void public function tearDown(): void { - $this->finder->deleteDirectory($this->modulePath); - if ($this->finder->isDirectory(base_path('modules/ModuleName'))) { - $this->finder->deleteDirectory(base_path('modules/ModuleName')); - } + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + $this->activator->reset(); parent::tearDown(); } @@ -226,16 +226,15 @@ public function test_it_outputs_error_when_module_exists() public function test_it_still_generates_module_if_it_exists_using_force_flag() { + Event::fake(); + $this->artisan('module:make', ['name' => ['Blog']]); $code = $this->artisan('module:make', ['name' => ['Blog'], '--force' => true]); - - $output = Artisan::output(); - - $notExpected = 'Module [Blog] already exist! -'; - $this->assertNotEquals($notExpected, $output); - $this->assertTrue(Str::contains($output, 'Module [Blog] created successfully.')); $this->assertSame(0, $code); + + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETING, strtolower('Blog'))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETED, strtolower('Blog'))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower('Blog'))); } public function test_it_can_generate_module_with_old_config_format() @@ -301,10 +300,15 @@ public function test_it_can_ignore_some_folders_to_generate_with_new_format() public function test_it_can_ignore_resource_folders_to_generate() { - $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false]); + $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false] + ); $this->app['config']->set('modules.paths.generator.provider', ['path' => 'Providers', 'generate' => false]); - $this->app['config']->set('modules.paths.generator.route-provider', ['path' => 'Providers', 'generate' => false]); - $this->app['config']->set('modules.paths.generator.controller', ['path' => 'Http/Controllers', 'generate' => false]); + $this->app['config']->set('modules.paths.generator.route-provider', ['path' => 'Providers', 'generate' => false] + ); + $this->app['config']->set( + 'modules.paths.generator.controller', + ['path' => 'Http/Controllers', 'generate' => false] + ); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -473,7 +477,15 @@ public function test_it_generate_module_when_provider_is_disable_and_route_provi public function test_it_can_set_author_details() { - $code = $this->artisan('module:make', ['name' => ['Blog'], '--author-name' => 'Joe Blogs', '--author-email' => 'user@domain.com', '--author-vendor' => 'JoeBlogs']); + $code = $this->artisan( + 'module:make', + [ + 'name' => ['Blog'], + '--author-name' => 'Joe Blogs', + '--author-email' => 'user@domain.com', + '--author-vendor' => 'JoeBlogs' + ] + ); $content = $this->finder->get($this->getModuleBasePath().'/composer.json'); @@ -483,4 +495,37 @@ public function test_it_can_set_author_details() $this->assertSame(0, $code); } + + public function test_it_fires_events_when_module_created() + { + $module_name = 'Blog'; + Event::fake(); + + $code = $this->createModule($module_name); + + $this->assertSame(0, $code); + + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATING, strtolower($module_name))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower($module_name))); + } + + public function test_it_fires_events_when_multi_module_created() + { + Event::fake(); + + $modules = [ + 'Foo', + 'Bar', + 'Zoo', + ]; + + $code = $this->artisan('module:make', ['name' => $modules]); + + $this->assertSame(0, $code); + + foreach ($modules as $module) { + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATING, strtolower($module))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower($module))); + } + } } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt index 863f2f9d1..ebb6e6b8c 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 8d94acf97..f6ad657b7 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 8d94acf97..f6ad657b7 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt index 5001fb01e..7f1d535a9 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers\Api; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 863f2f9d1..ebb6e6b8c 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 4130adfaa..5f4668484 100644 --- a/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -22,11 +22,9 @@ class EventServiceProvider extends ServiceProvider /** * Configure the proper event listeners for email verification. - * - * @return void */ protected function configureEmailVerification(): void { - + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 395327120..7355e76a1 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = []; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 395327120..7355e76a1 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = []; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 395327120..7355e76a1 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = []; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt index 0006937ff..3a09e23cb 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class PostController extends Controller { @@ -28,7 +26,7 @@ class PostController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class PostController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt index 0006937ff..3a09e23cb 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class PostController extends Controller { @@ -28,7 +26,7 @@ class PostController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class PostController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt index 0006937ff..3a09e23cb 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class PostController extends Controller { @@ -28,7 +26,7 @@ class PostController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class PostController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt index 1d8cc95e6..8cd255f13 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = ["title","slug"]; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt index 4130adfaa..5f4668484 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt @@ -22,11 +22,9 @@ class EventServiceProvider extends ServiceProvider /** * Configure the proper event listeners for email verification. - * - * @return void */ protected function configureEmailVerification(): void { - + // } } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt index 6a89e8c29..21acf68c4 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class BlogController extends Controller { @@ -28,7 +26,7 @@ class BlogController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class BlogController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt index 6a89e8c29..21acf68c4 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class BlogController extends Controller { @@ -28,7 +26,7 @@ class BlogController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class BlogController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt index 6a89e8c29..21acf68c4 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class BlogController extends Controller { @@ -28,7 +26,7 @@ class BlogController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class BlogController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index b21fb56ef..000000000 --- a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,11 +0,0 @@ - $attributes - */ - public function get(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } - - /** - * Prepare the given value for storage. - * - * @param array $attributes - */ - public function set(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } -} diff --git a/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 05d8e3e37..000000000 --- a/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,29 +0,0 @@ - $attributes - */ - public function get(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } - - /** - * Prepare the given value for storage. - * - * @param array $attributes - */ - public function set(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } -} diff --git a/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 55d364bf9..000000000 --- a/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,24 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt deleted file mode 100644 index 863f2f9d1..000000000 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt +++ /dev/null @@ -1,67 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt deleted file mode 100644 index 41a1b8ced..000000000 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt +++ /dev/null @@ -1,17 +0,0 @@ -json([]); - } -} diff --git a/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index c9edb0b1b..000000000 --- a/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,8 +0,0 @@ -> - */ - protected $listen = []; - - /** - * Indicates if events should be discovered. - * - * @var bool - */ - protected static $shouldDiscoverEvents = true; - - /** - * Configure the proper event listeners for email verification. - * - * @return void - */ - protected function configureEmailVerification(): void - { - - } -} diff --git a/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index 4e24c9dc5..000000000 --- a/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,10 +0,0 @@ -view(\'view.name\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index de57ce98c..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,36 +0,0 @@ -view(\'view.name\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index 721ca773a..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,36 +0,0 @@ -view(\'view.name\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 5bee369ee..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 5bee369ee..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index f908a99b1..000000000 --- a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,24 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php deleted file mode 100644 index 638fa8f70..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php +++ /dev/null @@ -1,31 +0,0 @@ -bigIncrements(\'id\'); - - $table->timestamps(); - }); - } -} -'; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt deleted file mode 100644 index e14933dcd..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php deleted file mode 100644 index b268cb945..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->integer(\'user_id\')->unsigned(); - $table->foreign(\'user_id\')->references(\'id\')->on(\'users\'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt deleted file mode 100644 index 6546dae4d..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt +++ /dev/null @@ -1,30 +0,0 @@ -id(); - $table->integer('user_id')->unsigned(); - $table->foreign('user_id')->references('id')->on('users'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt deleted file mode 100644 index ec659d5fe..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt deleted file mode 100644 index 88fa2f36b..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt +++ /dev/null @@ -1,24 +0,0 @@ -id(); - - $table->timestamps(); - }); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt deleted file mode 100644 index 6546dae4d..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt +++ /dev/null @@ -1,30 +0,0 @@ -id(); - $table->integer('user_id')->unsigned(); - $table->foreign('user_id')->references('id')->on('users'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index b9dc5670f..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,21 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php deleted file mode 100644 index 96c430491..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php +++ /dev/null @@ -1,82 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'product_details\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt deleted file mode 100644 index 1e0f11a0a..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('product_details'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php deleted file mode 100644 index cd1d8ef83..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php deleted file mode 100644 index cd1d8ef83..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 395327120..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,22 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt deleted file mode 100644 index 0006937ff..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt +++ /dev/null @@ -1,67 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('product_details'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php b/tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php deleted file mode 100644 index b168a77d4..000000000 --- a/tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php +++ /dev/null @@ -1,5 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php deleted file mode 100644 index 83c177982..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php +++ /dev/null @@ -1,63 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php deleted file mode 100644 index 6e21400e5..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php +++ /dev/null @@ -1,24 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php deleted file mode 100644 index aeda47cc3..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php +++ /dev/null @@ -1,20 +0,0 @@ -get(\'/blog\', function (Request $request) { - return $request->user(); -});'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt deleted file mode 100644 index cbdf7602e..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -prefix('v1')->group(function () { - Route::apiResource('blog', BlogController::class)->names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php deleted file mode 100644 index d59c9fbab..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php +++ /dev/null @@ -1,26 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->registerFactories(); - $this->loadMigrationsFrom(__DIR__ . \'/../Database/Migrations\'); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - __DIR__.\'/../Config/config.php\' => config_path(\'blog.php\'), - ], \'config\'); - $this->mergeConfigFrom( - __DIR__.\'/../Config/config.php\', \'blog\' - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/blog\'); - - $sourcePath = __DIR__.\'/../Resources/views\'; - - $this->publishes([ - $sourcePath => $viewPath - ],\'views\'); - - $this->loadViewsFrom(array_merge(array_map(function ($path) { - return $path . \'/modules/blog\'; - }, \\Config::get(\'view.paths\')), [$sourcePath]), \'blog\'); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/blog\'); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, \'blog\'); - } else { - $this->loadTranslationsFrom(__DIR__ .\'/../Resources/lang\', \'blog\'); - } - } - - /** - * Register an additional directory of factories. - * - * @return void - */ - public function registerFactories() - { - if (! app()->environment(\'production\')) { - app(Factory::class)->load(__DIR__ . \'/../Database/factories\'); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php deleted file mode 100644 index e18455549..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php +++ /dev/null @@ -1,16 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt deleted file mode 100644 index da938d49a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php deleted file mode 100644 index 116c300ac..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php deleted file mode 100644 index 70eda9111..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php +++ /dev/null @@ -1,82 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php deleted file mode 100644 index 964652b2e..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php +++ /dev/null @@ -1,6 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php deleted file mode 100644 index 7167823ee..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php +++ /dev/null @@ -1,82 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php deleted file mode 100644 index 116c300ac..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php deleted file mode 100644 index 7167823ee..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php +++ /dev/null @@ -1,82 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php deleted file mode 100644 index 92a328a04..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php +++ /dev/null @@ -1,19 +0,0 @@ -group(function() { - Route::get(\'/\', \'BlogController@index\'); -}); -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt deleted file mode 100644 index 082efd6d4..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php deleted file mode 100644 index ddb6e2084..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php +++ /dev/null @@ -1,16 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - // $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt deleted file mode 100644 index bc3afb929..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt +++ /dev/null @@ -1,59 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt deleted file mode 100644 index 97e7e2a48..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt deleted file mode 100644 index cbdf7602e..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -prefix('v1')->group(function () { - Route::apiResource('blog', BlogController::class)->names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt deleted file mode 100644 index 746cae739..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "nwidart/blog", - "description": "", - "authors": [ - { - "name": "Nicolas Widart", - "email": "n.widart@gmail.com" - } - ], - "extra": { - "laravel": { - "providers": [], - "aliases": { - - } - } - }, - "autoload": { - "psr-4": { - "Modules\\Blog\\": "app/", - "Modules\\Blog\\Database\\Factories\\": "database/factories/", - "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" - } - }, - "autoload-dev": { - "psr-4": { - "Modules\\Blog\\Tests\\": "tests/" - } - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt deleted file mode 100644 index 92e3b4504..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Blog", - "alias": "blog", - "description": "", - "keywords": [], - "priority": 0, - "providers": [ - "Modules\\Blog\\Providers\\BlogServiceProvider" - ], - "files": [] -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt deleted file mode 100644 index 560ac5db1..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt deleted file mode 100644 index 4130adfaa..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt +++ /dev/null @@ -1,32 +0,0 @@ -> - */ - protected $listen = []; - - /** - * Indicates if events should be discovered. - * - * @var bool - */ - protected static $shouldDiscoverEvents = true; - - /** - * Configure the proper event listeners for email verification. - * - * @return void - */ - protected function configureEmailVerification(): void - { - - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt deleted file mode 100644 index 6a89e8c29..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ /dev/null @@ -1,67 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt deleted file mode 100644 index 72d694d39..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt +++ /dev/null @@ -1,26 +0,0 @@ -import { defineConfig } from 'vite'; -import laravel from 'laravel-vite-plugin'; - -export default defineConfig({ - build: { - outDir: '../../public/build-blog', - emptyOutDir: true, - manifest: true, - }, - plugins: [ - laravel({ - publicDirectory: '../../public', - buildDirectory: 'build-blog', - input: [ - __dirname + '/resources/assets/sass/app.scss', - __dirname + '/resources/assets/js/app.js' - ], - refresh: true, - }), - ], -}); - -//export const paths = [ -// 'Modules/Blog/resources/assets/sass/app.scss', -// 'Modules/Blog/resources/assets/js/app.js', -//]; \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt deleted file mode 100644 index 6a89e8c29..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt +++ /dev/null @@ -1,67 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt deleted file mode 100644 index 6a89e8c29..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ /dev/null @@ -1,67 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt deleted file mode 100644 index 082efd6d4..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt deleted file mode 100644 index c59f26953..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Blog", - "alias": "blog", - "description": "", - "keywords": [], - "priority": 0, - "providers": [ - "Modules\\Blog\\Base\\Providers\\BlogServiceProvider" - ], - "files": [] -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt deleted file mode 100644 index 746cae739..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "nwidart/blog", - "description": "", - "authors": [ - { - "name": "Nicolas Widart", - "email": "n.widart@gmail.com" - } - ], - "extra": { - "laravel": { - "providers": [], - "aliases": { - - } - } - }, - "autoload": { - "psr-4": { - "Modules\\Blog\\": "app/", - "Modules\\Blog\\Database\\Factories\\": "database/factories/", - "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" - } - }, - "autoload-dev": { - "psr-4": { - "Modules\\Blog\\Tests\\": "tests/" - } - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index 941a05c26..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,64 +0,0 @@ -line(\'The introduction to the notification.\') - ->action(\'Notification Action\', \'https://laravel.com\') - ->line(\'Thank you for using our application!\'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} -'; diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index 941a05c26..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,64 +0,0 @@ -line(\'The introduction to the notification.\') - ->action(\'Notification Action\', \'https://laravel.com\') - ->line(\'Thank you for using our application!\'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} -'; diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index 98a1b6e9c..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,64 +0,0 @@ -line(\'The introduction to the notification.\') - ->action(\'Notification Action\', \'https://laravel.com\') - ->line(\'Thank you for using our application!\'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} -'; diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 53e7ab765..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 53e7ab765..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php b/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php deleted file mode 100644 index 7e8a21ea2..000000000 --- a/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php +++ /dev/null @@ -1,52 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index b4c6f48d6..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index 4b1d92d74..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index b4c6f48d6..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php deleted file mode 100644 index e9af8c60a..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt deleted file mode 100644 index 4f132a028..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index c5ec999ae..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,31 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index bb17c3614..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index bb17c3614..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt deleted file mode 100644 index 26918b859..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 922456f3d..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,24 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index 6ddffc7b9..000000000 --- a/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,11 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt deleted file mode 100644 index 4415d0ded..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index 92c4b0049..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 4d24c8e15..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index 92c4b0049..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 4d24c8e15..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php deleted file mode 100644 index 3c1840372..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/SuperRoutes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt deleted file mode 100644 index 68d0fd9d6..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php deleted file mode 100644 index e51b25a48..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/SuperRoutes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/SuperRoutes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt deleted file mode 100644 index 10aaad55e..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt deleted file mode 100644 index 79746f865..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index af40c469e..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index af40c469e..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt deleted file mode 100644 index e8d7205d7..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt deleted file mode 100644 index 7c40e3d35..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/SuperRoutes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index 4bdb9a702..000000000 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,43 +0,0 @@ -get(\'/\'); - - $response->assertStatus(200); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php deleted file mode 100644 index 2ce31ff0d..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php +++ /dev/null @@ -1,25 +0,0 @@ -get(\'/\'); - - $response->assertStatus(200); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php deleted file mode 100644 index 2da859821..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php +++ /dev/null @@ -1,23 +0,0 @@ -assertTrue(true); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt deleted file mode 100644 index 273dc9657..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php deleted file mode 100644 index 2da859821..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php +++ /dev/null @@ -1,23 +0,0 @@ -assertTrue(true); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php deleted file mode 100644 index 7b9c70d06..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php +++ /dev/null @@ -1,25 +0,0 @@ -get(\'/\'); - - $response->assertStatus(200); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt deleted file mode 100644 index 6378738a3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php deleted file mode 100644 index b927d166c..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php +++ /dev/null @@ -1,23 +0,0 @@ -assertTrue(true); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt deleted file mode 100644 index 273dc9657..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt deleted file mode 100644 index 6378738a3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index 81f87fd99..000000000 --- a/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,8 +0,0 @@ -activator->reset(); + $this->artisan('module:delete', ['--all' => true, '--force' => true]); parent::tearDown(); } diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index a529d7001..dd8878c53 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Event; use Modules\Recipe\Providers\DeferredServiceProvider; use Modules\Recipe\Providers\RecipeServiceProvider; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Json; @@ -147,8 +148,8 @@ public function test_it_fires_events_when_module_is_enabled() $this->module->enable(); - Event::assertDispatched(sprintf('modules.%s.enabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.enabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLED, $this->module->getLowerName())); } public function test_it_fires_events_when_module_is_disabled() @@ -157,8 +158,8 @@ public function test_it_fires_events_when_module_is_disabled() $this->module->disable(); - Event::assertDispatched(sprintf('modules.%s.disabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.disabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLED, $this->module->getLowerName())); } public function test_it_has_a_good_providers_manifest_path() diff --git a/tests/LumenModuleTest.php b/tests/LumenModuleTest.php index 2f2b1a8bc..1dc142ea6 100644 --- a/tests/LumenModuleTest.php +++ b/tests/LumenModuleTest.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules\Tests; use Illuminate\Support\Facades\Event; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Json; @@ -114,8 +115,8 @@ public function test_it_fires_events_when_module_is_enabled() $this->module->enable(); - Event::assertDispatched(sprintf('modules.%s.enabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.enabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLED, $this->module->getLowerName())); } public function test_it_fires_events_when_module_is_disabled() @@ -124,8 +125,8 @@ public function test_it_fires_events_when_module_is_disabled() $this->module->disable(); - Event::assertDispatched(sprintf('modules.%s.disabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.disabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLED, $this->module->getLowerName())); } public function test_it_has_a_good_providers_manifest_path() @@ -137,6 +138,4 @@ public function test_it_has_a_good_providers_manifest_path() } } -class LumenTestingModule extends \Nwidart\Modules\Lumen\Module -{ -} +class LumenTestingModule extends \Nwidart\Modules\Lumen\Module {}