diff --git a/tests/Commands/Make/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 00000000..b21fb56e --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,11 @@ + $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/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 00000000..05d8e3e3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,29 @@ + $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/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 00000000..55d364bf --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,24 @@ +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/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt new file mode 100644 index 00000000..41a1b8ce --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt @@ -0,0 +1,17 @@ +json([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 00000000..c9edb0b1 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + */ + protected function configureEmailVerification(): void + { + // + } +} diff --git a/tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 00000000..4e24c9dc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,10 @@ +view('view.name'); + } +} diff --git a/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 00000000..45f802ff --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,29 @@ +view('view.name'); + } +} diff --git a/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 00000000..5bee369e --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,29 @@ +view('view.name'); + } +} diff --git a/tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 00000000..e8b58675 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,17 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt new file mode 100644 index 00000000..88fa2f36 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt @@ -0,0 +1,24 @@ +id(); + + $table->timestamps(); + }); + } +}; diff --git a/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt new file mode 100644 index 00000000..6546dae4 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt @@ -0,0 +1,30 @@ +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/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 new file mode 100644 index 00000000..7355e76a --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,22 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; 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 new file mode 100644 index 00000000..3a09e23c --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt @@ -0,0 +1,65 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('product_details'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt new file mode 100644 index 00000000..36dc20e8 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt new file mode 100644 index 00000000..36dc20e8 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt new file mode 100644 index 00000000..7ad790eb --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt new file mode 100644 index 00000000..1823f4c3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt new file mode 100644 index 00000000..650b2838 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt new file mode 100644 index 00000000..1823f4c3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt new file mode 100644 index 00000000..bc3afb92 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt @@ -0,0 +1,59 @@ +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/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt new file mode 100644 index 00000000..97e7e2a4 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt new file mode 100644 index 00000000..650b2838 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt new file mode 100644 index 00000000..cbdf7602 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('blog', BlogController::class)->names('blog'); +}); diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file_with_multi_segment_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file_with_multi_segment_default_namespace__1.txt new file mode 100644 index 00000000..f063f6cb --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file_with_multi_segment_default_namespace__1.txt @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('blog', BlogController::class)->names('blog'); +}); diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt new file mode 100644 index 00000000..746cae73 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt @@ -0,0 +1,30 @@ +{ + "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/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt new file mode 100644 index 00000000..92e3b450 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt @@ -0,0 +1,11 @@ +{ + "name": "Blog", + "alias": "blog", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Blog\\Providers\\BlogServiceProvider" + ], + "files": [] +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt new file mode 100644 index 00000000..d0f0fa75 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt new file mode 100644 index 00000000..1823f4c3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} 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 new file mode 100644 index 00000000..5f466848 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt @@ -0,0 +1,30 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + */ + protected function configureEmailVerification(): void + { + // + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt new file mode 100644 index 00000000..650b2838 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} 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 new file mode 100644 index 00000000..21acf68c --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -0,0 +1,65 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt new file mode 100644 index 00000000..0dd60664 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt @@ -0,0 +1,57 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; +import { readdirSync, statSync } from 'fs'; +import { join,relative,dirname } from 'path'; +import { fileURLToPath } from 'url'; + +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, + }), + ], +}); +// Scen all resources for assets file. Return array +//function getFilePaths(dir) { +// const filePaths = []; +// +// function walkDirectory(currentPath) { +// const files = readdirSync(currentPath); +// for (const file of files) { +// const filePath = join(currentPath, file); +// const stats = statSync(filePath); +// if (stats.isFile() && !file.startsWith('.')) { +// const relativePath = 'Modules/Blog/'+relative(__dirname, filePath); +// filePaths.push(relativePath); +// } else if (stats.isDirectory()) { +// walkDirectory(filePath); +// } +// } +// } +// +// walkDirectory(dir); +// return filePaths; +//} + +//const __filename = fileURLToPath(import.meta.url); +//const __dirname = dirname(__filename); + +//const assetsDir = join(__dirname, 'resources/assets'); +//export const paths = getFilePaths(assetsDir); + + +//export const paths = [ +// 'Modules/Blog/resources/assets/sass/app.scss', +// 'Modules/Blog/resources/assets/js/app.js', +//]; diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt new file mode 100644 index 00000000..1823f4c3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} 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 new file mode 100644 index 00000000..21acf68c --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt @@ -0,0 +1,65 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt new file mode 100644 index 00000000..650b2838 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt new file mode 100644 index 00000000..1823f4c3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} 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 new file mode 100644 index 00000000..21acf68c --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -0,0 +1,65 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt new file mode 100644 index 00000000..650b2838 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt new file mode 100644 index 00000000..082efd6d --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt @@ -0,0 +1,19 @@ +names('blog'); +}); diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file_with_multi_segment_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file_with_multi_segment_default_namespace__1.txt new file mode 100644 index 00000000..ee8df69c --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file_with_multi_segment_default_namespace__1.txt @@ -0,0 +1,19 @@ +names('blog'); +}); diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt new file mode 100644 index 00000000..c59f2695 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt @@ -0,0 +1,11 @@ +{ + "name": "Blog", + "alias": "blog", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Blog\\Base\\Providers\\BlogServiceProvider" + ], + "files": [] +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt new file mode 100644 index 00000000..746cae73 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt @@ -0,0 +1,30 @@ +{ + "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/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 00000000..4fb9ff31 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,48 @@ +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/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 00000000..4fb9ff31 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,48 @@ +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/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 00000000..53e7ab76 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,48 @@ +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/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt b/tests/Commands/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt new file mode 100644 index 00000000..f2b38c90 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt @@ -0,0 +1,48 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 00000000..7a1ebd09 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt new file mode 100644 index 00000000..ed70db0e --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -0,0 +1,135 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 00000000..922456f3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,24 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->name, '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->nameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->nameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower); + $this->loadJsonTranslationsFrom(module_path($this->name, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $relativeConfigPath = config('modules.paths.generator.config.path'); + $configPath = module_path($this->name, $relativeConfigPath); + + if (is_dir($configPath)) { + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath)); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname()); + $configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath); + $key = ($relativePath === 'config.php') ? $this->nameLower : $configKey; + + $this->publishes([$file->getPathname() => config_path($relativePath)], 'config'); + $this->mergeConfigFrom($file->getPathname(), $key); + } + } + } + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->nameLower); + $sourcePath = module_path($this->name, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower); + + $componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path'))); + Blade::componentNamespace($componentNamespace, $this->nameLower); + } + + /** + * 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->nameLower)) { + $paths[] = $path.'/modules/'.$this->nameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 00000000..6ddffc7b --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,11 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 00000000..43a25d37 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 00000000..43a25d37 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt new file mode 100644 index 00000000..9b80aa3d --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt new file mode 100644 index 00000000..fe4cb9a8 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/SuperRoutes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 00000000..650b2838 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,50 @@ +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($this->name, '/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($this->name, '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 00000000..23757e05 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,17 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt new file mode 100644 index 00000000..3986e14b --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt @@ -0,0 +1,18 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt new file mode 100644 index 00000000..ae35f4fe --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt @@ -0,0 +1,16 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt new file mode 100644 index 00000000..d6cc1988 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt @@ -0,0 +1,16 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt new file mode 100644 index 00000000..f5907115 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt @@ -0,0 +1,18 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt new file mode 100644 index 00000000..d6cc1988 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt @@ -0,0 +1,16 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 00000000..81f87fd9 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ +