Migrate tests to Pest
This commit is contained in:
50
tests/Integration/SQLite/DeleteTest.php
Normal file
50
tests/Integration/SQLite/DeleteTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use BitBadger\PDODocument\{Count, Delete, DocumentException, Field};
|
||||
use Test\Integration\SQLite\ThrowawayDb;
|
||||
|
||||
pest()->group('integration', 'sqlite');
|
||||
|
||||
describe('::byId()', function () {
|
||||
test('deletes a document when one exists', function () {
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(5);
|
||||
Delete::byId(ThrowawayDb::TABLE, 'four');
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(4);
|
||||
});
|
||||
test('does nothing when the document does not exist', function () {
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(5);
|
||||
Delete::byId(ThrowawayDb::TABLE, 'negative four');
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::byFields()', function () {
|
||||
test('deletes matching documents', function () {
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(5);
|
||||
Delete::byFields(ThrowawayDb::TABLE, [Field::notEqual('value', 'purple')]);
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(2);
|
||||
});
|
||||
test('does nothing when no documents match', function () {
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(5);
|
||||
Delete::byFields(ThrowawayDb::TABLE, [Field::equal('value', 'crimson')]);
|
||||
expect(Count::all(ThrowawayDb::TABLE))->toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::byContains()', function () {
|
||||
test('throws an exception', function () {
|
||||
expect(fn () => Delete::byContains('', []))->toThrow(DocumentException::class);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::byJsonPath()', function () {
|
||||
test('throws an exception', function () {
|
||||
expect(fn () => Delete::byJsonPath('', ''))->toThrow(DocumentException::class);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user