Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
WorkflowMergeTagsUtilTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
37  {
38  protected static $emailTemplate;
39 
40  protected static $super;
41 
42  protected static $compareContent;
43 
44  protected static $content;
45 
46  protected static $contact;
47 
48  protected $invalidTags;
49 
50  protected $mergeTagsUtil;
51 
52  protected static $userHash;
53 
54  protected static $emailTemplateUserHash;
55 
56  public static function setUpBeforeClass()
57  {
58  parent::setUpBeforeClass();
60  SecurityTestHelper::createSuperAdmin();
61  SecurityTestHelper::createUsers();
62  self::$super = User::getByUsername('super');
63  Yii::app()->user->userModel = self::$super;
64  $emailSignature = new EmailSignature();
65  $emailSignature->htmlContent = 'my email signature';
66  self::$super->emailSignatures->add($emailSignature);
67  self::$super->save();
68 
69  $currencies = Currency::getAll();
70  $currencyValue1 = new CurrencyValue();
71  $currencyValue1->value = 100;
72  $currencyValue1->currency = $currencies[0];
73 
74  $multiDropDownCustomFieldData1 = new CustomFieldData();
75  $multiDropDownCustomFieldData1->name = 'multiDropDown1';
76  $multiDropDownCustomFieldData1->serializedData = serialize(array('Ten', 11, 'XII'));
77  $saved = $multiDropDownCustomFieldData1->save();
78  assert('$saved'); // Not Coding Standard
79 
80  $multiDropDownCustomFieldValue1 = new CustomFieldValue();
81  $multiDropDownCustomFieldValue1->value = 'Ten';
82  $multiDropDownCustomFieldValue2 = new CustomFieldValue();
83  $multiDropDownCustomFieldValue2->value = 11;
84  $multiDropDownCustomFieldValue3 = new CustomFieldValue();
85  $multiDropDownCustomFieldValue3->value = 'XII';
86 
87  $tagCustomFieldData1 = new CustomFieldData();
88  $tagCustomFieldData1->name = 'tagCloud1';
89  $tagCustomFieldData1->serializedData = serialize(array('Apache', 'PHP'));
90  $saved = $tagCustomFieldData1->save();
91  assert('$saved'); // Not Coding Standard
92 
93  $tagCustomFieldValue1 = new CustomFieldValue();
94  $tagCustomFieldValue1->value = 'PHP';
95  $tagCustomFieldValue2 = new CustomFieldValue();
96  $tagCustomFieldValue2->value = 'Apache';
97 
98  $primaryEmail1 = new Email();
99  $primaryEmail1->emailAddress = "info@zurmo.com";
100  $primaryEmail1->isInvalid = true;
101  $primaryEmail1->optOut = false;
102 
103  $secondaryEmail1 = new Email();
104  $secondaryEmail1->emailAddress = "jake@zurmo.com";
105  $secondaryEmail1->isInvalid = false;
106  $secondaryEmail1->optOut = true;
107 
108  $address1 = new Address();
109  $address1->street1 = "SomeStreet1";
110  $address1->street2 = "SomeStreet2";
111  $address1->city = "SomeCity";
112  $address1->state = "SomeState";
113  $address1->postalCode = 1111;
114  $address1->country = "SomeCountry";
115 
116  $likeContactState1 = new ContactState();
117  $likeContactState1->name = 'Customer';
118  $likeContactState1->order = 0;
119 
120  static::$userHash = StringUtil::generateRandomString(60);
121  $users = User::getAll();
122  $user1 = new User();
123  $user1->lastName = 'Kevin';
124  $user1->hash = static::$userHash;
125  $user1->language = 'es';
126  $user1->timeZone = 'America/Chicago';
127  $user1->username = 'dave';
128  $user1->currency = $currencies[0];
129  $user1->manager = $users[0];
130 
131  //Custom attribute
132  $attributeForm = new TextAttributeForm();
133  $attributeForm->attributeName = 'custom';
134  $attributeForm->attributeLabels = array('en' => 'test label en');
135 
136  $modelAttributesAdapterClassName = $attributeForm::
137  getModelAttributeAdapterNameForSavingAttributeFormData();
138  $adapter = new $modelAttributesAdapterClassName(new EmailTemplateModelTestItem());
139  $adapter->setAttributeMetadataFromForm($attributeForm);
140 
141  //ManyMany
142  $manyModel = new EmailTemplateModelTestItem2();
143  $manyModel->name = 'manyOriginalName';
144 
145  $model = new EmailTemplateModelTestItem();
146  $model->string = 'abc';
147  $model->firstName = 'James';
148  $model->lastName = 'Jackson';
149  $model->phone = 1122334455;
150  $model->boolean = true;
151  $model->date = '2008-12-31';
152  $model->dateTime = '2008-12-31 07:48:04';
153  $model->textArea = 'Multiple Lines\nOf Text';
154  $model->url = 'http://www.zurmo.com/';
155  $model->integer = 999;
156  $model->float = 999.999;
157  $model->currencyValue = $currencyValue1;
158  $model->dropDown->value = "DropdownSelectedValue";
159  $model->radioDropDown->value = "RadioDropdownSelectedValue";
160  $model->primaryEmail = $primaryEmail1;
161  $model->secondaryEmail = $secondaryEmail1;
162  $model->primaryAddress = $address1;
163  $model->likeContactState = $likeContactState1;
164  $model->user = $user1;
165  $model->multiDropDown->data = $multiDropDownCustomFieldData1;
166  $model->tagCloud->data = $tagCustomFieldData1;
167  $model->multiDropDown->values->add($multiDropDownCustomFieldValue1);
168  $model->multiDropDown->values->add($multiDropDownCustomFieldValue2);
169  $model->multiDropDown->values->add($multiDropDownCustomFieldValue3);
170  $model->tagCloud->values->add($tagCustomFieldValue1);
171  $model->tagCloud->values->add($tagCustomFieldValue2);
172  $model->customCstm = 'text custom';
173  $model->hasMany->add($manyModel);
174  $saved = $model->save();
175  assert('$saved'); // Not Coding Standard
176  self::$emailTemplate = $model;
177 
178  // Update all values but do not save the model.
179  $multiDropDownCustomFieldData2 = new CustomFieldData();
180  $multiDropDownCustomFieldData2->name = 'multiDropDown2';
181  $multiDropDownCustomFieldData2->serializedData = serialize(array('Thirteen', 14, 'XV'));
182  $saved = $multiDropDownCustomFieldData2->save();
183  assert('$saved'); // Not Coding Standard
184 
185  $multiDropDownCustomFieldValue4 = new CustomFieldValue();
186  $multiDropDownCustomFieldValue4->value = 'Thirteen';
187  $multiDropDownCustomFieldValue5 = new CustomFieldValue();
188  $multiDropDownCustomFieldValue5->value = 14;
189  $multiDropDownCustomFieldValue6 = new CustomFieldValue();
190  $multiDropDownCustomFieldValue6->value = 'XV';
191 
192  $tagCustomFieldData2 = new CustomFieldData();
193  $tagCustomFieldData2->name = 'tagCloud2';
194  $tagCustomFieldData2->serializedData = serialize(array('Nginx', 'Python'));
195  $saved = $tagCustomFieldData2->save();
196  assert('$saved'); // Not Coding Standard
197 
198  $tagCustomFieldValue3 = new CustomFieldValue();
199  $tagCustomFieldValue3->value = 'Python';
200  $tagCustomFieldValue4 = new CustomFieldValue();
201  $tagCustomFieldValue4->value = 'Nginx';
202 
203  $manyModel->name = 'manyChangedName';
204  $manyModel2 = new EmailTemplateModelTestItem2();
205  $manyModel2->name = 'newOriginalName';
206  self::$emailTemplate->hasMany->add($manyModel2);
207 
208  static::$emailTemplateUserHash = StringUtil::generateRandomString(60);
209  self::$emailTemplate->string = 'def';
210  self::$emailTemplate->firstName = 'Jane';
211  self::$emailTemplate->lastName = 'Bond';
212  self::$emailTemplate->phone = 66778899;
213  self::$emailTemplate->boolean = false;
214  self::$emailTemplate->date = '2009-12-31';
215  self::$emailTemplate->dateTime = '2009-12-31 07:48:04';
216  self::$emailTemplate->textArea = 'Multiple Lines\nOf\nText';
217  self::$emailTemplate->url = 'http://www.zurmo.org/';
218  self::$emailTemplate->integer = 888;
219  self::$emailTemplate->float = 888.888;
220  self::$emailTemplate->currencyValue->value = 99;
221  self::$emailTemplate->dropDown->value = "DropdownSelectedVal";
222  self::$emailTemplate->radioDropDown->value = "RadioDropdownSelectedVal";
223  self::$emailTemplate->primaryEmail->emailAddress = "info@zurmo.org";
224  self::$emailTemplate->primaryEmail->isInvalid = false;
225  self::$emailTemplate->primaryEmail->optOut = true;
226  self::$emailTemplate->secondaryEmail->emailAddress = "jake@zurmo.org";
227  self::$emailTemplate->secondaryEmail->isInvalid = true;
228  self::$emailTemplate->secondaryEmail->optOut = false;
229  self::$emailTemplate->primaryAddress->street1 = "SomeOtherStreet1";
230  self::$emailTemplate->primaryAddress->street2 = "SomeOtherStreet2";
231  self::$emailTemplate->primaryAddress->city = "SomeOtherCity";
232  self::$emailTemplate->primaryAddress->state = "SomeOtherState";
233  self::$emailTemplate->primaryAddress->postalCode = 2222;
234  self::$emailTemplate->primaryAddress->country = "SomeOtherCountry";
235  self::$emailTemplate->likeContactState->name = 'New';
236  self::$emailTemplate->likeContactState->order = 1;
237  self::$emailTemplate->user->lastName = 'Dean';
238  self::$emailTemplate->user->hash = static::$emailTemplateUserHash;
239  self::$emailTemplate->user->language = 'en';
240  self::$emailTemplate->user->timeZone = 'America/Denver';
241  self::$emailTemplate->user->username = 'deandavis';
242 
243  self::$emailTemplate->multiDropDown->data = $multiDropDownCustomFieldData2;
244  self::$emailTemplate->multiDropDown->values->remove($multiDropDownCustomFieldValue1);
245  self::$emailTemplate->multiDropDown->values->remove($multiDropDownCustomFieldValue2);
246  self::$emailTemplate->multiDropDown->values->remove($multiDropDownCustomFieldValue3);
247  self::$emailTemplate->multiDropDown->values->add($multiDropDownCustomFieldValue4);
248  self::$emailTemplate->multiDropDown->values->add($multiDropDownCustomFieldValue5);
249  self::$emailTemplate->multiDropDown->values->add($multiDropDownCustomFieldValue6);
250 
251  self::$emailTemplate->tagCloud->data = $tagCustomFieldData2;
252  self::$emailTemplate->tagCloud->values->remove($tagCustomFieldValue1);
253  self::$emailTemplate->tagCloud->values->remove($tagCustomFieldValue2);
254  self::$emailTemplate->tagCloud->values->add($tagCustomFieldValue3);
255  self::$emailTemplate->tagCloud->values->add($tagCustomFieldValue4);
256 
257  self::$emailTemplate->customCstm = 'text custom changed';
258 
259  self::$content = 'Current: [[STRING]] [[FIRST^NAME]] [[LAST^NAME]] ' .
260  '[[PHONE]] Old: [[WAS%STRING]] [[WAS%FIRST^NAME]] ' .
261  '[[WAS%LAST^NAME]] [[WAS%PHONE]]';
262  self::$compareContent = 'Current: def Jane Bond 66778899 Old: abc James ' .
263  'Jackson 1122334455';
264  self::$contact = ContactTestHelper::
265  createContactByNameForOwner('Jason', self::$super);
266  }
267 
268  public static function getDependentTestModelClassNames()
269  {
270  return array('EmailTemplateModelTestItem', 'EmailTemplateModelTestItem2');
271  }
272 
273  public function setUp()
274  {
275  parent::setUp();
276  Yii::app()->user->userModel = self::$super;
277  $this->mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW,
278  null, self::$content);
279  $this->invalidTags = array();
280  }
281 
282  public function testCanInstantiateContactMergeTags()
283  {
284  $this->assertTrue($this->mergeTagsUtil instanceof MergeTagsUtil);
285  $this->assertTrue($this->mergeTagsUtil instanceof WorkflowMergeTagsUtil);
286  }
287 
292  {
293  $resolvedContent = $this->mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags, 'fr');
294  $this->assertTrue($resolvedContent !== false);
295  $this->assertNotEquals($resolvedContent, self::$content);
296  $this->assertEquals($resolvedContent, self::$compareContent);
297  $this->assertEmpty($this->invalidTags);
298  }
299 
304  {
305  $resolvedContent = $this->mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags, null);
306  $this->assertTrue($resolvedContent !== false);
307  $this->assertNotEquals($resolvedContent, self::$content);
308  $this->assertEquals($resolvedContent, self::$compareContent);
309  $this->assertEmpty($this->invalidTags);
310  }
311 
316  {
317  $resolvedContent = $this->mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
318  $this->assertTrue($resolvedContent !== false);
319  $this->assertNotEquals($resolvedContent, self::$content);
320  $this->assertEquals($resolvedContent, self::$compareContent);
321  $this->assertEmpty($this->invalidTags);
322  }
323 
328  {
329  $content = "This is some text that doesn't contain any merge tags";
330  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
331  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
332  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
333  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags, null);
334  $this->assertTrue($resolvedContent !== false);
335  $this->assertEquals($resolvedContent, $content);
336  $this->assertEmpty($this->invalidTags);
337  }
338 
342  public function testFailsOnInvalidMergeTags()
343  {
344  $content = "This is some text that has [[INVALID]] [[IN^VALID]] [[PHONE__NO]] merge tags";
345  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
346  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
347  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
348  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags, null);
349  $this->assertFalse($resolvedContent);
350  $this->assertNotEquals($resolvedContent, $content);
351  $this->assertNotEmpty($this->invalidTags);
352  $this->assertEquals(3, count($this->invalidTags));
353  $this->assertTrue($this->invalidTags[0] == 'INVALID');
354  $this->assertTrue($this->invalidTags[1] == 'IN^VALID');
355  $this->assertTrue($this->invalidTags[2] == 'PHONE__NO');
356  }
357 
362  {
363  $content = "This is some text that has [[INVALID]] [[IN^VALID]] [[PHONE__NO]] merge tags";
364  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
365  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
366  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
367  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags, null,
368  MergeTagsToModelAttributesAdapter::ERROR_ON_FIRST_INVALID_TAG);
369  $this->assertFalse($resolvedContent);
370  $this->assertNotEquals($resolvedContent, $content);
371  $this->assertEmpty($this->invalidTags);
372  }
373 
374  // TODO: @Shoaibi/@Jason: Low: All of the tests below would have to be duplicated for different languages.
375 
379  public function testStringMergeTag()
380  {
381  $content = 'string: Current: [[STRING]] Old: [[WAS%STRING]]';
382  $compareContent = 'string: Current: def Old: abc';
383  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
384  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
385  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
386  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
387  $this->assertTrue($resolvedContent !== false);
388  $this->assertNotEquals($resolvedContent, $content);
389  $this->assertEquals($compareContent, $resolvedContent);
390  $this->assertEmpty($this->invalidTags);
391  }
392 
396  public function testFirstNameMergeTag()
397  {
398  $content = 'firstName: Current: [[FIRST^NAME]] Old: [[WAS%FIRST^NAME]]';
399  $compareContent = 'firstName: Current: Jane Old: James';
400  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
401  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
402  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
403  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
404  $this->assertTrue($resolvedContent !== false);
405  $this->assertNotEquals($resolvedContent, $content);
406  $this->assertEquals($compareContent, $resolvedContent);
407  $this->assertEmpty($this->invalidTags);
408  }
409 
413  public function testLastNameMergeTag()
414  {
415  $content = 'lastName: Current: [[LAST^NAME]] Old: [[WAS%LAST^NAME]]';
416  $compareContent = 'lastName: Current: Bond Old: Jackson';
417  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
418  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
419  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
420  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
421  $this->assertTrue($resolvedContent !== false);
422  $this->assertNotEquals($resolvedContent, $content);
423  $this->assertEquals($compareContent, $resolvedContent);
424  $this->assertEmpty($this->invalidTags);
425  }
426 
430  public function testPhoneMergeTag()
431  {
432  $content = 'phone: Current: [[PHONE]] Old: [[WAS%PHONE]]';
433  $compareContent = 'phone: Current: 66778899 Old: 1122334455';
434  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
435  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
436  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
437  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
438  $this->assertTrue($resolvedContent !== false);
439  $this->assertNotEquals($resolvedContent, $content);
440  $this->assertEquals($compareContent, $resolvedContent);
441  $this->assertEmpty($this->invalidTags);
442  }
443 
447  public function testBooleanMergeTag()
448  {
449  $content = 'boolean: Current: [[BOOLEAN]] Old: [[WAS%BOOLEAN]]';
450  $compareContent = 'boolean: Current: 0 Old: 1';
451  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
452  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
453  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
454  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
455  $this->assertTrue($resolvedContent !== false);
456  $this->assertNotEquals($resolvedContent, $content);
457  $this->assertEquals($compareContent, $resolvedContent);
458  $this->assertEmpty($this->invalidTags);
459  }
460 
464  public function testDateMergeTag()
465  {
466  $content = 'date: Current: [[DATE]] Old: [[WAS%DATE]]';
467  $compareContent = 'date: Current: 2009-12-31 Old: 2008-12-31';
468  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
469  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
470  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
471  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
472  $this->assertTrue($resolvedContent !== false);
473  $this->assertNotEquals($resolvedContent, $content);
474  $this->assertEquals($compareContent, $resolvedContent);
475  $this->assertEmpty($this->invalidTags);
476  }
477 
481  public function testDateTimeMergeTag()
482  {
483  $content = 'dateTime: Current: [[DATE^TIME]] Old: [[WAS%DATE^TIME]]';
484  $compareContent = 'dateTime: Current: 2009-12-31 07:48:04 GMT Old: 2008-12-31 07:48:04 GMT';
485  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
486  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
487  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
488  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
489  $this->assertTrue($resolvedContent !== false);
490  $this->assertNotEquals($resolvedContent, $content);
491  $this->assertEquals($compareContent, $resolvedContent);
492  $this->assertEmpty($this->invalidTags);
493  }
494 
498  public function testTextAreaMergeTag()
499  {
500  $content = 'textArea: Current: [[TEXT^AREA]] Old: [[WAS%TEXT^AREA]]';
501  $compareContent = 'textArea: Current: Multiple Lines\nOf\nText Old: Multiple Lines\nOf Text';
502  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
503  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
504  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
505  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
506  $this->assertTrue($resolvedContent !== false);
507  $this->assertNotEquals($resolvedContent, $content);
508  $this->assertEquals($compareContent, $resolvedContent);
509  $this->assertEmpty($this->invalidTags);
510  }
511 
515  public function testUrlMergeTag()
516  {
517  $content = 'url: Current: [[URL]] Old: [[WAS%URL]]';
518  $compareContent = 'url: Current: http://www.zurmo.org/ Old: http://www.zurmo.com/';
519  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
520  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
521  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
522  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
523  $this->assertTrue($resolvedContent !== false);
524  $this->assertNotEquals($resolvedContent, $content);
525  $this->assertEquals($compareContent, $resolvedContent);
526  $this->assertEmpty($this->invalidTags);
527  }
528 
532  public function testIntegerMergeTag()
533  {
534  $content = 'integer: Current: [[INTEGER]] Old: [[WAS%INTEGER]]';
535  $compareContent = 'integer: Current: 888 Old: 999';
536  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
537  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
538  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
539  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
540  $this->assertTrue($resolvedContent !== false);
541  $this->assertNotEquals($resolvedContent, $content);
542  $this->assertEquals($compareContent, $resolvedContent);
543  $this->assertEmpty($this->invalidTags);
544  }
545 
549  public function testFloatMergeTag()
550  {
551  $content = 'float: Current: [[FLOAT]] Old: [[WAS%FLOAT]]';
552  $compareContent = 'float: Current: 888.888 Old: 999.999';
553  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
554  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
555  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
556  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
557  $this->assertTrue($resolvedContent !== false);
558  $this->assertNotEquals($resolvedContent, $content);
559  $this->assertEquals($compareContent, $resolvedContent);
560  $this->assertEmpty($this->invalidTags);
561  }
562 
566  public function testCurrencyValueMergeTag()
567  {
568  $content = 'currencyValue: Current: [[CURRENCY^VALUE]] [[CURRENCY^VALUE__VALUE]] ' .
569  '[[CURRENCY^VALUE__CURRENCY__CODE]] [[CURRENCY^VALUE__CURRENCY__ACTIVE]] ' .
570  'Old: [[WAS%CURRENCY^VALUE__VALUE]]';
571  $compareContent = 'currencyValue: Current: $99 99 USD 1 Old: 100';
572  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
573  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
574  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
575  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
576  $this->assertTrue($resolvedContent !== false);
577  $this->assertNotEquals($resolvedContent, $content);
578  $this->assertEquals($compareContent, $resolvedContent);
579  $this->assertEmpty($this->invalidTags);
580  }
581 
585  public function testDropDownMergeTag()
586  {
587  $content = 'dropDown: Current: [[DROP^DOWN]] [[DROP^DOWN__VALUE]] ' .
588  'Old: [[WAS%DROP^DOWN__VALUE]]';
589  $compareContent = 'dropDown: Current: DropdownSelectedVal DropdownSelectedVal '.
590  'Old: DropdownSelectedValue';
591  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
592  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
593  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
594  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
595  $this->assertTrue($resolvedContent !== false);
596  $this->assertNotEquals($resolvedContent, $content);
597  $this->assertEquals($compareContent, $resolvedContent);
598  $this->assertEmpty($this->invalidTags);
599  }
600 
604  public function testRadioDropDownMergeTag()
605  {
606  $content = 'radioDropDown: Current: [[RADIO^DROP^DOWN]] [[RADIO^DROP^DOWN__VALUE]] ' .
607  'Old: [[WAS%RADIO^DROP^DOWN__VALUE]]';
608  $compareContent = 'radioDropDown: Current: RadioDropdownSelectedVal RadioDropdownSelectedVal ' .
609  'Old: RadioDropdownSelectedValue';
610  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
611  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
612  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
613  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
614  $this->assertTrue($resolvedContent !== false);
615  $this->assertNotEquals($resolvedContent, $content);
616  $this->assertEquals($compareContent, $resolvedContent);
617  $this->assertEmpty($this->invalidTags);
618  }
619 
623  public function testMultiDropDownMergeTag()
624  {
625  // TODO: @Shoaibi/@Jason: Low: We can't do WAS% with multiDropDown at all.
626  // WAS%MULTI^DROP^DOWN
627  // WAS%MULTI^DROP^DOWN__VALUES
628  // WAS%MULTI^DROP^DOWN__DATA
629  // All of these are ending on a relation tag. How do we use WAS% with multiDropDown? which data can we change which isn't HAS_MANY and direct property.
630  $content = 'multiDropDown: Current: [[MULTI^DROP^DOWN]] [[MULTI^DROP^DOWN__VALUES]] ' .
631  'Old:';
632  $compareContent = 'multiDropDown: Current: Thirteen, 14, XV 3 records.' .
633  ' Old:';
634  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
635  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
636  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
637  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
638  $this->assertTrue($resolvedContent !== false);
639  $this->assertNotEquals($resolvedContent, $content);
640  $this->assertEquals($compareContent, $resolvedContent);
641  $this->assertEmpty($this->invalidTags);
642  }
643 
647  public function testTagCloudMergeTag()
648  {
649  // TODO: @Shoaibi/Jason: Low: How do we do "WAS%" with this? Same explanation as above.
650  $content = 'tagCloud: Current: [[TAG^CLOUD]] [[TAG^CLOUD__VALUES]] ' .
651  'Old:';
652  $compareContent = 'tagCloud: Current: Python, Nginx 2 records. '.
653  'Old:';
654  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
655  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
656  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
657  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
658  $this->assertTrue($resolvedContent !== false);
659  $this->assertNotEquals($resolvedContent, $content);
660  $this->assertEquals($compareContent, $resolvedContent);
661  $this->assertEmpty($this->invalidTags);
662  }
663 
667  public function testPrimaryEmailMergeTag()
668  {
669  $content = 'primaryEmail: Current: [[PRIMARY^EMAIL]] [[PRIMARY^EMAIL__EMAIL^ADDRESS]] ' .
670  '[[PRIMARY^EMAIL__IS^INVALID]] [[PRIMARY^EMAIL__OPT^OUT]] ' .
671  'Old: [[WAS%PRIMARY^EMAIL__EMAIL^ADDRESS]] ' .
672  '[[WAS%PRIMARY^EMAIL__IS^INVALID]] [[WAS%PRIMARY^EMAIL__OPT^OUT]]';
673  $compareContent = 'primaryEmail: Current: info@zurmo.org info@zurmo.org 0 1 ' .
674  'Old: info@zurmo.com 1 0';
675  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
676  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
677  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
678  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
679  $this->assertTrue($resolvedContent !== false);
680  $this->assertNotEquals($resolvedContent, $content);
681  $this->assertEquals($compareContent, $resolvedContent);
682  $this->assertEmpty($this->invalidTags);
683  }
684 
688  public function testSecondaryEmailMergeTag()
689  {
690  $content = 'secondaryEmail: Current: [[SECONDARY^EMAIL]] [[SECONDARY^EMAIL__EMAIL^ADDRESS]] ' .
691  '[[SECONDARY^EMAIL__IS^INVALID]] [[SECONDARY^EMAIL__OPT^OUT]] ' .
692  'Old: [[WAS%SECONDARY^EMAIL__EMAIL^ADDRESS]] ' .
693  '[[WAS%SECONDARY^EMAIL__IS^INVALID]] [[WAS%SECONDARY^EMAIL__OPT^OUT]]';
694  $compareContent = 'secondaryEmail: Current: jake@zurmo.org jake@zurmo.org 1 0 '.
695  'Old: jake@zurmo.com 0 1';
696  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
697  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
698  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
699  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
700  $this->assertTrue($resolvedContent !== false);
701  $this->assertNotEquals($resolvedContent, $content);
702  $this->assertEquals($compareContent, $resolvedContent);
703  $this->assertEmpty($this->invalidTags);
704  }
705 
709  public function testAddressMergeTag()
710  {
711  $content = 'address: Current: [[PRIMARY^ADDRESS]] [[PRIMARY^ADDRESS__STREET1]] ' .
712  '[[PRIMARY^ADDRESS__STREET2]] [[PRIMARY^ADDRESS__CITY]] ' .
713  '[[PRIMARY^ADDRESS__STATE]] [[PRIMARY^ADDRESS__POSTAL^CODE]] ' .
714  '[[PRIMARY^ADDRESS__COUNTRY]] ' .
715  'Old: [[WAS%PRIMARY^ADDRESS__STREET1]] ' .
716  '[[WAS%PRIMARY^ADDRESS__STREET2]] [[WAS%PRIMARY^ADDRESS__CITY]] ' .
717  '[[WAS%PRIMARY^ADDRESS__STATE]] [[WAS%PRIMARY^ADDRESS__POSTAL^CODE]] ' .
718  '[[WAS%PRIMARY^ADDRESS__COUNTRY]]';
719  $compareContent = 'address: Current: SomeOtherStreet1, SomeOtherStreet2, SomeOtherCity,'. // Not Coding Standard
720  ' SomeOtherState, 2222, SomeOtherCountry SomeOtherStreet1 ' .
721  'SomeOtherStreet2 SomeOtherCity SomeOtherState 2222 SomeOtherCountry' .
722  ' Old: SomeStreet1 SomeStreet2 SomeCity SomeState 1111 SomeCountry';
723  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
724  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
725  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
726  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
727  $this->assertTrue($resolvedContent !== false);
728  $this->assertNotEquals($resolvedContent, $content);
729  $this->assertEquals($compareContent, $resolvedContent);
730  $this->assertEmpty($this->invalidTags);
731  }
732 
737  {
738  // ContactState does not support originalAttributeValues
739  $content = 'likeContactState: Current: [[LIKE^CONTACT^STATE]] [[LIKE^CONTACT^STATE__NAME]] ' .
740  '[[LIKE^CONTACT^STATE__ORDER]][[LIKE^CONTACT^STATE__SERIALIZED^LABELS]] ' .
741  'Old: [[WAS%LIKE^CONTACT^STATE]] [[WAS%LIKE^CONTACT^STATE__NAME]] ' .
742  '[[WAS%LIKE^CONTACT^STATE__ORDER]][[WAS%LIKE^CONTACT^STATE__SERIALIZED^LABELS]]';
743  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
744  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
745  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
746  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
747  $this->assertFalse($resolvedContent);
748  $this->assertNotEmpty($this->invalidTags);
749  $this->assertCount(4, $this->invalidTags);
750  $this->assertEquals('WAS%LIKE^CONTACT^STATE', $this->invalidTags[0]);
751  $this->assertEquals('WAS%LIKE^CONTACT^STATE__NAME', $this->invalidTags[1]);
752  $this->assertEquals('WAS%LIKE^CONTACT^STATE__ORDER', $this->invalidTags[2]);
753  $this->assertEquals('WAS%LIKE^CONTACT^STATE__SERIALIZED^LABELS', $this->invalidTags[3]);
754  }
755 
759  public function testUserMergeTag()
760  {
761  // Currency does not support originalAttributeValues
762  $content = 'user: Current: [[USER__HASH]] [[USER__LAST^NAME]] [[USER__LANGUAGE]] [[USER__TIME^ZONE]]' .
763  ' [[USER__USERNAME]] [[USER__CURRENCY]] [[USER__CURRENCY__CODE]] ' .
764  'Old: [[WAS%USER__HASH]] [[WAS%USER__LAST^NAME]] [[WAS%USER__LANGUAGE]]' .
765  ' [[WAS%USER__TIME^ZONE]] [[WAS%USER__USERNAME]]';
766  $compareContent = 'user: Current: ' . static::$emailTemplateUserHash . ' Dean en America/Denver'.
767  ' deandavis USD USD Old: ' . static::$userHash . ' Kevin es '.
768  'America/Chicago dave';
769  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
770  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
771  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
772  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
773  $this->assertTrue($resolvedContent !== false);
774  $this->assertNotEquals($resolvedContent, $content);
775  $this->assertEquals($compareContent, $resolvedContent);
776  $this->assertEmpty($this->invalidTags);
777  }
778 
782  public function testModelUrlMergeTag()
783  {
784  $content = '[[MODEL^URL]]';
785  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
786  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
787  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
788  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
789  $this->assertTrue($resolvedContent !== false);
790  $this->assertNotEquals($resolvedContent, $content);
791  $expectedSuffix = '/emailTemplates/default/details?id=' . static::$emailTemplate->id;
792  $this->assertContains($expectedSuffix, $resolvedContent);
793  $this->assertEmpty($this->invalidTags);
794 
795  $content = '[[WAS%MODEL^URL]]';
796  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
797  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
798  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
799  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
800  $this->assertTrue($resolvedContent === false);
801  $this->assertNotEquals($resolvedContent, $content);
802  $this->assertNotEmpty($this->invalidTags);
803  $this->assertEquals('WAS%MODEL^URL', $this->invalidTags[0]);
804  }
805 
809  public function testModelCustomAttribute()
810  {
811  $content = 'customCstm: Current: [[CUSTOM^CSTM]] Old: [[WAS%CUSTOM^CSTM]]';
812  $compareContent = 'customCstm: Current: text custom changed Old: text custom';
813  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
814  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
815  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
816  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
817  $this->assertTrue($resolvedContent !== false);
818  $this->assertNotEquals($resolvedContent, $content);
819  $this->assertEquals($compareContent, $resolvedContent);
820  $this->assertEmpty($this->invalidTags);
821  }
822 
826  public function testApplicationNameMergeTag()
827  {
828  ZurmoConfigurationUtil::setByModuleName('ZurmoModule', 'applicationName', 'Demo App');
829  $content = '[[APPLICATION^NAME]]';
830  $expectedContent = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'applicationName');
831  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
832  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
833  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
834  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
835  $this->assertTrue($resolvedContent !== false);
836  $this->assertNotEquals($resolvedContent, $content);
837  $this->assertEquals($expectedContent, $resolvedContent);
838  $this->assertEmpty($this->invalidTags);
839  }
840 
844  public function testCurrentYearMergeTag()
845  {
846  $content = '[[CURRENT^YEAR]]';
847  $expectedContent = date('Y');
848  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
849  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
850  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
851  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
852  $this->assertTrue($resolvedContent !== false);
853  $this->assertNotEquals($resolvedContent, $content);
854  $this->assertEquals($expectedContent, $resolvedContent);
855  $this->assertEmpty($this->invalidTags);
856  }
857 
861  public function testLastYearMergeTag()
862  {
863  $content = '[[LAST^YEAR]]';
864  $expectedContent = date('Y') - 1;
865  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
866  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
867  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
868  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
869  $this->assertTrue($resolvedContent !== false);
870  $this->assertNotEquals($resolvedContent, $content);
871  $this->assertEquals($expectedContent, $resolvedContent);
872  $this->assertEmpty($this->invalidTags);
873  }
874 
878  public function testBaseUrlMergeTag()
879  {
880  $content = '[[BASE^URL]]';
881  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
882  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
883  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
884  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
885  $this->assertTrue($resolvedContent !== false);
886  $this->assertNotEquals($resolvedContent, $content);
887  $this->assertContains('localhost', $resolvedContent);
888  $this->assertEmpty($this->invalidTags);
889  }
890 
894  public function testActivityItemsMergeTag()
895  {
896  $account = AccountTestHelper::createAccountByNameForOwner('testAccount', self::$super);
897  $task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('testTask', self::$super, $account);
898  $content = '[[ACCOUNT__NAME]]';
899  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
900  $resolvedContent = $mergeTagsUtil->resolveMergeTags($task, $this->invalidTags);
901  $this->assertEquals('testAccount', $resolvedContent);
902 
903  $content = '[[CONTACT__NAME]]';
904  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
905  $resolvedContent = $mergeTagsUtil->resolveMergeTags($task, $this->invalidTags);
906  $this->assertFalse($resolvedContent);
907  $this->assertContains('CONTACT__NAME', $this->invalidTags);
908  }
909 
914  {
915  $content = '[[OWNERS^AVATAR^SMALL]]';
916  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
917  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
918  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
919  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$contact, $this->invalidTags);
920  $this->assertTrue($resolvedContent !== false);
921  $this->assertNotEquals($resolvedContent, $content);
922  $expectedAvatarImage = '<img class="gravatar" width="32" height="32" src="http://www.gravatar.com/avatar/?s=32&amp;r=g&amp;d=mm" alt="Clark Kent" />'; // Not Coding Standard
923  $this->assertEquals($expectedAvatarImage, $resolvedContent);
924  $this->assertEmpty($this->invalidTags);
925  }
926 
931  {
932  $content = '[[OWNERS^AVATAR^MEDIUM]]';
933  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
934  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
935  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
936  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$contact, $this->invalidTags);
937  $this->assertTrue($resolvedContent !== false);
938  $this->assertNotEquals($resolvedContent, $content);
939  $expectedAvatarImage = '<img class="gravatar" width="64" height="64" src="http://www.gravatar.com/avatar/?s=64&amp;r=g&amp;d=mm" alt="Clark Kent" />'; // Not Coding Standard
940  $this->assertEquals($expectedAvatarImage, $resolvedContent);
941  $this->assertEmpty($this->invalidTags);
942  }
943 
948  {
949  $content = '[[OWNERS^AVATAR^LARGE]]';
950  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
951  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
952  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
953  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$contact, $this->invalidTags);
954  $this->assertTrue($resolvedContent !== false);
955  $this->assertNotEquals($resolvedContent, $content);
956  $expectedAvatarImage = '<img class="gravatar" width="128" height="128" src="http://www.gravatar.com/avatar/?s=128&amp;r=g&amp;d=mm" alt="Clark Kent" />'; // Not Coding Standard
957  $this->assertEquals($expectedAvatarImage, $resolvedContent);
958  $this->assertEmpty($this->invalidTags);
959  }
960 
965  {
966  $content = '[[OWNERS^EMAIL^SIGNATURE]]';
967  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
968  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
969  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
970  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$contact, $this->invalidTags);
971  $this->assertTrue($resolvedContent !== false);
972  $this->assertNotEquals($resolvedContent, $content);
973  $expectedEmailSignature = 'my email signature';
974  $this->assertEquals($expectedEmailSignature, $resolvedContent);
975  $this->assertEmpty($this->invalidTags);
976  }
977 
981  public function testHasManyRelation()
982  {
983  $content = '[[HAS^MANY__EMAIL^TEMPLATE^MODEL^TEST^ITEM2]]';
984  $mergeTagsUtil = MergeTagsUtilFactory::make(EmailTemplate::TYPE_WORKFLOW, null, $content);
985  $this->assertTrue($mergeTagsUtil instanceof MergeTagsUtil);
986  $this->assertTrue($mergeTagsUtil instanceof WorkflowMergeTagsUtil);
987  $resolvedContent = $mergeTagsUtil->resolveMergeTags(self::$emailTemplate, $this->invalidTags);
988  $this->assertTrue($resolvedContent !== false);
989  $this->assertNotEquals($resolvedContent, $content);
990  $expectedContent = 'manyChangedName, newOriginalName';
991  $this->assertEquals($expectedContent, $resolvedContent);
992  $this->assertEmpty($this->invalidTags);
993  }
994  }
995 ?>
Definition: Email.php:37
static getByUsername($username)
Definition: User.php:49
Definition: User.php:37
static make($emailTemplateType, $language, $content)
static loadStartingData()
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null, $buildFirstCurrency=true)
Definition: Currency.php:107
static getByModuleName($moduleName, $key, $cache=true)
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
static generateRandomString($length=10, $characterSet=null)
Definition: StringUtil.php:156
static setByModuleName($moduleName, $key, $value, $cache=true)
Generated on Tue Sep 22 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.