<?php
 namespace App\Console\Commands; use App\Facades\Product; use Illuminate\Console\Command; class ProductTest extends Command { protected $signature = 'module:product-test 
                            {module : Test edilecek ürün modülü} 
                            {--connection : Sadece bağlantı testi yap}'; protected $description = 'Ürün sağlayıcı modülünü test etmeye yarar'; public function handle() { $moduleName = $this->argument('module'); $connectionOnly = $this->option('connection'); $this->info(__('console.product_test_starting', ['module' => $moduleName])); try { if (! Product::has($moduleName)) { $this->error(__('console.product_test_module_not_found', ['module' => $moduleName])); return 1; } $module = Product::get($moduleName); if ($connectionOnly) { $this->info(__('console.product_test_connection_testing')); $response = $module->testConnection(); $this->table( [__('console.product_test_status'), __('console.product_test_message')], [[ $response['status'] ?? __('console.product_test_unknown'), $response['message'] ?? json_encode($response), ]] ); } else { $this->info(__('console.product_test_module_info')); $adminFields = $module->adminFields(); if (! empty($adminFields)) { $this->info(__('console.product_test_admin_fields')); $fieldData = []; foreach ($adminFields as $key => $field) { $fieldData[] = [ $key, $field['name'] ?? __('console.product_test_unnamed'), $field['type'] ?? 'text', $field['required'] ? __('console.product_test_yes') : __('console.product_test_no'), $field['description'] ?? '-', ]; } $this->table([ __('console.product_test_field_name'), __('console.product_test_display_name'), __('console.product_test_type'), __('console.product_test_required'), __('console.product_test_description') ], $fieldData); } else { $this->warn(__('console.product_test_no_admin_fields')); } } return 0; } catch (\Exception $e) { $this->error(__('console.product_test_error', ['message' => $e->getMessage()])); return 1; } } } 