mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Move db stats to separate classes for each db type
Project......: Performance Profiling Sponsored-by.: NLnet NGI0 Commons Fund
This commit is contained in:
41
tests/unit/Lib/DbStatsTest.php
Normal file
41
tests/unit/Lib/DbStatsTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/* Test cases for DbStats
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 The Hubzilla Community
|
||||
* SPDX-FileContributor: Harald Eilertsen <haraldei@anduin.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
namespace Zotlabs\Tests\Unit\Lib;
|
||||
|
||||
use DBA;
|
||||
use Zotlabs\Lib\DbStats;
|
||||
use Zotlabs\Tests\Unit\UnitTestCase;
|
||||
|
||||
class DbStatsTest extends UnitTestCase
|
||||
{
|
||||
public function testGetQueries(): void {
|
||||
$stats = DbStats::getStats();
|
||||
$this->assertNotNull($stats);
|
||||
$this->assertInstanceOf(DbStats::class, $stats);
|
||||
|
||||
$numQueries = $stats->getQueries();
|
||||
$this->assertNotEquals(0, $numQueries);
|
||||
|
||||
if (!DBA::$dba->is_postgres()) {
|
||||
//
|
||||
// Postgres will only update the stats once the transaction
|
||||
// is committed or rolled back. As we wrap the tests in a
|
||||
// transaction to begin with, the stats won't change here,
|
||||
// so we skip this test on Postgres.
|
||||
//
|
||||
dbq("select * from account");
|
||||
dbq("select * from channel");
|
||||
dbq("select * from xchan");
|
||||
|
||||
$numMoreQueries = $stats->getQueries();
|
||||
$this->assertGreaterThan($numQueries, $numMoreQueries);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user