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]]; } } }