Add byContains and byJsonPath

- Add document index functions
This commit is contained in:
2024-06-12 17:43:17 -04:00
parent 65fd46835c
commit 9ecabbe39f
32 changed files with 632 additions and 139 deletions

View File

@@ -2,7 +2,7 @@
namespace Test\Integration\PostgreSQL;
use BitBadger\PDODocument\{Custom, Definition, DocumentException};
use BitBadger\PDODocument\{Custom, Definition, DocumentException, DocumentIndex};
use BitBadger\PDODocument\Mapper\ExistsMapper;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
@@ -41,7 +41,7 @@ class DefinitionTest extends TestCase
[':name' => $name], new ExistsMapper());
}
public function testEnsureTableSucceeds()
public function testEnsureTableSucceeds(): void
{
$this->assertFalse($this->itExists('ensured'), 'The table should not exist already');
$this->assertFalse($this->itExists('idx_ensured_key'), 'The key index should not exist already');
@@ -50,11 +50,29 @@ class DefinitionTest extends TestCase
$this->assertTrue($this->itExists('idx_ensured_key'), 'The key index should now exist');
}
public function testEnsureFieldIndexSucceeds()
public function testEnsureFieldIndexSucceeds(): void
{
$this->assertFalse($this->itExists('idx_ensured_test'), 'The index should not exist already');
Definition::ensureTable('ensured');
Definition::ensureFieldIndex('ensured', 'test', ['name', 'age']);
$this->assertTrue($this->itExists('idx_ensured_test'), 'The index should now exist');
}
public function testEnsureDocumentIndexSucceedsForFull(): void
{
$docIdx = 'idx_' . ThrowawayDb::TABLE . '_document';
Definition::ensureTable(ThrowawayDb::TABLE);
$this->assertFalse($this->itExists($docIdx), 'The document index should not exist');
Definition::ensureDocumentIndex(ThrowawayDb::TABLE, DocumentIndex::Full);
$this->assertTrue($this->itExists($docIdx), 'The document index should now exist');
}
public function testEnsureDocumentIndexSucceedsForOptimized(): void
{
$docIdx = 'idx_' . ThrowawayDb::TABLE . '_document';
Definition::ensureTable(ThrowawayDb::TABLE);
$this->assertFalse($this->itExists($docIdx), 'The document index should not exist');
Definition::ensureDocumentIndex(ThrowawayDb::TABLE, DocumentIndex::Optimized);
$this->assertTrue($this->itExists($docIdx), 'The document index should now exist');
}
}