public function __construct(array $jsonData)
 {
     foreach ($jsonData['MailingLists'] as $mailingList) {
         $entry = MailingList::withJSON($mailingList);
         $this->append($entry);
     }
 }
 /**
  * Test if MailingListDetailsAction returns a MailingList object when onParse is called.
  * @group MailingListDetailsActionTest
  * @covers moosend\Actions\MailingListDetails\MailingListDetailsAction::onParse
  */
 public function test_Should_Return_MailingList_Object_When_CreateMailingListAction_Calls_onParse_With_Success()
 {
     $jsonData = json_decode(file_get_contents(__DIR__ . '/../../JsonResponses/getMailingListDetailsJsonResponse.html'), true)['Context'];
     $returnedObject = $this->_action->onParse($jsonData);
     $expectedMailingListObject = MailingList::withJSON($jsonData);
     $this->assertEquals($expectedMailingListObject, $returnedObject);
 }
示例#3
0
 /**
  * Test custom "constructor" when providing valid JSON data.
  * @covers moosend\Models\Campaign::withJSON
  * @group CampaignTest
  */
 public function test_Can_Create_Campaign_Instance_When_Providing_Valid_Json_Data_To_Custom_Constructor()
 {
     $this->assertEquals('4824c0fb-c41c-4b09-a35d-03d4e6177630', $this->_campaign->getID());
     $this->assertEquals('Your Campaign Name', $this->_campaign->getName());
     $this->assertEquals('Your Campaign Subject', $this->_campaign->getSubject());
     $this->assertEquals('http://www.your-domain.com/newsletter', $this->_campaign->getWebLocation());
     $this->assertEquals('SOME HTML BODY', $this->_campaign->getHTMLContent());
     $this->assertEquals('Some plain text body', $this->_campaign->getPlainContent());
     $this->assertEquals(Sender::withJSON($this->_jsonData['Sender']), $this->_campaign->getSender());
     $this->assertEquals(null, $this->_campaign->getDeliveredOn());
     $this->assertEquals(Sender::withJSON($this->_jsonData['ReplyToEmail']), $this->_campaign->getReplyToEmail());
     $this->assertEquals('/Date(1368710321000+0300)/', $this->_campaign->getCreatedOn());
     $this->assertEquals('/Date(1368839678000+0300)/', $this->_campaign->getUpdatedOn());
     $this->assertEquals('/Date(1369017000000+0300)/', $this->_campaign->getScheduledFor());
     $this->assertEquals('GTB Standard Time', $this->_campaign->getTimezone());
     $this->assertEquals(0, $this->_campaign->getFormatType());
     $this->assertEquals(ABCampaignData::withJSON($this->_jsonData['ABCampaignData']), $this->_campaign->getABCampaignData());
     $this->assertEquals(MailingList::withJSON($this->_jsonData['MailingList']), $this->_campaign->getMailingList());
     $this->assertEquals('*****@*****.**', $this->_campaign->getConfirmationTo());
     $this->assertEquals(0, $this->_campaign->getStatus());
     $this->assertEquals(Segment::withJSON($this->_jsonData['Segment']), $this->_campaign->getSegment());
     $this->assertEquals(false, $this->_campaign->getIsTransactional());
     $this->assertInstanceOf('moosend\\Models\\Campaign', $this->_campaign);
 }
示例#4
0
 public function setUp()
 {
     $this->_jsonData = json_decode(file_get_contents(__DIR__ . '/../../tests/JsonResponses/getCampaignRawJsonResponse.html'), true)['Context']['MailingList'];
     $this->_mailingList = MailingList::withJSON($this->_jsonData);
 }
 public function onParse($jsonData)
 {
     return MailingList::withJSON($jsonData);
 }