public function setUp() { parent::setUp(); $this->user = User::getByUsername('super'); Yii::app()->user->userModel = $this->user; Campaign::deleteAll(); CampaignItem::deleteAll(); Contact::deleteAll(); MarketingList::deleteAll(); }
/** * @depends testGetByProcessed */ public function testGetByProcessedAndCampaignId() { CampaignItem::deleteAll(); $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 03'); $this->assertNotNull($marketingList); $campaign1 = CampaignTestHelper::createCampaign('campaign 01', 'subject 01', 'text 01', 'html 01', null, null, null, null, null, null, $marketingList); $this->assertNotNull($campaign1); $campaign2 = CampaignTestHelper::createCampaign('campaign 02', 'subject 02', 'text 02', 'html 02', null, null, null, null, null, null, $marketingList); $this->assertNotNull($campaign2); for ($i = 0; $i < 10; $i++) { $contact = ContactTestHelper::createContactByNameForOwner('contact 0' . $i, Yii::app()->user->userModel); $this->assertNotNull($contact); if ($i % 3) { $processed = 1; } else { $processed = 0; } if ($i % 2) { $campaign = $campaign1; } else { $campaign = $campaign2; } $campaignItem = CampaignItemTestHelper::createCampaignItem($processed, $campaign); $this->assertNotNull($campaignItem); } $campaignItems = CampaignItem::getAll(); $this->assertNotEmpty($campaignItems); $this->assertCount(10, $campaignItems); $campaign1Processed = CampaignItem::getByProcessedAndCampaignId(1, $campaign1->id); $this->assertNotEmpty($campaign1Processed); $this->assertCount(3, $campaign1Processed); $campaign1NotProcessed = CampaignItem::getByProcessedAndCampaignId(0, $campaign1->id); $this->assertNotEmpty($campaign1NotProcessed); $this->assertCount(2, $campaign1NotProcessed); $campaign2Processed = CampaignItem::getByProcessedAndCampaignId(1, $campaign2->id); $this->assertNotEmpty($campaign2Processed); $this->assertCount(3, $campaign2Processed); $campaign2NotProcessed = CampaignItem::getByProcessedAndCampaignId(0, $campaign2->id); $this->assertNotEmpty($campaign2NotProcessed); $this->assertCount(2, $campaign2NotProcessed); }