* @license MIT */ declare(strict_types=1); use BitBadger\PDODocument\{Count, DocumentException, Field}; use Test\Integration\SQLite\ThrowawayDb; pest()->group('integration', 'sqlite'); describe('::all()', function () { test('counts all documents', function () { expect(Count::all(ThrowawayDb::TABLE))->toBe(5); }); }); describe('::byFields()', function () { test('counts by numeric range', function () { expect(Count::byFields(ThrowawayDb::TABLE, [Field::between('num_value', 10, 20)]))->toBe(3); }); test('counts by non-numeric range', function () { expect(Count::byFields(ThrowawayDb::TABLE, [Field::between('value', 'aardvark', 'apple')]))->toBe(1); }); }); describe('::byContains()', function () { test('throws an exception', function () { expect(fn () => Count::byContains('', []))->toThrow(DocumentException::class); }); }); describe('::byJsonPath()', function () { test('throws an exception', function () { expect(fn () => Count::byJsonPath('', ''))->toThrow(DocumentException::class); }); });