at the end of the day, it was inevitable

This commit is contained in:
Mo Elzubeir
2022-12-09 08:36:26 -06:00
commit 1218570914
1768 changed files with 887087 additions and 0 deletions
@@ -0,0 +1,88 @@
<?php
namespace UserBundle\Manager\Notification;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Tests\AppTestCaseTrait;
use UserBundle\Entity\Notification\Notification;
use UserBundle\Entity\Notification\NotificationTheme;
use UserBundle\Entity\Notification\NotificationThemeOptions;
use UserBundle\Enum\ThemeTypeEnum;
use UserBundle\Manager\Notification\Model\FeedData;
/**
* Class AbstractSendableNotificationTest
*
* @package UserBundle\Manager\Notification
*/
abstract class AbstractSendableNotificationTest extends KernelTestCase
{
use AppTestCaseTrait;
const PATTERN_TPL = '/%s[^\{]*?\{[^\}]*%s[^\}]*\}/i';
/**
* @var EngineInterface
*/
private static $templating;
/**
* @beforeClass
*
* @return void
*/
public static function getServices()
{
self::bootKernel();
self::$templating = self::$kernel->getContainer()->get('templating');
}
/**
* @param ThemeTypeEnum $themeType A ThemeTypeEnum instance.
* @param array $diffs Notification theme diffs.
* @param FeedData[] $data Array of feed data.
*
* @return string
*/
protected function render(ThemeTypeEnum $themeType, array $diffs = [], array $data = [])
{
$notification = Notification::create()
->setTheme(
NotificationTheme::create()
->setEnhanced(NotificationThemeOptions::createDefault())
->setPlain(NotificationThemeOptions::createDefault())
)
->setThemeType($themeType);
switch ($themeType->getValue()) {
case ThemeTypeEnum::ENHANCED:
$notification->setEnhancedThemeOptionsDiff($diffs);
break;
case ThemeTypeEnum::PLAIN:
$notification->setPlainThemeOptionsDiff($diffs);
break;
default:
throw new \DomainException('Unhandled theme type: '. $themeType->getValue());
}
$sendableNotification = new SendableNotification(
new SendableNotificationConfig(
0,
0,
0,
0,
'<p>empty</p>',
0
),
$notification,
$data
);
return $sendableNotification->render(self::$templating);
}
}