pdo-document/tests/unit/ConfigurationTest.php

38 lines
1.1 KiB
PHP

<?php declare(strict_types=1);
namespace Test\Unit;
use BitBadger\PDODocument\Configuration;
use BitBadger\PDODocument\DocumentException;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
/**
* Unit tests for the Configuration class
*/
class ConfigurationTest extends TestCase
{
public function testIdFieldDefaultSucceeds(): void
{
$this->assertEquals('id', Configuration::$idField, 'Default ID field should be "id"');
}
public function testIdFieldChangeSucceeds()
{
try {
Configuration::$idField = 'EyeDee';
$this->assertEquals('EyeDee', Configuration::$idField, 'ID field should have been updated');
} finally {
Configuration::$idField = 'id';
$this->assertEquals('id', Configuration::$idField, 'Default ID value should have been restored');
}
}
#[TestDox("Db conn fails when no DSN specified")]
public function testDbConnFailsWhenNoDSNSpecified(): void
{
$this->expectException(DocumentException::class);
Configuration::dbConn();
}
}