Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When changing the text of a message template via the text is missing #174

Open
RoySegall opened this issue Mar 21, 2017 · 2 comments
Open
Labels

Comments

@RoySegall
Copy link

During DDD 2017 I started to work on the tests of Message UI. I found when settigng the text of the message template entity the text is being removed:

    $messageTemplate = MessageTemplate::create(['text' => ['bar'], 'template' => 'bar']);
    $messageTemplate->save();

    $template = MessageTemplate::load('bar');
    dpm($template->getText());
    $template->set('text', ['b']);
    $template->save();
    dpm($template->getText());

Will output for the first text printing:

Array
(
[0] => stdClass Object
(
[CLASS] => Drupal\Core\Render\Markup
[string] => asdasd
)
)

But after saving:

Array
(
)

@RoySegall
Copy link
Author

I'm looking on the tests and it seems that the proper way to set the text is:

    $this->messageTemplate->set('text', [
      [
        'value' => 'foo [fake:token] and [message:author:name]',
        'format' => filter_default_format(),
      ],
    ]);

Rather than

$template->set('text', ['b']);

@amitaibu @jhedstrom If that the case - shouldn't we have an API function to do that for us?

@jhedstrom
Copy link
Collaborator

We have a test helper method in MessageTemplateCreateTrait::createMessageTemplate that makes it easier to set text without a format. I suppose we could add an api method that calls out to filter_default_format if no format is passed in...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants