Add PDO connection config
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Test\Unit;
|
||||
|
||||
use BitBadger\PDODocument\Configuration;
|
||||
use BitBadger\PDODocument\DocumentException;
|
||||
use PHPUnit\Framework\Attributes\TestDox;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
@@ -12,17 +14,24 @@ class ConfigurationTest extends TestCase
|
||||
{
|
||||
public function testIdFieldDefaultSucceeds(): void
|
||||
{
|
||||
$this->assertEquals('id', Configuration::idField(), 'Default ID field should be "id"');
|
||||
$this->assertEquals('id', Configuration::$idField, 'Default ID field should be "id"');
|
||||
}
|
||||
|
||||
public function testUseIdFieldSucceeds()
|
||||
public function testIdFieldChangeSucceeds()
|
||||
{
|
||||
try {
|
||||
Configuration::useIdField('EyeDee');
|
||||
$this->assertEquals('EyeDee', Configuration::idField(), 'ID field should have been updated');
|
||||
Configuration::$idField = 'EyeDee';
|
||||
$this->assertEquals('EyeDee', Configuration::$idField, 'ID field should have been updated');
|
||||
} finally {
|
||||
Configuration::useIdField('id');
|
||||
$this->assertEquals('id', Configuration::idField(), 'Default ID value should have been restored');
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user