From 531e05fc3abd8cb8b5f7a5b1e76a6854988a31e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 17 Oct 2022 17:54:50 +0200 Subject: [PATCH] DX: fix tests to find ancestor to all SocialAction and SocialIssue --- .../Entity/SocialWork/SocialAction.php | 2 ++ .../Entity/SocialWork/SocialIssue.php | 12 +++++++++--- .../Tests/Entity/SocialWork/SocialActionTest.php | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index ea5df8fe0..bb393a3b5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -389,6 +389,8 @@ class SocialAction { $this->parent = $parent; + $parent->addChild($this); + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index d36642977..8708e34f3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -71,11 +71,15 @@ class SocialIssue $this->socialActions = new ArrayCollection(); } + /** + * @internal use @see{SocialIssue::setParent} instead + * @param SocialIssue $child + * @return $this + */ public function addChild(self $child): self { if (!$this->children->contains($child)) { $this->children[] = $child; - $child->setParent($this); } return $this; @@ -216,10 +220,10 @@ class SocialIssue } /** - * @param Collection|SocialIssue[] $socialIssues + * @param array|SocialIssue[] $socialIssues * @return Collection */ - public static function getDescendantsWithThisForIssues(Collection $socialIssues): Collection + public static function getDescendantsWithThisForIssues(array $socialIssues): Collection { $unique = []; @@ -351,6 +355,8 @@ class SocialIssue { $this->parent = $parent; + $parent->addChild($this); + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php index 2e0b64d6d..804ea2b1b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php @@ -50,4 +50,4 @@ final class SocialActionTest extends TestCase $this->assertNotContains($unrelatedB, $actual); } -} \ No newline at end of file +}