-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
If an entity has a property referencing the id of another entity (but isn't defined as a relation; e.g. a Column rather than ManyToOne), and you pass that entity to a find*By* method, Doctrine appears to detect the entity and automatically use its primary key in the actual query. Mocktrine does not have this same behavior, resulting in either misleading test results or forcing specific repository interactions.
Instead, Mocktrine should aim to detect that the query parameter is an entity and use its id to perform lookups.
// Most details elided
#[Entity]
class User
{
#[Column]
#[Id]
public string $id;
}
#[Entity]
class Membership
{
#[Column]
public string $userId;
}
// These should produce the same results in Mocktrine, and do in Doctrine
$repo = $this->em->getRepository(Membership::class);
$byId = $repo->findOneBy(['userId' => $user->id]);
$byEntity = $repo->findOneBy(['userId' => $user]);
assert($byId === $byEntity); // fails only under mocktrineReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels