pdo-document/tests/unit/ConfigurationTest.php
Daniel J. Summers d067f8983f Changes for beta10 (#5)
- Add In/InArray support
- Add ORDER BY support for `Find` functions
- Update dependencies
- Implement fixes identified via static analysis

Reviewed-on: #5
2024-09-27 02:15:00 +00:00

59 lines
1.7 KiB
PHP

<?php
/**
* @author Daniel J. Summers <daniel@bitbadger.solutions>
* @license MIT
*/
declare(strict_types=1);
namespace Test\Unit;
use BitBadger\PDODocument\{AutoId, Configuration, DocumentException};
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
/**
* Unit tests for the Configuration class
*/
#[TestDox('Configuration (Unit tests)')]
class ConfigurationTest extends TestCase
{
#[TestDox('id default succeeds')]
public function testIdFieldDefaultSucceeds(): void
{
$this->assertEquals('id', Configuration::$idField, 'Default ID field should be "id"');
}
#[TestDox('id change succeeds')]
public function testIdFieldChangeSucceeds(): void
{
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('autoId default succeeds')]
public function testAutoIdDefaultSucceeds(): void
{
$this->assertEquals(AutoId::None, Configuration::$autoId, 'Auto ID should default to None');
}
#[TestDox('idStringLength default succeeds')]
public function testIdStringLengthDefaultSucceeds(): void
{
$this->assertEquals(16, Configuration::$idStringLength, 'ID string length should default to 16');
}
#[TestDox("dbConn() fails when no DSN specified")]
public function testDbConnFailsWhenNoDSNSpecified(): void
{
$this->expectException(DocumentException::class);
Configuration::useDSN('');
Configuration::dbConn();
}
}