mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-25 16:14:59 +00:00
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?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\SavedExport;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\MainBundle\Entity\UserGroup;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @coversNothing
|
|
*/
|
|
class SavedExportTest extends TestCase
|
|
{
|
|
public function testIsSharedWithUser(): void
|
|
{
|
|
// Create test users
|
|
$user1 = new User();
|
|
$user2 = new User();
|
|
$user3 = new User();
|
|
|
|
// Create a test group and add user2 to the group
|
|
$group = new UserGroup();
|
|
$group->addUser($user2);
|
|
|
|
// Create a SavedExport entity
|
|
$savedExport = new SavedExport();
|
|
|
|
// Share the saved export with user1
|
|
$savedExport->addShare($user1);
|
|
|
|
// Share the saved export with the group
|
|
$savedExport->addShare($group);
|
|
|
|
// Assertions
|
|
$this->assertTrue($savedExport->isSharedWithUser($user1), 'User1 should have access to the saved export.');
|
|
$this->assertTrue($savedExport->isSharedWithUser($user2), 'User2 (via group) should have access to the saved export.');
|
|
$this->assertFalse($savedExport->isSharedWithUser($user3), 'User3 should not have access to the saved export.');
|
|
|
|
}
|
|
}
|