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

@@ -63,7 +63,7 @@ class CustomTest extends TestCase
$list = Custom::list(Query::selectFromTable(ThrowawayDb::TABLE), [], new DocumentMapper(TestDocument::class));
$this->assertNotNull($list, 'The document list should not be null');
$count = 0;
foreach ($list->items() as $ignored) $count++;
foreach ($list->items as $ignored) $count++;
$this->assertEquals(5, $count, 'There should have been 5 documents in the list');
}
@@ -74,7 +74,7 @@ class CustomTest extends TestCase
Query::selectFromTable(ThrowawayDb::TABLE) . " WHERE (data->>'num_value')::numeric > :value",
[':value' => 100], new DocumentMapper(TestDocument::class));
$this->assertNotNull($list, 'The document list should not be null');
$this->assertFalse($list->hasItems(), 'There should have been no documents in the list');
$this->assertFalse($list->hasItems, 'There should have been no documents in the list');
}
#[TestDox('array() succeeds when data is found')]
@@ -100,8 +100,8 @@ class CustomTest extends TestCase
{
$doc = Custom::single('SELECT data FROM ' . ThrowawayDb::TABLE . " WHERE data->>'id' = :id", [':id' => 'one'],
new DocumentMapper(TestDocument::class));
$this->assertTrue($doc->isSome(), 'There should have been a document returned');
$this->assertEquals('one', $doc->get()->id, 'The incorrect document was returned');
$this->assertTrue($doc->isSome, 'There should have been a document returned');
$this->assertEquals('one', $doc->value->id, 'The incorrect document was returned');
}
#[TestDox('single() succeeds when a row is not found')]
@@ -109,7 +109,7 @@ class CustomTest extends TestCase
{
$doc = Custom::single('SELECT data FROM ' . ThrowawayDb::TABLE . " WHERE data->>'id' = :id",
[':id' => 'eighty'], new DocumentMapper(TestDocument::class));
$this->assertTrue($doc->isNone(), 'There should not have been a document returned');
$this->assertTrue($doc->isNone, 'There should not have been a document returned');
}
#[TestDox('nonQuery() succeeds when operating on data')]