public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     EmailTemplateTestHelper::create('EmailTemplate 01', 'Subject 01', 'Contact', 'html', 'text');
     EmailTemplateTestHelper::create('EmailTemplate 02', 'Subject 02', 'Contact', 'html', 'text');
     EmailTemplateTestHelper::create('EmailTemplate 03', 'Subject 03', 'Contact', 'html', 'text');
     MarketingListTestHelper::createMarketingListByName('MarketingListName', 'MarketingList Description', 'first', '*****@*****.**');
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     EmailTemplateTestHelper::create('EmailTemplate 01', 'Subject 01', 'Contact', 'Html Content 01', 'Text Content 01');
     EmailTemplateTestHelper::create('EmailTemplate 02', 'Subject 02', 'Contact', 'Html Content 02', 'Text Content 02');
     EmailTemplateTestHelper::create('EmailTemplate 03', 'Subject 03', 'Contact', 'Html Content 03', 'Text Content 03');
     EmailTemplateTestHelper::create('EmailTemplate 04', 'Subject 04', 'Contact', 'Html Content 04', 'Text Content 04');
     EmailTemplateTestHelper::create('EmailTemplate 05', 'Subject 05', 'Contact', 'Html Content 05', 'Text Content 05');
     $marketingList = MarketingListTestHelper::createMarketingListByName('MarketingListName', 'MarketingList Description');
     static::$marketingListId = $marketingList->id;
     AutoresponderTestHelper::createAutoresponder('Subject 01', 'This is text Content 01', 'This is html Content 01', 10, Autoresponder::OPERATION_SUBSCRIBE, true, $marketingList);
     AutoresponderTestHelper::createAutoresponder('Subject 02', 'This is text Content 02', 'This is html Content 02', 5, Autoresponder::OPERATION_UNSUBSCRIBE, false, $marketingList);
     AllPermissionsOptimizationUtil::rebuild();
 }
 /**
  * @depends testDetailsJsonActionForPlainText
  */
 public function testDetailsJsonActionForWorkflow()
 {
     $emailTemplate = EmailTemplateTestHelper::create('workflow 01', 'workflow 01', 'Note', 'html', 'text', EmailTemplate::TYPE_WORKFLOW);
     $emailTemplateDataUtil = new ModelToArrayAdapter($emailTemplate);
     $emailTemplateDetailsArray = $emailTemplateDataUtil->getData();
     $this->assertNotEmpty($emailTemplateDetailsArray);
     $this->setGetArray(array('id' => $emailTemplate->id, 'renderJson' => true));
     // @ to avoid headers already sent error.
     $content = @$this->runControllerWithExitExceptionAndGetContent('emailTemplates/default/detailsJson');
     $emailTemplateDetailsResolvedArray = CJSON::decode($content);
     $this->assertNotEmpty($emailTemplateDetailsResolvedArray);
     $this->assertEquals($emailTemplateDetailsArray, $emailTemplateDetailsResolvedArray);
 }
 public function testListForWorkflowAction()
 {
     EmailTemplateTestHelper::create('Test Name', 'Test Subject', 'Contact', 'Text HtmlContent', 'Test TextContent', EmailTemplate::TYPE_WORKFLOW);
     parent::testListForWorkflowAction();
 }
 public function testUserWithNotReadPermissionForEmailTemplatesModuleStillCanSeePredefinedTemplates()
 {
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $everyone = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $item = NamedSecurableItem::getByName('EmailTemplatesModule');
     $item->addPermissions($everyone, Permission::READ, Permission::DENY);
     $this->assertTrue($item->save());
     ReadPermissionsOptimizationUtil::rebuild();
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
     $emailTemplate2 = EmailTemplateTestHelper::create('Test Name Regular 02', 'Test Subject Regular 02', 'Contact', 'Test HtmlContent Regular 01', 'Test TextContent Regular 01', EmailTemplate::TYPE_CONTACT, 0, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     $this->setGetArray(array('id' => $emailTemplate2->id, 'filterBy' => SelectBaseTemplateElement::FILTER_BY_PREDEFINED_TEMPLATES, 'ajax' => 'BuilderEmailTemplateWizardForm_baseTemplateId_list_view'));
     $content = @$this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/edit');
     $this->assertContains('<div class="summary">Displaying 1-6 of 6 results.</div><ul class="template-list clearfix">', $content);
     $emailTemplate2->delete();
 }
예제 #6
0
 /**
  * @depends testCreateAndGetEmailTemplateById
  */
 public function testGetPreviouslyCreatedBuilderTemplates()
 {
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates();
     $this->assertEmpty($previouslyCreated);
     $previouslyCreatedWithDrafts = EmailTemplate::getPreviouslyCreatedBuilderTemplates(null, true);
     $this->assertEmpty($previouslyCreatedWithDrafts);
     $previouslyCreatedContactTemplates = EmailTemplate::getPreviouslyCreatedBuilderTemplates('Contact');
     $this->assertEmpty($previouslyCreatedContactTemplates);
     $previouslyCreatedContactTemplatesWithDrafts = EmailTemplate::getPreviouslyCreatedBuilderTemplates('Contact', true);
     $this->assertEmpty($previouslyCreatedContactTemplatesWithDrafts);
     // create 2 predefined builder templates
     EmailTemplateTestHelper::create('predefined builder 01', 'subject 01', null, 'html', 'text', EmailTemplate::TYPE_CONTACT, 0, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     EmailTemplateTestHelper::create('predefined builder 02', 'subject 02', null, 'html', 'text', EmailTemplate::TYPE_CONTACT, 0, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     // create 2 contact type builder, 1 draft 1 non draft
     EmailTemplateTestHelper::create('contact 03', 'subject 03', 'Contact', 'html', 'text', EmailTemplate::TYPE_CONTACT, 0, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     EmailTemplateTestHelper::create('contact 04', 'subject 04', 'Contact', 'html', 'text', EmailTemplate::TYPE_CONTACT, 1, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     // create 2 note type builder, 1 draft 1 non draft
     EmailTemplateTestHelper::create('note 01', 'subject 01', 'Note', 'html', 'text', EmailTemplate::TYPE_WORKFLOW, 0, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     EmailTemplateTestHelper::create('note 02', 'subject 02', 'Note', 'html', 'text', EmailTemplate::TYPE_WORKFLOW, 1, EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE);
     // list all previously created templates without drafts
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates();
     $this->assertCount(2, $previouslyCreated);
     $this->assertEquals('contact 03', $previouslyCreated[0]->name);
     $this->assertEquals('note 01', $previouslyCreated[1]->name);
     // list all previously created templates with drafts
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates(null, true);
     $this->assertCount(4, $previouslyCreated);
     $this->assertEquals('contact 03', $previouslyCreated[0]->name);
     $this->assertEquals('contact 04', $previouslyCreated[1]->name);
     $this->assertEquals('note 01', $previouslyCreated[2]->name);
     $this->assertEquals('note 02', $previouslyCreated[3]->name);
     // list all contact model previously created templates without drafts
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates('Contact');
     $this->assertCount(1, $previouslyCreated);
     $this->assertEquals('contact 03', $previouslyCreated[0]->name);
     // list all contact model previously created templates with drafts
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates('Contact', true);
     $this->assertCount(2, $previouslyCreated);
     $this->assertEquals('contact 03', $previouslyCreated[0]->name);
     $this->assertEquals('contact 04', $previouslyCreated[1]->name);
     // list all note model previously created templates without drafts
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates('Note');
     $this->assertCount(1, $previouslyCreated);
     $this->assertEquals('note 01', $previouslyCreated[0]->name);
     // list all note model previously created templates with drafts
     $previouslyCreated = EmailTemplate::getPreviouslyCreatedBuilderTemplates('Note', true);
     $this->assertCount(2, $previouslyCreated);
     $this->assertEquals('note 01', $previouslyCreated[0]->name);
     $this->assertEquals('note 02', $previouslyCreated[1]->name);
 }