pdo-document/tests/Integration/SQLite/DefinitionTest.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2024-11-17 21:30:53 +00:00
<?php
/**
* @author Daniel J. Summers <daniel@bitbadger.solutions>
* @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);
});
});