ver. 0.310: logi integracji w panelu admin
Nowa zakladka "Logi" w sekcji Integracje - podglad tabeli pp_log z paginacja, sortowaniem, filtrami i rozwijalnym kontekstem JSON. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -298,4 +298,69 @@ class IntegrationsRepositoryTest extends TestCase
|
||||
$this->assertSame('1', (string)$result[0]['id']);
|
||||
$this->assertSame('Przelew', (string)$result[0]['name']);
|
||||
}
|
||||
|
||||
// ── Logs ────────────────────────────────────────────────────
|
||||
|
||||
public function testGetLogsReturnsItemsAndTotal(): void
|
||||
{
|
||||
$this->mockDb->expects($this->once())
|
||||
->method('count')
|
||||
->with('pp_log', $this->anything())
|
||||
->willReturn(2);
|
||||
|
||||
$this->mockDb->expects($this->once())
|
||||
->method('select')
|
||||
->with('pp_log', '*', $this->anything())
|
||||
->willReturn([
|
||||
['id' => 1, 'action' => 'send_order', 'message' => 'OK', 'date' => '2026-01-01 12:00:00'],
|
||||
['id' => 2, 'action' => 'status_sync', 'message' => 'Synced', 'date' => '2026-01-02 12:00:00'],
|
||||
]);
|
||||
|
||||
$result = $this->repository->getLogs([], 'id', 'DESC', 1, 15);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('items', $result);
|
||||
$this->assertArrayHasKey('total', $result);
|
||||
$this->assertCount(2, $result['items']);
|
||||
$this->assertSame(2, $result['total']);
|
||||
}
|
||||
|
||||
public function testGetLogsReturnsEmptyWhenNoResults(): void
|
||||
{
|
||||
$this->mockDb->method('count')->willReturn(0);
|
||||
$this->mockDb->method('select')->willReturn([]);
|
||||
|
||||
$result = $this->repository->getLogs([], 'id', 'DESC', 1, 15);
|
||||
|
||||
$this->assertSame(0, $result['total']);
|
||||
$this->assertEmpty($result['items']);
|
||||
}
|
||||
|
||||
public function testGetLogsHandlesNullFromSelect(): void
|
||||
{
|
||||
$this->mockDb->method('count')->willReturn(0);
|
||||
$this->mockDb->method('select')->willReturn(null);
|
||||
|
||||
$result = $this->repository->getLogs([], 'id', 'DESC', 1, 15);
|
||||
|
||||
$this->assertSame([], $result['items']);
|
||||
}
|
||||
|
||||
public function testDeleteLogCallsDelete(): void
|
||||
{
|
||||
$this->mockDb->expects($this->once())
|
||||
->method('delete')
|
||||
->with('pp_log', ['id' => 42]);
|
||||
|
||||
$this->assertTrue($this->repository->deleteLog(42));
|
||||
}
|
||||
|
||||
public function testClearLogsDeletesAll(): void
|
||||
{
|
||||
$this->mockDb->expects($this->once())
|
||||
->method('delete')
|
||||
->with('pp_log', []);
|
||||
|
||||
$this->assertTrue($this->repository->clearLogs());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user