LMIV-SNACKAUTOMAT/app/Console/Commands/TestPublicDisplay.php

79 lines
2.4 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Tenant;
use App\Http\Controllers\VendingDisplayController;
use Illuminate\Http\Request;
class TestPublicDisplay extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:public-display';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Test public display with different tenant settings';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('=== Public Display Test ===');
$tenant = Tenant::first();
if (!$tenant) {
$this->error('Kein Mandant gefunden!');
return 1;
}
$this->info("Testing with Tenant: {$tenant->name}");
// Test 1: Beide Einstellungen aktiviert
$tenant->update(['show_prices' => true, 'show_stock' => true]);
$this->testDisplay($tenant, 'Beide aktiviert');
// Test 2: Nur Preise deaktiviert
$tenant->update(['show_prices' => false, 'show_stock' => true]);
$this->testDisplay($tenant, 'Preise deaktiviert');
// Test 3: Nur Stock deaktiviert
$tenant->update(['show_prices' => true, 'show_stock' => false]);
$this->testDisplay($tenant, 'Stock deaktiviert');
// Test 4: Beide deaktiviert
$tenant->update(['show_prices' => false, 'show_stock' => false]);
$this->testDisplay($tenant, 'Beide deaktiviert');
// Zurücksetzen
$tenant->update(['show_prices' => true, 'show_stock' => true]);
$this->info('✅ Einstellungen zurückgesetzt');
return 0;
}
private function testDisplay($tenant, $scenario)
{
$this->info("--- Test: {$scenario} ---");
$this->info("show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
$this->info("show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
// Simuliere öffentliche Anzeige-Logik
$showPrice = !isset($tenant) || $tenant->show_prices;
$showStock = !isset($tenant) || $tenant->show_stock;
$this->info("Würde Preis anzeigen: " . ($showPrice ? 'JA' : 'NEIN'));
$this->info("Würde Stock anzeigen: " . ($showStock ? 'JA' : 'NEIN'));
$this->newLine();
}
}