mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix testContextGenerationDataNormalizeDenormalizeGetData
The method `Relationship::getOpposite` does not only compare the object equality, but also the object id.
This commit is contained in:
parent
0a2805f23f
commit
7a12602699
@ -147,10 +147,16 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
public function getOpposite(Person $counterpart): Person
|
public function getOpposite(Person $counterpart): Person
|
||||||
{
|
{
|
||||||
if ($this->fromPerson !== $counterpart && $this->toPerson !== $counterpart) {
|
if ($this->fromPerson !== $counterpart && $this->toPerson !== $counterpart) {
|
||||||
throw new \RuntimeException('the counterpart is neither the from nor to person for this relationship');
|
// during tests, comparing using equality does not work. We have to compare the ids
|
||||||
|
if (
|
||||||
|
($this->fromPerson->getId() === $counterpart->getId() && $this->toPerson->getId() === $counterpart->getId())
|
||||||
|
|| null === $counterpart->getId()
|
||||||
|
) {
|
||||||
|
throw new \RuntimeException(sprintf('the counterpart is neither the from nor to person for this relationship, expecting counterpart from %d and available %d and %d', $counterpart->getId(), $this->getFromPerson()->getId(), $this->getToPerson()->getId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->fromPerson === $counterpart) {
|
if ($this->fromPerson === $counterpart || $this->fromPerson->getId() === $counterpart->getId()) {
|
||||||
return $this->toPerson;
|
return $this->toPerson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user