* @license MIT */ declare(strict_types=1); use BitBadger\PDODocument\{Definition, DocumentException, DocumentIndex}; pest()->group('integration', 'sqlite'); describe('::ensureTable()', function () { test('creates table and PK index', 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('throws an exception', function () { expect(fn () => Definition::ensureDocumentIndex('', DocumentIndex::Full))->toThrow(DocumentException::class); }); });