public static function populateAutoresponderItem($processed, $processDateTime, $autoresponder = null, $contact = null)
 {
     assert('is_string($processed) || is_int($processed)');
     assert('is_string($processDateTime)');
     assert('is_object($autoresponder) || $autoresponder === null');
     assert('is_object($contact) || $contact === null');
     if (empty($autoresponder)) {
         $autoresponders = Autoresponder::getAll();
         if (!empty($autoresponders)) {
             $autoresponder = RandomDataUtil::getRandomValueFromArray($autoresponders);
         }
     }
     if (empty($contact)) {
         $contacts = Contact::getAll();
         if (!empty($contacts)) {
             $contact = RandomDataUtil::getRandomValueFromArray($contacts);
         }
     }
     $autoresponderItem = new AutoresponderItem();
     $autoresponderItem->processed = $processed;
     $autoresponderItem->processDateTime = $processDateTime;
     $autoresponderItem->autoresponder = $autoresponder;
     $autoresponderItem->contact = $contact;
     return $autoresponderItem;
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("Contact")');
     assert('$demoDataHelper->isSetRange("Autoresponder")');
     $items = array();
     if ($this->loadMagnitude >= 100) {
         foreach (Autoresponder::getAll() as $autoresponder) {
             foreach ($autoresponder->marketingList->marketingListMembers as $marketingListMember) {
                 $item = new AutoresponderItem();
                 $item->autoresponder = $autoresponder;
                 $item->contact = $marketingListMember->contact;
                 $this->populateModel($item);
                 $saved = $item->unrestrictedSave();
                 assert('$saved');
                 $items[] = $item->id;
             }
         }
     } else {
         for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
             $item = new AutoresponderItem();
             $item->autoresponder = $demoDataHelper->getRandomByModelName('Autoresponder');
             $item->contact = $demoDataHelper->getRandomByModelName('Contact');
             $this->populateModel($item);
             $saved = $item->unrestrictedSave();
             assert('$saved');
             $items[] = $item->id;
         }
     }
     $demoDataHelper->setRangeByModelName('AutoresponderItem', $items[0], $items[count($items) - 1]);
 }
 public static function fillAutoresponderItem($processed, $processDateTime, $autoresponder = null, $contact = null)
 {
     if (empty($autoresponder)) {
         $autoresponders = Autoresponder::getAll();
         if (!empty($autoresponders)) {
             $autoresponder = RandomDataUtil::getRandomValueFromArray($autoresponders);
         }
     }
     if (empty($contact)) {
         $contacts = Contact::getAll();
         if (!empty($contacts)) {
             $contact = RandomDataUtil::getRandomValueFromArray($contacts);
         }
     }
     $autoresponderItem = new AutoresponderItem();
     $autoresponderItem->processed = $processed;
     $autoresponderItem->processDateTime = $processDateTime;
     $autoresponderItem->autoresponder = $autoresponder;
     $autoresponderItem->contact = $contact;
     return $autoresponderItem;
 }
 /**
  * @depends testSuperUserCreateActionWithParameters
  */
 public function testSuperUserDeleteAction()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders);
     $this->assertCount(3, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $this->setGetArray(array('id' => $autoresponderId));
     $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/delete', true);
     $this->assertEmpty($content);
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders);
     $this->assertCount(2, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $redirectUrl = 'http://www.zurmo.com/';
     $this->setGetArray(array('id' => $autoresponderId, 'redirectUrl' => $redirectUrl));
     $resolvedRedirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/delete');
     $this->assertEquals($redirectUrl, $resolvedRedirectUrl);
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders);
     $this->assertCount(1, $autoresponders);
 }
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDeleteAutoresponder()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertCount(7, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $contact = ContactTestHelper::createContactByNameForOwner('autoresponderContact', Yii::app()->user->userModel);
     $saved = AutoresponderItem::addNewItem(0, $processDateTime, $contact, $autoresponders[0]);
     $this->assertTrue($saved);
     $autoresponderItems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     $this->assertNotEmpty($autoresponderItems);
     $this->assertCount(1, $autoresponderItems);
     $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf');
     $files = array();
     foreach ($fileNames as $index => $fileName) {
         $file = ZurmoTestHelper::createFileModel($fileName);
         $files[$index]['name'] = $fileName;
         $files[$index]['type'] = $file->type;
         $files[$index]['size'] = $file->size;
         $files[$index]['contents'] = $file->fileContent->content;
         $autoresponders[0]->files->add($file);
     }
     $this->assertTrue($autoresponders[0]->save());
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders[0]->files);
     $this->assertCount(count($files), $autoresponders[0]->files);
     $this->assertEquals(count($files), FileModel::getCount());
     $autoresponders[0]->delete();
     $autoresponders = Autoresponder::getAll();
     $this->assertEquals(6, count($autoresponders));
     $autoresponderitems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     $this->assertEquals(0, count($autoresponderitems));
     $this->assertEquals(0, FileModel::getCount());
 }
Esempio n. 6
0
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDeleteAutoresponder()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertCount(5, $autoresponders);
     $autoresponders[0]->delete();
     $autoresponders = Autoresponder::getAll();
     $this->assertEquals(4, count($autoresponders));
 }
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDeleteAutoresponder()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertCount(7, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $contact = ContactTestHelper::createContactByNameForOwner('autoresponderContact', Yii::app()->user->userModel);
     $saved = AutoresponderItem::addNewItem(0, $processDateTime, $contact, $autoresponders[0]);
     $this->assertTrue($saved);
     $autoresponderItems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     //print_r($autoresponderItems[0]->id);
     $this->assertNotEmpty($autoresponderItems);
     $this->assertCount(1, $autoresponderItems);
     $autoresponderItemActivity = new AutoresponderItemActivity();
     $autoresponderItemActivity->type = AutoresponderItemActivity::TYPE_OPEN;
     $autoresponderItemActivity->quantity = 10;
     $autoresponderItemActivity->latestSourceIP = '10.11.12.13';
     $autoresponderItemActivity->autoresponderItem = $autoresponderItems[0];
     $this->assertTrue($autoresponderItemActivity->save());
     //print_r($autoresponderItemActivity->id);
     $autoresponderItemActivities = AutoresponderItemActivity::getAll();
     $this->assertCount(1, $autoresponderItemActivities);
     $autoresponders[0]->delete();
     $autoresponders = Autoresponder::getAll();
     $this->assertEquals(6, count($autoresponders));
     $autoresponderitems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     $this->assertEquals(0, count($autoresponderitems));
     $autoresponderItemActivities = AutoresponderItemActivity::getAll();
     $this->assertCount(0, $autoresponderItemActivities);
 }