48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||
|
* @license MIT
|
||
|
*/
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
use BitBadger\PDODocument\{Definition, DocumentIndex};
|
||
|
|
||
|
pest()->group('integration', 'postgresql');
|
||
|
|
||
|
describe('::ensureTable()', function () {
|
||
|
test('creates a table', function () {
|
||
|
expect($this->dbObjectExists('ensured'))->toBeFalse()
|
||
|
->and($this->dbObjectExists('idx_ensured_key'))->toBeFalse();
|
||
|
Definition::ensureTable('ensured');
|
||
|
expect($this->dbObjectExists('ensured'))->toBeTrue()
|
||
|
->and($this->dbObjectExists('idx_ensured_key'))->toBeTrue();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('::ensureFieldIndex()', function () {
|
||
|
test('creates an index', function () {
|
||
|
expect($this->dbObjectExists('idx_ensured_test'))->toBeFalse();
|
||
|
Definition::ensureTable('ensured');
|
||
|
Definition::ensureFieldIndex('ensured', 'test', ['name', 'age']);
|
||
|
expect($this->dbObjectExists('idx_ensured_test'))->toBeTrue();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('::ensureDocumentIndex()', function () {
|
||
|
test('creates a full index', function () {
|
||
|
$docIdx = 'idx_doc_table_document';
|
||
|
Definition::ensureTable('doc_table');
|
||
|
expect($this->dbObjectExists($docIdx))->toBeFalse();
|
||
|
Definition::ensureDocumentIndex('doc_table', DocumentIndex::Full);
|
||
|
expect($this->dbObjectExists($docIdx))->toBeTrue();
|
||
|
});
|
||
|
test('creates an optimized index', function () {
|
||
|
$docIdx = 'idx_doc_tbl_document';
|
||
|
Definition::ensureTable('doc_tbl');
|
||
|
expect($this->dbObjectExists($docIdx))->toBeFalse();
|
||
|
Definition::ensureDocumentIndex('doc_tbl', DocumentIndex::Optimized);
|
||
|
expect($this->dbObjectExists($docIdx))->toBeTrue();
|
||
|
});
|
||
|
});
|