90 lines
2.7 KiB
PHP
90 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use App\Models\Tenant;
|
|
use App\Http\Controllers\SettingsController;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class TestTenantSettingsWeb extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'test:tenant-settings-web';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Test tenant settings via web interface simulation';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info('=== Web Interface Test ===');
|
|
|
|
$tenant = Tenant::first();
|
|
if (!$tenant) {
|
|
$this->error('Kein Mandant gefunden!');
|
|
return 1;
|
|
}
|
|
|
|
$this->info("Testing with Tenant: {$tenant->name}");
|
|
$this->info("Original show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
|
$this->info("Original show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
|
|
|
// Simuliere Session
|
|
Session::put('current_tenant_id', $tenant->id);
|
|
Session::put('current_tenant', $tenant);
|
|
|
|
// Simuliere Request mit deaktivierten Checkboxen
|
|
$request = new Request();
|
|
$request->merge([
|
|
'_token' => csrf_token(),
|
|
'_method' => 'PUT'
|
|
// Checkboxes nicht gesetzt = deaktiviert
|
|
]);
|
|
|
|
try {
|
|
$controller = new SettingsController();
|
|
$response = $controller->updateTenantSettings($request);
|
|
|
|
// Prüfe Ergebnis
|
|
$tenant->refresh();
|
|
$this->info("Nach Update - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
|
$this->info("Nach Update - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
|
|
|
// Test mit aktivierten Checkboxen
|
|
$request2 = new Request();
|
|
$request2->merge([
|
|
'_token' => csrf_token(),
|
|
'_method' => 'PUT',
|
|
'show_prices' => '1',
|
|
'show_stock' => '1'
|
|
]);
|
|
|
|
$controller->updateTenantSettings($request2);
|
|
|
|
$tenant->refresh();
|
|
$this->info("Nach Reaktivierung - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
|
$this->info("Nach Reaktivierung - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
|
|
|
$this->info('✅ Web Interface Test erfolgreich!');
|
|
|
|
} catch (\Exception $e) {
|
|
$this->error('Fehler: ' . $e->getMessage());
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|