This commit is contained in:
lizandrogd
2026-01-21 08:28:54 -05:00
parent 7d6c3b4fb4
commit 45a11032f5
59 changed files with 315 additions and 315 deletions
+27 -27
View File
@@ -279,31 +279,31 @@ class APITestSuite {
private function testConfigurationAPIs() {
echo "<h4>⚙️ Tests de APIs de Configuración</h4>";
// Test get_settings.php
$this->apiTest("API get_settings existe", function() {
if (!file_exists(__DIR__ . '/../api/get_settings.php')) {
throw new Exception("get_settings.php no existe");
// Test get_system_config.php
$this->apiTest("API get_system_config existe", function() {
if (!file_exists(__DIR__ . '/../api/get_system_config.php')) {
throw new Exception("get_system_config.php no existe");
}
$content = file_get_contents(__DIR__ . '/../api/get_settings.php');
$content = file_get_contents(__DIR__ . '/../api/get_system_config.php');
if (strpos($content, 'requireAuthentication()') === false) {
throw new Exception("get_settings no requiere autenticación");
throw new Exception("get_system_config no requiere autenticación");
}
return "API get_settings correcta";
return "API get_system_config correcta";
});
// Test save_settings.php
$this->apiTest("API save_settings existe", function() {
if (!file_exists(__DIR__ . '/../api/save_settings.php')) {
throw new Exception("save_settings.php no existe");
// Test save_system_config.php
$this->apiTest("API save_system_config existe", function() {
if (!file_exists(__DIR__ . '/../api/save_system_config.php')) {
throw new Exception("save_system_config.php no existe");
}
$content = file_get_contents(__DIR__ . '/../api/save_settings.php');
$content = file_get_contents(__DIR__ . '/../api/save_system_config.php');
if (strpos($content, 'requireAuthentication()') === false) {
throw new Exception("save_settings no requiere autenticación");
throw new Exception("save_system_config no requiere autenticación");
}
$fields = ['business_name', 'whatsapp_token', 'phone_number_id'];
@@ -313,16 +313,16 @@ class APITestSuite {
}
}
return "API save_settings completa";
return "API save_system_config completa";
});
// Verificar tabla settings
// Verificar tabla system_config
$this->apiTest("Verificar tabla configuración", function() {
$db = Database::getInstance();
$result = $db->fetchAll("SHOW TABLES LIKE 'settings'");
$result = $db->fetchAll("SHOW TABLES LIKE 'system_config'");
if (!$result || empty($result)) {
throw new Exception("Tabla settings no existe");
throw new Exception("Tabla system_config no existe");
}
return "Tabla de configuración existe";
@@ -344,7 +344,7 @@ class APITestSuite {
throw new Exception("get_stats no requiere autenticación");
}
$stats = ['total_users', 'messages_today', 'active_users', 'total_messages'];
$stats = ['total_users', 'conversations_today', 'active_users', 'total_conversations'];
foreach ($stats as $stat) {
if (strpos($content, $stat) === false) {
throw new Exception("Estadística '$stat' no está implementada");
@@ -369,30 +369,30 @@ class APITestSuite {
return "API get_chart_data correcta";
});
// Test get_recent_messages.php
$this->apiTest("API get_recent_messages existe", function() {
if (!file_exists(__DIR__ . '/../api/get_recent_messages.php')) {
throw new Exception("get_recent_messages.php no existe");
// Test get_recent_conversations.php
$this->apiTest("API get_recent_conversations existe", function() {
if (!file_exists(__DIR__ . '/../api/get_recent_conversations.php')) {
throw new Exception("get_recent_conversations.php no existe");
}
$content = file_get_contents(__DIR__ . '/../api/get_recent_messages.php');
$content = file_get_contents(__DIR__ . '/../api/get_recent_conversations.php');
if (strpos($content, 'requireAuthentication()') === false) {
throw new Exception("get_recent_messages no requiere autenticación");
throw new Exception("get_recent_conversations no requiere autenticación");
}
if (strpos($content, 'messages') === false && strpos($content, 'conversations') === false) {
if (strpos($content, 'conversations') === false && strpos($content, 'conversations') === false) {
throw new Exception("No consulta mensajes");
}
return "API get_recent_messages correcta";
return "API get_recent_conversations correcta";
});
// Test de integridad de datos
$this->apiTest("Verificar tablas de analytics", function() {
$db = Database::getInstance();
$tables = ['messages', 'conversations'];
$tables = ['conversations', 'conversations'];
foreach ($tables as $table) {
$result = $db->fetchAll("SHOW TABLES LIKE '$table'");
if (!$result || empty($result)) {
+2 -2
View File
@@ -314,7 +314,7 @@ class TestRunner {
'changes' => [
[
'value' => [
'messages' => [
'conversations' => [
[
'from' => '573001234567',
'text' => ['body' => 'test message'],
@@ -442,7 +442,7 @@ class TestRunner {
$db = Database::getInstance();
$requiredTables = [
'users', 'conversations', 'menus', 'menu_options',
'system_config', 'auto_responses', 'message_templates',
'system_config', 'autoresponses', 'message_templates',
'webhook_logs'
];
+1 -1
View File
@@ -114,7 +114,7 @@ class SecurityTestSuite {
$this->securityTest("APIs requieren autenticación", function() {
$protectedAPIs = [
'get_stats.php', 'get_users.php', 'send_message.php',
'save_template.php', 'get_templates.php', 'save_settings.php'
'save_template.php', 'get_templates.php', 'save_system_config.php'
];
unset($_SESSION['admin_logged_in']);
+2 -2
View File
@@ -203,7 +203,7 @@ class ServiceTestSuite {
$this->serviceTest("Test de respuestas automáticas", function() {
// Verificar que hay respuestas automáticas configuradas
$responses = $this->db->fetchAll(
"SELECT * FROM auto_responses WHERE trigger_type = 'keyword'"
"SELECT * FROM autoresponses WHERE trigger_type = 'keyword'"
);
if (empty($responses)) {
@@ -216,7 +216,7 @@ class ServiceTestSuite {
foreach ($requiredFields as $field) {
if (!isset($firstResponse[$field])) {
throw new Exception("Campo requerido '$field' faltante en auto_responses");
throw new Exception("Campo requerido '$field' faltante en autoresponses");
}
}
+8 -8
View File
@@ -159,7 +159,7 @@ class WebhookTestSuite {
'display_phone_number' => '573001234567',
'phone_number_id' => WHATSAPP_PHONE_NUMBER_ID
],
'messages' => [
'conversations' => [
[
'from' => '573009876543',
'id' => 'wamid.test123',
@@ -171,7 +171,7 @@ class WebhookTestSuite {
]
]
],
'field' => 'messages'
'field' => 'conversations'
]
]
]
@@ -183,7 +183,7 @@ class WebhookTestSuite {
throw new Exception("Estructura de payload incorrecta");
}
if (!isset($validPayload['entry'][0]['changes'][0]['value']['messages'])) {
if (!isset($validPayload['entry'][0]['changes'][0]['value']['conversations'])) {
throw new Exception("Estructura de mensajes incorrecta");
}
@@ -205,7 +205,7 @@ class WebhookTestSuite {
'changes' => [
[
'value' => [
'messages' => [
'conversations' => [
[
'from' => $testPhone,
'id' => 'test_message_id',
@@ -328,9 +328,9 @@ class WebhookTestSuite {
[
'changes' => [
[
'field' => 'messages',
'field' => 'conversations',
'value' => [
'messages' => [
'conversations' => [
[
'from' => $testPhone,
'id' => '2001',
@@ -383,9 +383,9 @@ class WebhookTestSuite {
[
'changes' => [
[
'field' => 'messages',
'field' => 'conversations',
'value' => [
'messages' => [
'conversations' => [
[
'from' => $testPhone,
'id' => '2002',
+2 -2
View File
@@ -21,7 +21,7 @@ $data = [
'type' => 'reaction',
'reaction' => ['message_id' => '5001', 'emoji' => '❤️']
];
$response = ['messages' => [['id' => 'out_msg_1']]];
$response = ['conversations' => [['id' => 'out_msg_1']]];
$foundUser = $db->fetch('SELECT * FROM users WHERE phone_number = :p', ['p' => $phone]);
echo "User found for outgoing reaction? " . ($foundUser ? 'yes' : 'no') . "\n";
@@ -71,7 +71,7 @@ $data2 = [
'context' => ['message_id' => '5002'],
'text' => ['body' => 'Gracias']
];
$response2 = ['messages' => [['id' => 'out_msg_2']]];
$response2 = ['conversations' => [['id' => 'out_msg_2']]];
$method->invokeArgs($service, [$data2, $response2]);
$conv2 = $db->fetch('SELECT * FROM conversations WHERE message_id = :mid', ['mid' => 'out_msg_2']);
if ($conv2) {