cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,5 +1,12 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Tests\AccompanyingPeriod\SocialIssueConsistency;
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
@@ -11,8 +18,33 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Event\LifecycleEventArgs;
use PHPUnit\Framework\TestCase;
/**
* @internal
* @coversNothing
*/
class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends TestCase
{
public function testPrePersist()
{
$socialIssues = new ArrayCollection([
$parent = new SocialIssue(),
$child = (new SocialIssue())->setParent($parent),
$grandChild = (new SocialIssue())->setParent($child),
$grandGrandChild = (new SocialIssue())->setParent($grandChild),
]);
$period = (new AccompanyingPeriod())->addSocialIssue($unrelated = new SocialIssue());
$entity = $this->generateClass($period, $socialIssues);
$consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener();
$consistency->prePersist($entity, $this->generateLifecycleArgs());
$this->assertCount(2, $period->getSocialIssues());
$this->assertContains($grandGrandChild, $period->getSocialIssues());
$this->assertContains($unrelated, $period->getSocialIssues());
$this->assertCount(1, $entity->getSocialIssues());
$this->assertContains($grandGrandChild, $entity->getSocialIssues());
}
public function testPrePersistAccompanyingPeriod()
{
@@ -57,29 +89,6 @@ class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends TestCas
$this->assertContains($grandGrandChild, $entity->getSocialIssues());
}
public function testPrePersist()
{
$socialIssues = new ArrayCollection([
$parent = new SocialIssue(),
$child = (new SocialIssue())->setParent($parent),
$grandChild = (new SocialIssue())->setParent($child),
$grandGrandChild = (new SocialIssue())->setParent($grandChild),
]);
$period = (new AccompanyingPeriod())->addSocialIssue($unrelated = new SocialIssue());
$entity = $this->generateClass($period, $socialIssues);
$consistency = new AccompanyingPeriodSocialIssueConsistencyEntityListener();
$consistency->prePersist($entity, $this->generateLifecycleArgs());
$this->assertCount(2, $period->getSocialIssues());
$this->assertContains($grandGrandChild, $period->getSocialIssues());
$this->assertContains($unrelated, $period->getSocialIssues());
$this->assertCount(1, $entity->getSocialIssues());
$this->assertContains($grandGrandChild, $entity->getSocialIssues());
}
public function testPreUpdateAccompanyingPeriod()
{
$arraySocialIssues = [
@@ -101,40 +110,40 @@ class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends TestCas
$this->assertSame($grandGrandChild, $period->getSocialIssues()->first());
}
protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
return new class($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface {
public Collection $socialIssues;
public AccompanyingPeriod $period;
public function __construct($period, $socialIssues)
{
$this->period = $period;
$this->socialIssues = $socialIssues;
}
public function getAccompanyingPeriod(): AccompanyingPeriod
{
return $this->period;
}
public function getSocialIssues(): Collection
{
return $this->socialIssues;
}
public function removeSocialIssue(SocialIssue $issue): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
$this->socialIssues->removeElement($issue);
return $this;
}
};
}
protected function generateLifecycleArgs(): LifecycleEventArgs
{
return $this->createMock(LifecycleEventArgs::class);
}
protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
return new class($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
public Collection $socialIssues;
public AccompanyingPeriod $period;
public function __construct($period, $socialIssues)
{
$this->period = $period;
$this->socialIssues = $socialIssues;
}
public function getAccompanyingPeriod(): AccompanyingPeriod
{
return $this->period;
}
public function getSocialIssues(): Collection
{
return $this->socialIssues;
}
public function removeSocialIssue(SocialIssue $issue): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
$this->socialIssues->removeElement($issue);
return $this;
}
};
}
}