コード例 #1
0
ファイル: AutoresponderTest.php プロジェクト: youprofit/Zurmo
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testRequiredAttributes()
 {
     $intervalArray = array_flip(Autoresponder::getIntervalDropDownArray());
     $autoresponder = new Autoresponder();
     $this->assertFalse($autoresponder->unrestrictedSave());
     $errors = $autoresponder->getErrors();
     $this->assertNotEmpty($errors);
     $this->assertCount(5, $errors);
     $this->assertArrayHasKey('name', $errors);
     $this->assertEquals('Name cannot be blank.', $errors['name'][0]);
     $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('Seconds From Operation cannot be blank.', $errors['secondsFromOperation'][0]);
     $this->assertArrayHasKey('operationType', $errors);
     $this->assertEquals('Operation Type cannot be blank.', $errors['operationType'][0]);
     $autoresponder->name = 'Test Autoresponder name 02';
     $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;
     $this->assertTrue($autoresponder->unrestrictedSave());
     $id = $autoresponder->id;
     unset($autoresponder);
     $autoresponder = Autoresponder::getById($id);
     $this->assertEquals('Test Autoresponder name 02', $autoresponder->name);
     $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);
 }