public function testPackageContainsSendables() { $this->createEmailAndAddToPackage(); $this->assertCount(1, $this->package->getSendables(), "The sendable wasn't correctly added to the list"); $this->createEmailAndAddToPackage(); $this->assertCount(2, $this->package->getSendables(), "The sendable wasn't correctly added to the list"); }
public static function draftPackage(CommunicationPackage $package) { $communication = SolutionSchema::getModel("Communication"); $communication->Title = $package->title; if ($package->dateToSend) { $communication->DateToSend = $package->dateToSend; } $communication->save(); foreach ($package->getSendables() as $sendable) { foreach ($sendable->getRecipients() as $recipient) { $clone = clone $sendable; $clone->clearRecipients(); $clone->addRecipient($recipient); $item = SolutionSchema::getModel("CommunicationItem"); $item->Recipient = (string) $recipient; $item->Text = $clone->getText(); $item->Type = $clone->getSendableType(); $item->SendableClassName = get_class($clone); $item->Data = $clone->toArray(); $item->CommunicationID = $communication->CommunicationID; $item->save(); } } return $communication; }