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

@@ -47,7 +47,7 @@ class DocumentMapperTest extends TestCase
#[TestDox('map() succeeds with valid JSON')]
public function testMapSucceedsWithValidJSON(): void
{
$doc = (new DocumentMapper(TestDocument::class))->map(['data' => '{"id":7,"subDoc":{"id":22,"name":"tester"}}']);
$doc = new DocumentMapper(TestDocument::class)->map(['data' => '{"id":7,"subDoc":{"id":22,"name":"tester"}}']);
$this->assertNotNull($doc, 'The document should not have been null');
$this->assertEquals(7, $doc->id, 'ID not filled correctly');
$this->assertNotNull($doc->subDoc, 'The sub-document should not have been null');
@@ -58,7 +58,7 @@ class DocumentMapperTest extends TestCase
#[TestDox('map() succeeds with valid JSON for Pjson class')]
public function testMapSucceedsWithValidJSONForPjsonClass(): void
{
$doc = (new DocumentMapper(PjsonDocument::class))->map(['data' => '{"id":"seven","name":"bob","num_value":8}']);
$doc = new DocumentMapper(PjsonDocument::class)->map(['data' => '{"id":"seven","name":"bob","num_value":8}']);
$this->assertNotNull($doc, 'The document should not have been null');
$this->assertEquals(new PjsonId('seven'), $doc->id, 'ID not filled correctly');
$this->assertEquals('bob', $doc->name, 'Name not filled correctly');
@@ -70,13 +70,13 @@ class DocumentMapperTest extends TestCase
public function testMapFailsWithInvalidJSON(): void
{
$this->expectException(DocumentException::class);
(new DocumentMapper(TestDocument::class))->map(['data' => 'this is not valid']);
new DocumentMapper(TestDocument::class)->map(['data' => 'this is not valid']);
}
#[TestDox('map() fails with invalid JSON for Pjson class')]
public function testMapFailsWithInvalidJSONForPjsonClass(): void
{
$this->expectException(DocumentException::class);
(new DocumentMapper(PjsonDocument::class))->map(['data' => 'not even close']);
new DocumentMapper(PjsonDocument::class)->map(['data' => 'not even close']);
}
}