Skip to content

Commit afdb32a

Browse files
committed
test: add additional tests for MonitorManager SQLite methods
- Add tests for getActiveQueriesSQLite method - Add tests for getActiveConnectionsSQLite method - Add tests for getSlowQueriesSQLite with profiling enabled - Add tests for getSlowQueriesSQLite without profiling Total: 4 new tests added to MonitorManagerTests. Code coverage increased from 65.82% to 65.93% (Lines: 18194/27596). All tests pass successfully.
1 parent 38d538b commit afdb32a

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/shared/MonitorManagerTests.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,59 @@ public function testMonitorManagerToFloat(): void
8181
$this->assertEquals(0.0, $method->invoke(null, null));
8282
$this->assertEquals(0.0, $method->invoke(null, []));
8383
}
84+
85+
public function testMonitorManagerGetActiveQueriesSQLite(): void
86+
{
87+
$reflection = new ReflectionClass(MonitorManager::class);
88+
$method = $reflection->getMethod('getActiveQueriesSQLite');
89+
$method->setAccessible(true);
90+
91+
$result = $method->invoke(null, self::$db);
92+
$this->assertIsArray($result);
93+
// SQLite doesn't have built-in query monitoring, should return empty array
94+
$this->assertEmpty($result);
95+
}
96+
97+
public function testMonitorManagerGetActiveConnectionsSQLite(): void
98+
{
99+
$reflection = new ReflectionClass(MonitorManager::class);
100+
$method = $reflection->getMethod('getActiveConnectionsSQLite');
101+
$method->setAccessible(true);
102+
103+
$result = $method->invoke(null, self::$db);
104+
$this->assertIsArray($result);
105+
$this->assertArrayHasKey('connections', $result);
106+
$this->assertArrayHasKey('summary', $result);
107+
$this->assertIsArray($result['connections']);
108+
$this->assertIsArray($result['summary']);
109+
}
110+
111+
public function testMonitorManagerGetSlowQueriesSQLite(): void
112+
{
113+
// Enable profiling for SQLite slow queries
114+
self::$db->enableProfiling();
115+
self::$db->rawQuery('SELECT 1');
116+
117+
$reflection = new ReflectionClass(MonitorManager::class);
118+
$method = $reflection->getMethod('getSlowQueriesSQLite');
119+
$method->setAccessible(true);
120+
121+
$result = $method->invoke(null, self::$db, 0.001, 10);
122+
$this->assertIsArray($result);
123+
}
124+
125+
public function testMonitorManagerGetSlowQueriesSQLiteWithoutProfiling(): void
126+
{
127+
// Disable profiling
128+
self::$db->disableProfiling();
129+
130+
$reflection = new ReflectionClass(MonitorManager::class);
131+
$method = $reflection->getMethod('getSlowQueriesSQLite');
132+
$method->setAccessible(true);
133+
134+
$result = $method->invoke(null, self::$db, 0.001, 10);
135+
$this->assertIsArray($result);
136+
// Without profiling, should return empty array
137+
$this->assertEmpty($result);
138+
}
84139
}

0 commit comments

Comments
 (0)