Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}