mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-19 20:28:06 +00:00
Resolve "Notification aux groupes utilisateurs"
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?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\Notification\Email;
|
||||
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserGroup;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class NotificationMailTwigContentTest extends KernelTestCase
|
||||
{
|
||||
private Environment $twig;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->twig = $this->getContainer()->get('twig');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideContent
|
||||
*/
|
||||
public function testContent(string $template, array $args): void
|
||||
{
|
||||
$actual = $this->twig->render($template, $args);
|
||||
|
||||
self::assertIsString($actual);
|
||||
}
|
||||
|
||||
public static function provideContent(): iterable
|
||||
{
|
||||
$notification = new Notification();
|
||||
$notification->setMessage('test message');
|
||||
$notification->setSender(new User());
|
||||
|
||||
$class = new \ReflectionClass($notification);
|
||||
$method = $class->getProperty('id');
|
||||
$method->setValue($notification, 1);
|
||||
|
||||
$txt = '@ChillMain/Notification/email_non_system_notification_content.txt.twig';
|
||||
$md = '@ChillMain/Notification/email_non_system_notification_content.md.twig';
|
||||
|
||||
$user = new User();
|
||||
$user->setLocale('fr');
|
||||
$user->setLabel('test');
|
||||
|
||||
$userGroup = new UserGroup();
|
||||
$userGroup->setLabel(['fr' => 'test user group']);
|
||||
|
||||
foreach ([$md, $txt] as $template) {
|
||||
yield 'test with a user for '.$template => [$template, ['notification' => $notification, 'dest' => $user]];
|
||||
yield 'test with a group for '.$template => [$template, ['notification' => $notification, 'dest' => $userGroup]];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user