/** * @depends testRegularUserAllDefaultControllerActions */ public function testRegularUserCreateActionForWorkflow() { // TODO: @Shoaibi/@Jason: Medium: Even if a user doesn't have module permission he can sent that modelClassName in POST // nobody needs access to meetings ans contact to have that in ddl. $this->user->setRight('ContactsModule', ContactsModule::getAccessRight()); $this->user->setRight('MeetingsModule', MeetingsModule::getAccessRight()); $this->assertTrue($this->user->save()); // Create a new emailTemplate and test validator. $this->setGetArray(array('type' => EmailTemplate::TYPE_WORKFLOW)); $this->setPostArray(array('EmailTemplate' => array('type' => EmailTemplate::TYPE_WORKFLOW, 'name' => 'New Test Workflow EmailTemplate', 'subject' => 'New Test Subject'))); $content = $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/create'); $this->assertTrue(strpos($content, 'Create Email Template') !== false); $this->assertFalse(strpos($content, '<select name="EmailTemplate[type]" id="EmailTemplate_type">') !== false); $this->assertTrue(strpos($content, '<select name="EmailTemplate[modelClassName]" id="EmailTemplate_modelClassName_value"') !== false); $this->assertTrue(strpos($content, 'Please provide at least one of the contents field.') !== false); $this->assertTrue(strpos($content, 'Module cannot be blank.') !== false); // Create a new emailTemplate and test merge tags validator. $this->setPostArray(array('EmailTemplate' => array('type' => EmailTemplate::TYPE_WORKFLOW, 'modelClassName' => 'Meeting', 'name' => 'New Test Workflow EmailTemplate', 'subject' => 'New Test Subject', 'textContent' => 'This is text content [[INVALID^TAG]]', 'htmlContent' => 'This is Html content [[INVALIDTAG]]'))); $content = $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/create'); $this->assertTrue(strpos($content, 'Create Email Template') !== false); $this->assertFalse(strpos($content, '<select name="EmailTemplate[type]" id="EmailTemplate_type">') !== false); $this->assertTrue(strpos($content, '<select name="EmailTemplate[modelClassName]" id="EmailTemplate_modelClassName_value">') !== false); $this->assertTrue(strpos($content, '<option value="Meeting" selected="selected">Meetings</option>') !== false); $this->assertTrue(strpos($content, 'INVALID^TAG') !== false); $this->assertTrue(strpos($content, 'INVALIDTAG') !== false); $this->assertEquals(2, substr_count($content, 'INVALID^TAG')); $this->assertEquals(2, substr_count($content, 'INVALIDTAG')); // Create a new emailTemplate and save it. $this->setPostArray(array('EmailTemplate' => array('type' => EmailTemplate::TYPE_WORKFLOW, 'name' => 'New Test Workflow EmailTemplate', 'modelClassName' => 'Contact', 'subject' => 'New Test Subject [[FIRST^NAME]]', 'textContent' => 'New Text Content [[FIRST^NAME]]'))); $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/create'); $emailTemplateId = self::getModelIdByModelNameAndName('EmailTemplate', 'New Test Workflow EmailTemplate'); $emailTemplate = EmailTemplate::getById($emailTemplateId); $this->assertTrue($emailTemplate->id > 0); $this->assertEquals('New Test Subject [[FIRST^NAME]]', $emailTemplate->subject); $this->assertEquals('New Text Content [[FIRST^NAME]]', $emailTemplate->textContent); $this->assertTrue($emailTemplate->owner == $this->user); $compareRedirectUrl = Yii::app()->createUrl('emailTemplates/default/details', array('id' => $emailTemplate->id)); $this->assertEquals($compareRedirectUrl, $redirectUrl); $emailTemplates = EmailTemplate::getAll(); $this->assertEquals(1, count($emailTemplates)); }
public function testDeleteEmailTemplate() { $emailTemplates = EmailTemplate::getAll(); $this->assertEquals(3, count($emailTemplates)); $emailTemplates[0]->delete(); $emailTemplates = EmailTemplate::getAll(); $this->assertEquals(2, count($emailTemplates)); }
/** * @depends testSuperUserDetailsActionForMarketing */ public function testSuperUserDeleteAction() { $emailTemplateId = self::getModelIdByModelNameAndName('EmailTemplate', 'New Test Email Template 00'); // Delete an emailTemplate. $this->setGetArray(array('id' => $emailTemplateId)); $this->resetPostArray(); $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/delete'); $compareRedirectUrl = Yii::app()->createUrl('emailTemplates/default/listForMarketing'); $this->assertEquals($compareRedirectUrl, $redirectUrl); $emailTemplates = EmailTemplate::getAll(); $this->assertEquals(3, count($emailTemplates)); $emailTemplateId = self::getModelIdByModelNameAndName('EmailTemplate', 'New Test Workflow Email Template 00'); $this->setGetArray(array('id' => $emailTemplateId)); $this->resetPostArray(); $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/delete'); $compareRedirectUrl = Yii::app()->createUrl('emailTemplates/default/listForWorkflow'); $this->assertEquals($compareRedirectUrl, $redirectUrl); $emailTemplates = EmailTemplate::getAll(); $this->assertEquals(2, count($emailTemplates)); }
} */ use_class('EmailTemplate'); $languages = getLanguages(); if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'LOADTABLELIST') { $header = array(); $header['w040 a'] = 'No'; $header['w250 b'] = 'Template Name'; $header['w400 c'] = 'Template Info'; $header['w080 f'] = 'Active<br />Status'; // $header['w400 d'] = 'Technical Info'; $header['w200 e'] = 'Languages<br />(click to preview)'; $tablelist_data = array(); $tablelist_data[] = $header; $data_ids = EmailTemplate::getAll(); if (count($data_ids) == 0) { $tablelist = '<h3 class="red">No templates found in database</h3>'; } else { $data_counter = 0; foreach ($data_ids as $id) { $data_counter++; $obj = new EmailTemplate($id); $row = array(); foreach ($header as $hk => $hv) { list($class_width, $class_key) = explode(' ', $hk); $class_align = ''; switch ($class_key) { case 'a': $class_align = 'tac'; $value = $data_counter;