diff --git a/tests/Doctrine/Tests/Models/ReadonlyProperties/SimpleBook.php b/tests/Doctrine/Tests/Models/ReadonlyProperties/SimpleBook.php index 87e966682af..b31386c420c 100644 --- a/tests/Doctrine/Tests/Models/ReadonlyProperties/SimpleBook.php +++ b/tests/Doctrine/Tests/Models/ReadonlyProperties/SimpleBook.php @@ -19,7 +19,7 @@ class SimpleBook private readonly int $id; #[Column] - private readonly string $title; + public readonly string $title; #[ManyToOne, JoinColumn(nullable: false)] private readonly Author $author; diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php index 17aa2306df6..1139ae2342b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php @@ -108,4 +108,22 @@ public function testEntityWithManyToMany(): void self::assertEquals($bookId, $book->getId()); self::assertSame('Jane Austen', $book->getAuthors()[0]->getName()); } + + public function testEntityProxy(): void + { + $connection = $this->_em->getConnection(); + + $connection->insert('author', ['name' => 'Jane Austen']); + $authorId = $connection->lastInsertId(); + + $connection->insert('simple_book', ['title' => 'Pride and Prejudice', 'author_id' => $authorId]); + $bookId = $connection->lastInsertId(); + + $proxyBook = $this->_em->getReference(SimpleBook::class, $bookId); + + self::assertSame('Pride and Prejudice', $proxyBook->title); + self::assertEquals($bookId, $proxyBook->getId()); + self::assertSame('Jane Austen', $proxyBook->getAuthor()->getName()); + } + }