Merge branch 'fix-testContextGenerationDataNormalizeDenormalizeGetData' into 'master'

Fix the test "testContextGenerationDataNormalizeDenormalizeGetData"

See merge request Chill-Projet/chill-bundles!648
This commit is contained in:
Julien Fastré 2024-01-23 12:31:37 +00:00
commit 4fdc7fd210
2 changed files with 10 additions and 2 deletions

View File

@ -34,6 +34,8 @@ variables:
DEFAULT_CARRIER_CODE: BE DEFAULT_CARRIER_CODE: BE
# force a timezone # force a timezone
TZ: Europe/Brussels TZ: Europe/Brussels
# avoid direct deprecations (using symfony phpunit bridge: https://symfony.com/doc/4.x/components/phpunit_bridge.html#internal-deprecations
SYMFONY_DEPRECATIONS_HELPER: max[total]=99999999&max[self]=0&max[direct]=0&verbose=0
stages: stages:
- Composer install - Composer install

View File

@ -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;
} }