Пример #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);
 }
Пример #2
0
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testRequiredAttributes()
 {
     $autoresponder = new Autoresponder();
     $this->assertFalse($autoresponder->save());
     $errors = $autoresponder->getErrors();
     $this->assertNotEmpty($errors);
     $this->assertCount(5, $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('fromOperationDurationInterval', $errors);
     $this->assertEquals('Send After cannot be blank.', $errors['fromOperationDurationInterval'][0]);
     $this->assertArrayHasKey('fromOperationDurationType', $errors);
     $this->assertEquals('From Operation Duration Type cannot be blank.', $errors['fromOperationDurationType'][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->fromOperationDurationInterval = '1';
     $autoresponder->fromOperationDurationType = TimeDurationUtil::DURATION_TYPE_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('1', $autoresponder->fromOperationDurationInterval);
     $this->assertEquals(TimeDurationUtil::DURATION_TYPE_MONTH, $autoresponder->fromOperationDurationType);
     $this->assertEquals(Autoresponder::OPERATION_UNSUBSCRIBE, $autoresponder->operationType);
     $this->assertEquals(1, $autoresponder->enableTracking);
 }
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty()
 {
     $autoresponder = new Autoresponder();
     $autoresponder->subject = 'Another Test subject';
     $autoresponder->textContent = '';
     $autoresponder->htmlContent = "<html>\n<head>\n</head>\n<body>\n</body>\n</html>";
     $autoresponder->fromOperationDurationInterval = '1';
     $autoresponder->fromOperationDurationType = TimeDurationUtil::DURATION_TYPE_MONTH;
     $autoresponder->operationType = Autoresponder::OPERATION_UNSUBSCRIBE;
     $autoresponder->enableTracking = 1;
     $this->assertFalse($autoresponder->save());
     $errorMessages = $autoresponder->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]);
     $autoresponder->textContent = 'Text Content';
     $this->assertTrue($autoresponder->save());
     $this->assertEquals(3, Autoresponder::getCount());
     $id = $autoresponder->id;
     unset($autoresponder);
     $autoresponder = Autoresponder::getById($id);
     $this->assertEquals('Another Test subject', $autoresponder->subject);
     $this->assertEquals(null, $autoresponder->htmlContent);
     $this->assertEquals('Text Content', $autoresponder->textContent);
     $this->assertEquals('1', $autoresponder->fromOperationDurationInterval);
     $this->assertEquals(TimeDurationUtil::DURATION_TYPE_MONTH, $autoresponder->fromOperationDurationType);
     $this->assertEquals(Autoresponder::OPERATION_UNSUBSCRIBE, $autoresponder->operationType);
     $this->assertEquals(1, $autoresponder->enableTracking);
 }