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:
@@ -62,8 +62,9 @@ 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');
|
||||
$this->assertTrue($list->hasItems, 'There should have been documents in the list');
|
||||
$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');
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ class CustomTest extends TestCase
|
||||
$list = Custom::list(Query::selectFromTable(ThrowawayDb::TABLE) . " WHERE data->>'num_value' > :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')]
|
||||
@@ -99,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')]
|
||||
@@ -108,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')]
|
||||
|
||||
Reference in New Issue
Block a user