Changes for beta10 (#5)

- Add In/InArray support
- Add ORDER BY support for `Find` functions
- Update dependencies
- Implement fixes identified via static analysis

Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
2024-09-27 02:15:00 +00:00
parent 9e0e663811
commit d067f8983f
66 changed files with 1728 additions and 664 deletions

View File

@@ -34,7 +34,7 @@ class RemoveFieldsTest extends TestCase
parent::tearDown();
}
#[TestDox('By ID succeeds when fields are removed')]
#[TestDox('byId() succeeds when fields are removed')]
public function testByIdSucceedsWhenFieldsAreRemoved(): void
{
RemoveFields::byId(ThrowawayDb::TABLE, 'two', ['sub', 'value']);
@@ -45,47 +45,51 @@ class RemoveFieldsTest extends TestCase
$this->assertNull($doc->sub, 'Sub-document should have been null');
}
#[TestDox('By ID succeeds when a field is not removed')]
#[TestDox('byId() succeeds when a field is not removed')]
public function testByIdSucceedsWhenAFieldIsNotRemoved(): void
{
RemoveFields::byId(ThrowawayDb::TABLE, 'one', ['a_field_that_does_not_exist']);
$this->assertTrue(true, 'The above not throwing an exception is the test');
}
#[TestDox('By ID succeeds when no document is matched')]
#[TestDox('byId() succeeds when no document is matched')]
public function testByIdSucceedsWhenNoDocumentIsMatched(): void
{
RemoveFields::byId(ThrowawayDb::TABLE, 'fifty', ['sub']);
$this->assertTrue(true, 'The above not throwing an exception is the test');
}
#[TestDox('byFields() succeeds when a field is removed')]
public function testByFieldsSucceedsWhenAFieldIsRemoved(): void
{
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::EQ('num_value', 17)], ['sub']);
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::EQ('num_value', 17)], TestDocument::class);
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::equal('num_value', 17)], ['sub']);
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::equal('num_value', 17)], TestDocument::class);
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertNull($doc->get()->sub, 'Sub-document should have been null');
}
#[TestDox('byFields() succeeds when a field is not removed')]
public function testByFieldsSucceedsWhenAFieldIsNotRemoved(): void
{
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::EQ('num_value', 17)], ['nada']);
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::equal('num_value', 17)], ['nada']);
$this->assertTrue(true, 'The above not throwing an exception is the test');
}
#[TestDox('byFields() succeeds when no document is matched')]
public function testByFieldsSucceedsWhenNoDocumentIsMatched(): void
{
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::NE('missing', 'nope')], ['value']);
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::notEqual('missing', 'nope')], ['value']);
$this->assertTrue(true, 'The above not throwing an exception is the test');
}
#[TestDox('byContains() fails')]
public function testByContainsFails(): void
{
$this->expectException(DocumentException::class);
RemoveFields::byContains('', [], []);
}
#[TestDox('By JSON Path fails')]
#[TestDox('byJsonPath() fails')]
public function testByJsonPathFails(): void
{
$this->expectException(DocumentException::class);