/** * @param $oldBody * @param $newBody * @dataProvider testExecuteDataProvider */ public function testExecute($oldBody, $newBody) { $template = new EmailTemplate(); $template->setBody($oldBody); $template->setTags(['allowed tag']); $command = new NotAllowedTagsRemover(); $command->execute($template); $this->assertEquals($template->getBody(), $newBody); }
public function testProcessTemplate() { $body = <<<'EOL' Welcome to Street Team, {{firstname}}! {% block default %} emphasized block {% endblock default %} block normal {% block default %} another emphasized block {% endblock default %} {{request_tickets_button}} {{application_name}} EOL; $expected = <<<'EOL' {% embed '::email_base.html.twig' %} {% block style %}{% endblock style %} {% block header %}{% endblock header %} {% block content %}Welcome to Street Team, {{firstname}}!<br /> {% embed "::EmailBlocks/default.html.twig" %}{% block default %}<br /> emphasized block<br /> {% endblock default %}{% endembed %}<br /> <br /> block normal<br /> <br /> {% embed "::EmailBlocks/default.html.twig" %}{% block default %}<br /> another emphasized block<br /> {% endblock default %}{% endembed %}<br /> <br /> {{request_tickets_button}}<br /> <br /> {{application_name}}{% endblock content %} {% block footer %}{% endblock footer %} {% endembed %} EOL; $template = new EmailTemplate(); $template->setBody($body); $template->setTags(['request_tickets_button', 'firstname', 'application_name']); $template->setBlocks(['default']); $enricher = $this->getEnricher(); $enricher->processTemplate($template); $this->assertEquals($expected, $template->getBody()); }