Skip to content

Commit 3b77cb9

Browse files
committed
Support immutable entities, readonly stubs, persist return type
- Change persist() return type from bool to object (matches Data) - Add readonly entity test stubs (ReadOnlyAuthor, ReadOnlyPost, ReadOnlyComment) - Add tests for immutable entity hydration, insert, update, delete - Add tests for inline persist changes, relation graphs, mixed graphs - Update FlatNum hydrator tests for lazy entity class resolution - Remove duplicate testShouldNotExecuteEntityConstructorWhenDisabled - Rename testMultipleFilteredCollectionsDontPersist to clarify intent - Add actual refetch assertion to testReadOnlyDeleteAndRefetch
1 parent 61bd2da commit 3b77cb9

6 files changed

Lines changed: 436 additions & 35 deletions

File tree

src/Mapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function fetchAll(Collection $collection, mixed $extra = null): array
6868
return $entities;
6969
}
7070

71-
public function persist(object $object, Collection $onCollection): bool
71+
public function persist(object $object, Collection $onCollection): object
7272
{
7373
if ($onCollection instanceof Filtered) {
7474
return parent::persist($object, $onCollection);

tests/Hydrators/FlatNumTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public function hydrateSingleEntityFromNumericRow(): void
3939
$row = $stmt->fetch(PDO::FETCH_NUM);
4040

4141
$hydrator = new FlatNum($stmt);
42-
$result = $hydrator->hydrate($row, Collection::author(), $this->factory);
42+
$collection = Collection::author();
43+
$result = $hydrator->hydrate($row, $collection, $this->factory);
4344

4445
$this->assertNotFalse($result);
4546
$this->assertCount(1, $result);
@@ -76,7 +77,8 @@ public function hydrateReturnsFalseForEmptyResult(): void
7677

7778
$hydrator = new FlatNum($stmt);
7879

79-
$this->assertFalse($hydrator->hydrate($row, Collection::author(), $this->factory));
80+
$collection = Collection::author();
81+
$this->assertFalse($hydrator->hydrate($row, $collection, $this->factory));
8082
}
8183

8284
#[Test]

0 commit comments

Comments
 (0)