1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-23 18:29:15 +03:00
Files
phpmyadmin/tests/unit/Server/SysInfo/SysInfoTest.php
Kamil Tekiela 5e5fe6a72f Update testGetSysInfo
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2026-10-17 18:47:58 +01:00

66 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Server\SysInfo;
use PhpMyAdmin\Server\SysInfo\Base;
use PhpMyAdmin\Server\SysInfo\Linux;
use PhpMyAdmin\Server\SysInfo\SunOs;
use PhpMyAdmin\Server\SysInfo\SysInfo;
use PhpMyAdmin\Server\SysInfo\WindowsNt;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
#[CoversClass(SysInfo::class)]
class SysInfoTest extends AbstractTestCase
{
/**
* Test for OS detection
*
* @param string $os OS name as returned by PHP_OS
* @param string $expected Expected detected OS name
*/
#[DataProvider('sysInfoOsProvider')]
public function testGetSysInfoOs(string $os, string $expected): void
{
self::assertSame(
$expected,
SysInfo::getOs($os),
);
}
/**
* Data provider for OS detection tests.
*
* @return string[][]
*/
public static function sysInfoOsProvider(): array
{
return [['FreeBSD', 'Linux'], ['Linux', 'Linux'], ['Winnt', 'Winnt'], ['SunOS', 'SunOS']];
}
/**
* Test for getting sysinfo object.
*/
public function testGetSysInfo(): void
{
$isSupported = match (SysInfo::getOs()) {
'Linux' => Linux::isSupported(),
'WINNT' => WindowsNt::isSupported(),
'SunOS' => SunOs::isSupported(),
default => false,
};
$sysInfo = SysInfo::get();
if (! $isSupported) {
self::assertSame(Base::class, $sysInfo::class);
return;
}
self::assertNotSame(Base::class, $sysInfo::class);
}
}