You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]
classUser
{
#[Column]
#[Id]
publicstring$id;
}
#[Entity]
classMembership
{
#[Column]
publicstring$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 mocktrine
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: