harness = new class { use OrchestratesCascadeInstall { installSelectedDependencies as public; } }; } protected function tearDown(): void { Mockery::close(); parent::tearDown(); } public function test_inactive_installed_module_only_activates_no_reinstall(): void { $moduleService = Mockery::mock(ModuleService::class); $moduleService->shouldReceive('getModuleInfo') ->with('foo-module') ->andReturn([ 'is_installed' => true, 'status' => ExtensionStatus::Inactive->value, ]); $moduleService->shouldNotReceive('installModule'); $moduleService->shouldReceive('activateModule') ->once() ->with('foo-module'); $this->app->instance(ModuleService::class, $moduleService); $this->harness->installSelectedDependencies([ ['type' => 'module', 'identifier' => 'foo-module'], ]); } public function test_uninstalled_module_installs_then_activates(): void { $moduleService = Mockery::mock(ModuleService::class); $moduleService->shouldReceive('getModuleInfo') ->with('bar-module') ->andReturn([ 'is_installed' => false, 'status' => 'uninstalled', ]); $moduleService->shouldReceive('installModule')->once()->with('bar-module', \Mockery::any()); $moduleService->shouldReceive('activateModule')->once()->with('bar-module'); $this->app->instance(ModuleService::class, $moduleService); $this->harness->installSelectedDependencies([ ['type' => 'module', 'identifier' => 'bar-module'], ]); } public function test_active_module_is_skipped(): void { $moduleService = Mockery::mock(ModuleService::class); $moduleService->shouldReceive('getModuleInfo') ->with('baz-module') ->andReturn([ 'is_installed' => true, 'status' => ExtensionStatus::Active->value, ]); $moduleService->shouldNotReceive('installModule'); $moduleService->shouldNotReceive('activateModule'); $this->app->instance(ModuleService::class, $moduleService); $this->harness->installSelectedDependencies([ ['type' => 'module', 'identifier' => 'baz-module'], ]); } public function test_inactive_installed_plugin_only_activates(): void { $pluginService = Mockery::mock(PluginService::class); $pluginService->shouldReceive('getPluginInfo') ->with('foo-plugin') ->andReturn([ 'is_installed' => true, 'status' => ExtensionStatus::Inactive->value, ]); $pluginService->shouldNotReceive('installPlugin'); $pluginService->shouldReceive('activatePlugin')->once()->with('foo-plugin'); $this->app->instance(PluginService::class, $pluginService); $this->harness->installSelectedDependencies([ ['type' => 'plugin', 'identifier' => 'foo-plugin'], ]); } }