Use Option for single doc queries
This commit is contained in:
@@ -32,8 +32,9 @@ class RemoveFieldsTest extends TestCase
|
||||
public function testByIdSucceedsWhenFieldsAreRemoved(): void
|
||||
{
|
||||
RemoveFields::byId(ThrowawayDb::TABLE, 'two', ['sub', 'value']);
|
||||
$doc = Find::byId(ThrowawayDb::TABLE, 'two', TestDocument::class);
|
||||
$this->assertNotFalse($doc, 'There should have been a document returned');
|
||||
$tryDoc = Find::byId(ThrowawayDb::TABLE, 'two', TestDocument::class);
|
||||
$this->assertNotFalse($tryDoc->isDefined(), 'There should have been a document returned');
|
||||
$doc = $tryDoc->get();
|
||||
$this->assertEquals('', $doc->value, 'Value should have been blank (its default value)');
|
||||
$this->assertNull($doc->sub, 'Sub-document should have been null');
|
||||
}
|
||||
@@ -56,8 +57,8 @@ class RemoveFieldsTest extends TestCase
|
||||
{
|
||||
RemoveFields::byFields(ThrowawayDb::TABLE, [Field::EQ('num_value', 17)], ['sub']);
|
||||
$doc = Find::firstByFields(ThrowawayDb::TABLE, [Field::EQ('num_value', 17)], TestDocument::class);
|
||||
$this->assertNotFalse($doc, 'There should have been a document returned');
|
||||
$this->assertNull($doc->sub, 'Sub-document should have been null');
|
||||
$this->assertTrue($doc->isDefined(), 'There should have been a document returned');
|
||||
$this->assertNull($doc->get()->sub, 'Sub-document should have been null');
|
||||
}
|
||||
|
||||
public function testByFieldsSucceedsWhenAFieldIsNotRemoved(): void
|
||||
|
||||
Reference in New Issue
Block a user