当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailTemplate::getErrors方法代码示例

本文整理汇总了PHP中EmailTemplate::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailTemplate::getErrors方法的具体用法?PHP EmailTemplate::getErrors怎么用?PHP EmailTemplate::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EmailTemplate的用法示例。


在下文中一共展示了EmailTemplate::getErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetData

 public function testGetData()
 {
     $moduleClassName = Contact::getModuleClassName();
     $type = Report::TYPE_ROWS_AND_COLUMNS;
     $treeType = ComponentForReportForm::TYPE_FILTERS;
     $report = new Report();
     $report->setModuleClassName($moduleClassName);
     $report->setType($type);
     $reportToTreeAdapter = new MergeTagsReportRelationsAndAttributesToTreeAdapter($report, $treeType, 'EmailTemplate');
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = 'Text Content ';
     $emailTemplate->htmlContent = 'Html Content ';
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->modelClassName = 'Contact';
     // By testing the getData method we're actually testing that all Merge Tags are valid
     // and that we can save the EmailTemplate with each Merge Tag without having the error 'Invalid Merge Tag'.
     $data = $reportToTreeAdapter->getData('source');
     foreach ($data[1]['children'] as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_createdByUser');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_owner');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_owner___primaryEmail');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     $data = $reportToTreeAdapter->getData('EmailTemplate_primaryAddress');
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = '';
     foreach ($data as $child) {
         if (isset($child['dataValue']) && $child['dataValue']) {
             $emailTemplate->textContent .= ' ' . $child['dataValue'];
             $emailTemplate->htmlContent .= ' ' . $child['dataValue'];
         }
     }
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertTrue($emailTemplate->save());
     // Test against invalid Merge Tags
     $emailTemplate->textContent = 'Text Content [[TEXT__INVALID^MERGE^TAG]]';
     $emailTemplate->htmlContent = 'Html Content [[HTMLINVALIDMERGETAG]]';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertFalse($validated);
     $errorMessages = $emailTemplate->getErrors();
     $this->assertEquals(2, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertTrue(array_key_exists('htmlContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals(1, count($errorMessages['htmlContent']));
     $this->assertContains('TEXT__INVALID^MERGE^TAG', $errorMessages['textContent'][0]);
     $this->assertContains('HTMLINVALIDMERGETAG', $errorMessages['htmlContent'][0]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:96,代码来源:MergeTagsReportRelationsAndAttributesToTreeAdapterTest.php

示例2: testMergeTagsValidation

 public function testMergeTagsValidation()
 {
     // test against a invalid merge tags
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = 'Text Content [[TEXT__INVALID^MERGE^TAG]]';
     $emailTemplate->htmlContent = 'Html Content [[HTMLINVALIDMERGETAG]]';
     $emailTemplate->modelClassName = 'Contact';
     $this->assertFalse($emailTemplate->save());
     $errorMessages = $emailTemplate->getErrors();
     $this->assertEquals(2, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertTrue(array_key_exists('htmlContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals(1, count($errorMessages['htmlContent']));
     $this->assertTrue(strpos($errorMessages['textContent'][0], 'TEXT__INVALID^MERGE^TAG') !== false);
     $this->assertTrue(strpos($errorMessages['htmlContent'][0], 'HTMLINVALIDMERGETAG') !== false);
     // test with no merge tags
     $emailTemplate->textContent = 'Text Content without tags';
     $emailTemplate->htmlContent = 'Html Content without tags';
     $this->assertTrue($emailTemplate->save());
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertEquals(3, count(EmailTemplate::getAll()));
     // test with valid merge tags
     $emailTemplate->textContent = 'Name : [[FIRST^NAME]] [[LAST^NAME]]';
     $emailTemplate->htmlContent = '<b>Name : [[FIRST^NAME]] [[LAST^NAME]]</b>';
     $this->assertTrue($emailTemplate->save());
     $this->assertEmpty($emailTemplate->getErrors());
     $this->assertEquals(3, count(EmailTemplate::getAll()));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:EmailTemplateTest.php

示例3: testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty

 /**
  * @depends testCreateAndGetEmailTemplateById
  */
 public function testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty()
 {
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = '';
     $emailTemplate->htmlContent = "<html>\n<head>\n</head>\n<body>\n</body>\n</html>";
     $emailTemplate->modelClassName = 'Contact';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertFalse($validated);
     $errorMessages = $emailTemplate->getErrors();
     $this->assertEquals(1, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals('Please provide at least one of the contents field.', $errorMessages['textContent'][0]);
     $emailTemplate->textContent = 'Text Content';
     $validated = $emailTemplate->validate(null, false, true);
     $this->assertTrue($validated);
     $this->assertTrue($emailTemplate->save());
     $this->assertEquals(6, EmailTemplate::getCount());
     $id = $emailTemplate->id;
     unset($emailTemplate);
     $emailTemplate = EmailTemplate::getById($id);
     $this->assertEquals(EmailTemplate::TYPE_CONTACT, $emailTemplate->type);
     $this->assertEquals('Another Test subject', $emailTemplate->subject);
     $this->assertEquals('Another Test Email Template', $emailTemplate->name);
     $this->assertEquals(null, $emailTemplate->htmlContent);
     $this->assertEquals('Text Content', $emailTemplate->textContent);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:34,代码来源:EmailTemplateTest.php


注:本文中的EmailTemplate::getErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。