Пример #1
0
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testRequiredAttributes()
 {
     $intervalArray = array_flip(Autoresponder::getIntervalDropDownArray());
     $autoresponder = new Autoresponder();
     $this->assertFalse($autoresponder->save());
     $errors = $autoresponder->getErrors();
     $this->assertNotEmpty($errors);
     $this->assertCount(4, $errors);
     $this->assertArrayHasKey('subject', $errors);
     $this->assertEquals('Subject cannot be blank.', $errors['subject'][0]);
     $this->assertArrayHasKey('textContent', $errors);
     $this->assertEquals('Please provide at least one of the contents field.', $errors['textContent'][0]);
     $this->assertArrayHasKey('secondsFromOperation', $errors);
     $this->assertEquals('Send After cannot be blank.', $errors['secondsFromOperation'][0]);
     $this->assertArrayHasKey('operationType', $errors);
     $this->assertEquals('Triggered By cannot be blank.', $errors['operationType'][0]);
     $autoresponder->subject = 'Test Autoresponder subject 02';
     $autoresponder->htmlContent = 'Test HtmlContent 02';
     $autoresponder->textContent = 'Test TextContent 02';
     $autoresponder->secondsFromOperation = $intervalArray['1 month'];
     $autoresponder->operationType = Autoresponder::OPERATION_UNSUBSCRIBE;
     $autoresponder->enableTracking = 1;
     $this->assertTrue($autoresponder->save());
     $id = $autoresponder->id;
     unset($autoresponder);
     $autoresponder = Autoresponder::getById($id);
     $this->assertEquals('Test Autoresponder subject 02', $autoresponder->subject);
     $this->assertEquals('Test HtmlContent 02', $autoresponder->htmlContent);
     $this->assertEquals('Test TextContent 02', $autoresponder->textContent);
     $this->assertEquals($intervalArray['1 month'], $autoresponder->secondsFromOperation);
     $this->assertEquals(Autoresponder::OPERATION_UNSUBSCRIBE, $autoresponder->operationType);
     $this->assertEquals(1, $autoresponder->enableTracking);
 }
 protected static function renderExtraInfoContent(Autoresponder $autoresponder)
 {
     $operationValuesAndLabels = Autoresponder::getOperationTypeDropDownArray();
     if (!isset($operationValuesAndLabels[$autoresponder->operationType])) {
         return;
     }
     $intervalValuesAndLabels = Autoresponder::getIntervalDropDownArray();
     if (!isset($intervalValuesAndLabels[$autoresponder->secondsFromOperation])) {
         return;
     }
     $content = null;
     $content .= Zurmo::t('AutorespondersModule', 'Send {timeFrame} after {operation}', array('{timeFrame}' => $intervalValuesAndLabels[$autoresponder->secondsFromOperation], '{operation}' => $operationValuesAndLabels[$autoresponder->operationType]));
     return $content;
 }
 protected function getDropDownArray()
 {
     return Autoresponder::getIntervalDropDownArray();
 }