29 lines
916 B
PHP
29 lines
916 B
PHP
<?php
|
|
// DbTypeTest.php
|
|
// Created: 2021-04-28
|
|
// Updated: 2024-10-19
|
|
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use Index\Db\DbType;
|
|
|
|
#[CoversClass(DbType::class)]
|
|
final class DbTypeTest extends TestCase {
|
|
public function testDetectType(): void {
|
|
$this->assertEquals(DbType::NULL, DbType::detect(null));
|
|
$this->assertEquals(DbType::INTEGER, DbType::detect(12345));
|
|
$this->assertEquals(DbType::FLOAT, DbType::detect(123.45));
|
|
$this->assertEquals(DbType::STRING, DbType::detect('This is a string.'));
|
|
|
|
$blob = fopen('php://memory', 'r+b');
|
|
if($blob === false)
|
|
throw new RuntimeException('failed to fopen a memory stream');
|
|
|
|
fwrite($blob, 'This is a string inside a memory stream.');
|
|
fseek($blob, 0);
|
|
|
|
$this->assertEquals(DbType::BLOB, DbType::detect($blob));
|
|
}
|
|
}
|