$phone, 'body' => $body, 'id' => 'msg_' . uniqid() ]; $handled = ConversationFlowEngine::processMessage($session, $msgData); echo "Handled by Engine: " . ($handled ? "YES" : "NO") . "\n"; // Print current state in DB $state = ConversationState::findActive($session['company_id'], $phone); if ($state) { echo "Current DB State: Step = '{$state['current_step']}', Context = '{$state['context_data']}'\n"; } else { echo "Current DB State: [No Active Flow / Finished]\n"; } } // 3. Run test cases // Case A: Message not triggering anything simulateIncoming($session, $testPhone, "مرحبا"); // Case B: Trigger keyword "اختبار" simulateIncoming($session, $testPhone, "اختبار"); // Case C: Provide name "احمد" simulateIncoming($session, $testPhone, "احمد"); // Case D: Provide invalid rating "10" simulateIncoming($session, $testPhone, "10"); // Case E: Provide valid rating "5" simulateIncoming($session, $testPhone, "5"); // Case F: Start again and test cancellation simulateIncoming($session, $testPhone, "اختبار"); simulateIncoming($session, $testPhone, "إلغاء"); echo "\n=== Mock Test Complete ===\n";