Files
toolbox/tests/Feature/EventConsumerSyncTest.php
2025-12-02 10:16:32 +08:00

71 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature;
use Tests\TestCase;
use Carbon\Carbon;
class EventConsumerSyncTest extends TestCase
{
/**
* 测试对比事件消费者同步状态 API
*/
public function test_compare_event_consumer_sync_api()
{
$response = $this->postJson('/api/message-sync/compare-event-consumer', [
'start_time' => Carbon::now()->subDays(7)->format('Y-m-d H:i:s'),
'end_time' => Carbon::now()->format('Y-m-d H:i:s'),
'exclude_messages' => []
]);
$response->assertStatus(200);
$response->assertJsonStructure([
'success',
'data' => [
'crm_total',
'agent_total',
'missing_count',
'sync_rate',
'missing_messages',
'summary'
]
]);
}
/**
* 测试导出缺失消息 API
*/
public function test_export_missing_messages_api()
{
$response = $this->postJson('/api/message-sync/export-missing-messages', [
'start_time' => Carbon::now()->subDays(7)->format('Y-m-d H:i:s'),
'end_time' => Carbon::now()->format('Y-m-d H:i:s'),
'exclude_messages' => []
]);
$response->assertStatus(200);
$response->assertJsonStructure([
'success',
'data' => [
'csv',
'filename',
'count'
]
]);
}
/**
* 测试无效的时间格式
*/
public function test_invalid_time_format()
{
$response = $this->postJson('/api/message-sync/compare-event-consumer', [
'start_time' => 'invalid-date',
'end_time' => 'invalid-date'
]);
$response->assertStatus(422);
}
}