Resolve "Fusion actions d'accompagnement"

This commit is contained in:
2025-07-02 10:53:16 +00:00
committed by Julien Fastré
parent b4bbb1a456
commit 840ef6eed8
30 changed files with 1367 additions and 32 deletions

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/*
* 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\MainBundle\Tests\Entity\Workflow;
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
use Chill\MainBundle\Entity\User;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
/**
* @internal
*
* @coversNothing
*/
class PrivateCommentEmbeddableTest extends TestCase
{
use ProphecyTrait;
public function testConcatenateComment(): void
{
$userA = $this->prophesize(User::class);
$userA->getId()->willReturn(1);
$userB = $this->prophesize(User::class);
$userB->getId()->willReturn(2);
$userC = $this->prophesize(User::class);
$userC->getId()->willReturn(3);
$toKeep = new PrivateCommentEmbeddable();
$toKeep->setCommentForUser($userA->reveal(), 'My comment for A');
$toKeep->setCommentForUser($userB->reveal(), 'My comment for B');
$toDelete = new PrivateCommentEmbeddable();
$toDelete->setCommentForUser($userC->reveal(), 'My comment for C');
$toDelete->setCommentForUser($userB->reveal(), 'Another comment for B');
$toKeep->concatenateComments($toDelete, '----');
self::assertTrue($toKeep->hasCommentForUser($userA->reveal()));
self::assertEquals('My comment for A', $toKeep->getCommentForUser($userA->reveal()));
self::assertTrue($toKeep->hasCommentForUser($userB->reveal()));
self::assertEquals('My comment for B----Another comment for B', $toKeep->getCommentForUser($userB->reveal()));
self::assertTrue($toKeep->hasCommentForUser($userC->reveal()));
self::assertEquals('My comment for C', $toKeep->getCommentForUser($userC->reveal()));
}
}