Fix rendering shortcodes in subject

[MAILPOET-3333]
This commit is contained in:
Pavel Dohnal
2020-12-02 15:41:53 +01:00
committed by Veljko V
parent 3af2ffbbb4
commit 56d7cd1398
4 changed files with 22 additions and 8 deletions

View File

@@ -160,14 +160,19 @@ class ShortcodesTest extends \MailPoetTest {
}
public function testSubscriberShortcodesRequireSubscriberObjectOrFalseValue() {
// when subscriber is empty, default value is returned
// when subscriber is empty, original value is returned
$this->shortcodesObject->setSubscriber(null);
$result = $this->shortcodesObject->process(['[subscriber:firstname | default:test]']);
expect($result[0])->equals('test');
expect($result[0])->equals('[subscriber:firstname | default:test]');
// when subscriber is an object, proper value is returned
$this->shortcodesObject->setSubscriber($this->subscriber);
$result = $this->shortcodesObject->process(['[subscriber:firstname | default:test]']);
expect($result[0])->equals($this->subscriber->getFirstName());
// when subscriber hasn't name, the default value is returned
$this->subscriber->setFirstName('');
$this->shortcodesObject->setSubscriber($this->subscriber);
$result = $this->shortcodesObject->process(['[subscriber:firstname | default:test]']);
expect($result[0])->equals('test');
}
public function testSubscriberFirstAndLastNameShortcodesReturnDefaultValueWhenDataIsEmpty() {