mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
Resolve "Fusion actions d'accompagnement"
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user