Add BC for importing older exported templates

We allow exporting templates as JSON and templates exported from the older plugin versions use thumbnail key for storing the image data.
[MAILPOET-2686]
This commit is contained in:
Rostislav Wolny
2021-10-20 13:41:00 +02:00
committed by Veljko V
parent 5134713c2d
commit dd0a19a314
2 changed files with 17 additions and 1 deletions

View File

@@ -54,6 +54,17 @@ class NewsletterTemplatesRepositoryTest extends \MailPoetTest {
expect($templates[0]->getName())->equals('Testing template 5');
}
public function testItCanCreateFromOldDataFormat() {
$createdTemplate = $this->newsletterTemplatesRepository->createOrUpdate([
'name' => 'Another template',
'body' => '{"content": {}, "globalStyles": {}}',
'thumbnail' => 'data:image/gif;base64,R0lGODlhAQABAAAAACw=',
]);
expect($createdTemplate->getName())->equals('Another template');
expect($createdTemplate->getBody())->equals(['content' => [], 'globalStyles' => []]);
expect($createdTemplate->getThumbnailData())->equals('data:image/gif;base64,R0lGODlhAQABAAAAACw=');
}
public function _after() {
$this->truncateEntity(NewsletterTemplateEntity::class);
}