mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-31 20:13:49 +00:00
fix social action consistency
This commit is contained in:
@@ -12,12 +12,17 @@ declare(strict_types=1);
|
||||
namespace Chill\ActivityBundle\Tests\Entity;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
|
||||
final class ActivityTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testHierarchySocialActions(): void
|
||||
{
|
||||
@@ -59,6 +64,9 @@ final class ActivityTest extends TestCase
|
||||
|
||||
public function testHierarchySocialIssues(): void
|
||||
{
|
||||
$listener = new AccompanyingPeriodSocialIssueConsistencyEntityListener();
|
||||
$event = $this->prophesize(LifecycleEventArgs::class)->reveal();
|
||||
|
||||
$parent = new SocialIssue();
|
||||
$child = new SocialIssue();
|
||||
|
||||
@@ -67,19 +75,23 @@ final class ActivityTest extends TestCase
|
||||
$child->addChild($grandChild);
|
||||
|
||||
$activity = new Activity();
|
||||
$activity->setAccompanyingPeriod(new AccompanyingPeriod());
|
||||
|
||||
$activity->addSocialIssue($parent);
|
||||
$listener->preUpdate($activity, $event);
|
||||
|
||||
$this->assertCount(1, $activity->getSocialIssues());
|
||||
$this->assertContains($parent, $activity->getSocialIssues());
|
||||
|
||||
$activity->addSocialIssue($grandChild);
|
||||
$listener->preUpdate($activity, $event);
|
||||
|
||||
$this->assertCount(1, $activity->getSocialIssues());
|
||||
$this->assertContains($grandChild, $activity->getSocialIssues());
|
||||
$this->assertNotContains($parent, $activity->getSocialIssues());
|
||||
|
||||
$activity->addSocialIssue($child);
|
||||
$listener->preUpdate($activity, $event);
|
||||
|
||||
$this->assertCount(1, $activity->getSocialIssues());
|
||||
$this->assertContains($grandChild, $activity->getSocialIssues());
|
||||
@@ -87,6 +99,7 @@ final class ActivityTest extends TestCase
|
||||
$this->assertNotContains($child, $activity->getSocialIssues());
|
||||
|
||||
$activity->addSocialIssue($another = new SocialIssue());
|
||||
$listener->preUpdate($activity, $event);
|
||||
|
||||
$this->assertCount(2, $activity->getSocialIssues());
|
||||
$this->assertContains($grandChild, $activity->getSocialIssues());
|
||||
@@ -95,4 +108,4 @@ final class ActivityTest extends TestCase
|
||||
$this->assertNotContains($child, $activity->getSocialIssues());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user