Migrate tests to Pest
This commit is contained in:
48
tests/Integration/PostgreSQL/ExistsTest.php
Normal file
48
tests/Integration/PostgreSQL/ExistsTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use BitBadger\PDODocument\{Exists, Field};
|
||||
use Test\Integration\PostgreSQL\ThrowawayDb;
|
||||
|
||||
pest()->group('integration', 'postgresql');
|
||||
|
||||
describe('::byId()', function () {
|
||||
test('returns true when a document exists', function () {
|
||||
expect(Exists::byId(ThrowawayDb::TABLE, 'three'))->toBeTrue();
|
||||
});
|
||||
test('returns false when a document does not exist', function () {
|
||||
expect(Exists::byId(ThrowawayDb::TABLE, 'seven'))->toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('::byFields()', function () {
|
||||
test('returns true when matching documents exist', function () {
|
||||
expect(Exists::byFields(ThrowawayDb::TABLE, [Field::equal('num_value', 10)]))->toBeTrue();
|
||||
});
|
||||
test('returns false when no matching documents exist', function () {
|
||||
expect(Exists::byFields(ThrowawayDb::TABLE, [Field::less('nothing', 'none')]))->toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('::byContains()', function () {
|
||||
test('returns true when matching documents exist', function () {
|
||||
expect(Exists::byContains(ThrowawayDb::TABLE, ['value' => 'purple']))->toBeTrue();
|
||||
});
|
||||
test('returns false when no matching documents exist', function () {
|
||||
expect(Exists::byContains(ThrowawayDb::TABLE, ['value' => 'violet']))->toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('::byJsonPath()', function () {
|
||||
test('returns true when matching documents exist', function () {
|
||||
expect(Exists::byJsonPath(ThrowawayDb::TABLE, '$.num_value ? (@ == 10)'))->toBeTrue();
|
||||
});
|
||||
test('returns false when no matching documents exist', function () {
|
||||
expect(Exists::byJsonPath(ThrowawayDb::TABLE, '$.num_value ? (@ == 10.1)'))->toBeFalse();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user