Derive mode from DSN function

- Add headers in all files
- Minor field name changes
This commit is contained in:
2024-07-20 21:47:21 -04:00
parent 1a37b009ea
commit d8330d828a
81 changed files with 1053 additions and 551 deletions

View File

@@ -1,4 +1,10 @@
<?php declare(strict_types=1);
<?php
/**
* @author Daniel J. Summers <daniel@bitbadger.solutions>
* @license MIT
*/
declare(strict_types=1);
namespace Test\Unit\Query;
@@ -15,14 +21,14 @@ class DefinitionTest extends TestCase
{
protected function tearDown(): void
{
Configuration::$mode = null;
Configuration::overrideMode(null);
parent::tearDown();
}
#[TestDox('Ensure table succeeds for PosgtreSQL')]
public function testEnsureTableSucceedsForPostgreSQL(): void
{
Configuration::$mode = Mode::PgSQL;
Configuration::overrideMode(Mode::PgSQL);
$this->assertEquals('CREATE TABLE IF NOT EXISTS documents (data JSONB NOT NULL)',
Definition::ensureTable('documents'), 'CREATE TABLE statement not generated correctly');
}
@@ -30,7 +36,7 @@ class DefinitionTest extends TestCase
#[TestDox('Ensure table succeeds for SQLite')]
public function testEnsureTableSucceedsForSQLite(): void
{
Configuration::$mode = Mode::SQLite;
Configuration::overrideMode(Mode::SQLite);
$this->assertEquals('CREATE TABLE IF NOT EXISTS dox (data TEXT NOT NULL)', Definition::ensureTable('dox'),
'CREATE TABLE statement not generated correctly');
}
@@ -63,14 +69,14 @@ class DefinitionTest extends TestCase
public function testEnsureDocumentIndexOnSucceedsForSchemaAndFull(): void
{
Configuration::$mode = Mode::PgSQL;
Configuration::overrideMode(Mode::PgSQL);
$this->assertEquals("CREATE INDEX IF NOT EXISTS idx_tbl_document ON my.tbl USING GIN (data)",
Definition::ensureDocumentIndexOn('my.tbl', DocumentIndex::Full));
}
public function testEnsureDocumentIndexOnSucceedsForNoSchemaAndOptimized(): void
{
Configuration::$mode = Mode::PgSQL;
Configuration::overrideMode(Mode::PgSQL);
$this->assertEquals("CREATE INDEX IF NOT EXISTS idx_it_document ON it USING GIN (data jsonb_path_ops)",
Definition::ensureDocumentIndexOn('it', DocumentIndex::Optimized));
}