Update: 2026-07-05 22:59:19
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// ==============================================================================
|
||||
# Siro Guerrilla Marketing Flow Verification & Integration Test Script
|
||||
# ==============================================================================
|
||||
# This script executes a full dry-run integration test on the marketing engine.
|
||||
# It checks proxy assignments, country detection, dialect generation, and
|
||||
# dialogue scheduling.
|
||||
# ==============================================================================
|
||||
|
||||
require_once __DIR__ . '/../../core/bootstrap.php';
|
||||
require_once __DIR__ . '/schedule_manager.php';
|
||||
require_once __DIR__ . '/account_manager.php';
|
||||
|
||||
try {
|
||||
$con = Database::get('main');
|
||||
} catch (Exception $e) {
|
||||
die("[-] Connection failed: " . $e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
echo "[*] Starting Siro Integration Test...\n";
|
||||
|
||||
// --- 1. Set Up Mock Accounts ---
|
||||
echo "[*] Setting up mock accounts in database...\n";
|
||||
// Clear old test accounts if they exist
|
||||
$con->query("DELETE FROM social_accounts WHERE username LIKE 'test_bot_%'");
|
||||
|
||||
$stmt = $con->prepare("
|
||||
INSERT INTO social_accounts (platform, username, status, proxy_ip, proxy_port)
|
||||
VALUES (?, ?, 'active', ?, ?)
|
||||
");
|
||||
$stmt->execute(['facebook', 'test_bot_sy', '194.163.173.157', 8080]);
|
||||
$stmt->execute(['facebook', 'test_bot_jo', '194.163.173.200', 8080]);
|
||||
$stmt->execute(['facebook', 'test_bot_eg', '194.163.173.111', 8080]);
|
||||
|
||||
echo "[+] 3 Mock accounts created successfully.\n";
|
||||
|
||||
// --- 2. Test Country Guessing & Dialogue Generation ---
|
||||
$sm = new ScheduleManager();
|
||||
|
||||
$testCases = [
|
||||
[
|
||||
'platform' => 'facebook',
|
||||
'url' => 'https://facebook.com/groups/yallago.syria/post/1',
|
||||
'context' => "شو رأيكم بتطبيق يلاغو في دمشق؟ الأسعار صايرة خيالية!",
|
||||
'expected_country' => 'SY'
|
||||
],
|
||||
[
|
||||
'platform' => 'facebook',
|
||||
'url' => 'https://facebook.com/groups/taxif.amman/post/2',
|
||||
'context' => "التاكسي إف لغى رحلتي مرتين اليوم بعمان، شو في بديل؟",
|
||||
'expected_country' => 'JO'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($testCases as $index => $tc) {
|
||||
echo "\n------------------------------------------------------------\n";
|
||||
echo "[*] Test Case " . ($index + 1) . ": Target URL " . $tc['url'] . "\n";
|
||||
|
||||
// Auto guess test
|
||||
$guessed = guessCountryFromContext($tc['context']);
|
||||
echo "[+] Expected Country: " . $tc['expected_country'] . " | Guessed: " . $guessed . "\n";
|
||||
if ($guessed === $tc['expected_country']) {
|
||||
echo "[+] Country Detection: PASS\n";
|
||||
} else {
|
||||
echo "[-] Country Detection: FAIL\n";
|
||||
}
|
||||
|
||||
// Schedule Task
|
||||
// This will schedule the parent task and automatically trigger the dialogue simulator (Drama)
|
||||
echo "[*] Scheduling parent task and dialog drama...\n";
|
||||
$success = $sm->scheduleTask(
|
||||
platform: $tc['platform'],
|
||||
type: 'post_comment',
|
||||
targetUrl: $tc['url'],
|
||||
promptContext: $tc['context'],
|
||||
accountId: null,
|
||||
delayMinutes: 5
|
||||
);
|
||||
|
||||
if ($success) {
|
||||
echo "[+] Initial task and supporting drama scheduled successfully.\n";
|
||||
} else {
|
||||
echo "[-] Scheduling: FAIL\n";
|
||||
}
|
||||
}
|
||||
|
||||
// --- 3. Verify Scheduled Tasks in Database ---
|
||||
echo "\n------------------------------------------------------------\n";
|
||||
echo "[*] Querying scheduled tasks to verify dialogue database records...\n";
|
||||
|
||||
$stmtTasks = $con->prepare("
|
||||
SELECT t.id, t.type, t.target_url, t.generated_comment, t.scheduled_at, a.username, a.proxy_ip
|
||||
FROM social_tasks t
|
||||
LEFT JOIN social_accounts a ON t.account_id = a.id
|
||||
WHERE t.status = 'pending' AND t.target_url LIKE '%/post/%'
|
||||
ORDER BY t.scheduled_at ASC
|
||||
");
|
||||
$stmtTasks->execute();
|
||||
$tasks = $stmtTasks->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo "[+] Found " . count($tasks) . " pending tasks in queue:\n";
|
||||
foreach ($tasks as $t) {
|
||||
echo " - Account: [" . $t['username'] . " (IP: " . $t['proxy_ip'] . ")] | Type: " . $t['type'] . "\n";
|
||||
echo " Scheduled: " . $t['scheduled_at'] . "\n";
|
||||
echo " Generated Comment: \"" . trim($t['generated_comment']) . "\"\n\n";
|
||||
}
|
||||
|
||||
// --- 4. Clean Up Mock Database Data ---
|
||||
echo "[*] Cleaning up test data from DB...\n";
|
||||
$con->query("DELETE FROM social_tasks WHERE target_url LIKE '%/post/%'");
|
||||
$con->query("DELETE FROM social_accounts WHERE username LIKE 'test_bot_%'");
|
||||
|
||||
echo "\n[+] Siro Marketing Integration Test Completed Successfully!\n";
|
||||
Reference in New Issue
Block a user