v2 RC1 Changes (#7)

- Changes `items` and `hasItems` on `DocumentList` to be properties
- Updates dependent option/result library, which contains similar changes

Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2024-10-02 01:37:08 +00:00
parent df436c9ef4
commit 486028bd40
22 changed files with 266 additions and 247 deletions

View File

@@ -39,8 +39,8 @@ class RemoveFieldsTest extends TestCase
{
RemoveFields::byId(ThrowawayDb::TABLE, 'two', ['sub', 'value']);
$tryDoc = Find::byId(ThrowawayDb::TABLE, 'two', TestDocument::class);
$this->assertTrue($tryDoc->isSome(), 'There should have been a document returned');
$doc = $tryDoc->get();
$this->assertTrue($tryDoc->isSome, 'There should have been a document returned');
$doc = $tryDoc->value;
$this->assertEquals('', $doc->value, 'Value should have been blank (its default value)');
$this->assertNull($doc->sub, 'Sub-document should have been null');
}
@@ -64,8 +64,8 @@ class RemoveFieldsTest extends TestCase
{
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');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertNull($doc->value->sub, 'Sub-document should have been null');
}
#[TestDox('byFields() succeeds when a field is not removed')]
@@ -89,8 +89,8 @@ class RemoveFieldsTest extends TestCase
RemoveFields::byContains(ThrowawayDb::TABLE, $criteria, ['value']);
$docs = Find::byContains(ThrowawayDb::TABLE, $criteria, TestDocument::class);
$this->assertNotNull($docs, 'There should have been a document list returned');
$this->assertTrue($docs->hasItems(), 'The document list should not have been empty');
foreach ($docs->items() as $item) {
$this->assertTrue($docs->hasItems, 'The document list should not have been empty');
foreach ($docs->items as $item) {
$this->assertContains($item->id, ['two', 'four'], 'An incorrect document was returned');
$this->assertEquals('', $item->value, 'The value field was not removed');
}
@@ -117,8 +117,8 @@ class RemoveFieldsTest extends TestCase
RemoveFields::byJsonPath(ThrowawayDb::TABLE, $path, ['sub']);
$docs = Find::byJsonPath(ThrowawayDb::TABLE, $path, TestDocument::class);
$this->assertNotNull($docs, 'There should have been a document list returned');
$this->assertTrue($docs->hasItems(), 'The document list should not have been empty');
foreach ($docs->items() as $item) {
$this->assertTrue($docs->hasItems, 'The document list should not have been empty');
foreach ($docs->items as $item) {
$this->assertContains($item->id, ['four', 'five'], 'An incorrect document was returned');
$this->assertNull($item->sub, 'The sub field was not removed');
}