From 7a126026990cbe080a7f429164ac636bc217459d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 23 Jan 2024 10:51:48 +0100 Subject: [PATCH 1/2] fix testContextGenerationDataNormalizeDenormalizeGetData The method `Relationship::getOpposite` does not only compare the object equality, but also the object id. --- .../Entity/Relationships/Relationship.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php index f736913ae..ce56fa013 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php +++ b/src/Bundle/ChillPersonBundle/Entity/Relationships/Relationship.php @@ -147,10 +147,16 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface public function getOpposite(Person $counterpart): Person { 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; } From 0bf6c07e8d3dfa7f9cae9ecd2a14da2e29ec48a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 23 Jan 2024 11:32:22 +0100 Subject: [PATCH 2/2] Add Symfony Deprecations Helper to Gitlab CI configuration The Gitlab CI configuration for the Chill Project has been updated to include the Symfony Deprecations Helper setting. This addition helps to avoid direct deprecations and provide a more efficient testing process. The helper is integrated using Symfony's PHPUnit bridge. --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e976a4d18..945d13532 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,8 @@ variables: DEFAULT_CARRIER_CODE: BE # force a timezone 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: - Composer install