public function testCreateAndGetMarketingListMemberById() { $marketingList = RandomDataUtil::getRandomValueFromArray(MarketingList::getAll()); $this->assertNotNull($marketingList); $contact = RandomDataUtil::getRandomValueFromArray(Contact::getAll()); $this->assertNotNull($contact); $marketingListMember = new MarketingListMember(); $marketingListMember->unsubscribed = 0; $marketingListMember->marketingList = $marketingList; $marketingListMember->contact = $contact; $this->assertTrue($marketingListMember->unrestrictedSave()); $id = $marketingListMember->id; $this->assertTrue($id > 0); unset($marketingListMember); $marketingListMember = MarketingListMember::getById($id); $this->assertEquals(0, $marketingListMember->unsubscribed); $this->assertEquals($contact, $marketingListMember->contact); $this->assertEquals($marketingList, $marketingListMember->marketingList); }
public function testToggleUnsubscribed() { $marketingList = MarketingListTestHelper::createMarketingListByName('MarketingList4', 'MarketingList Description4'); $this->assertNotNull($marketingList); $contact = RandomDataUtil::getRandomValueFromArray(Contact::getAll()); $this->assertNotEmpty($contact); $previousUnsubcribedValue = 1; $marketingListMember = MarketingListMemberTestHelper::createMarketingListMember($previousUnsubcribedValue, $marketingList, $contact); $marketingListMemberId = $marketingListMember->id; $this->assertNotNull($marketingListMember); $this->setGetArray(array('id' => $marketingListMemberId)); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/toggleUnsubscribed', true); $this->assertEmpty($content); $marketingListMember = MarketingListMember::getById($marketingListMemberId); $newUnsubscribedValue = $marketingListMember->unsubscribed; $this->assertNotEquals($previousUnsubcribedValue, $newUnsubscribedValue); }
public function testMassUnsubscribeAllSelectedFromMemberController() { static::$marketingListMember->unsubscribed = 0; static::$marketingListMember->setScenario(MarketingListMember::SCENARIO_MANUAL_CHANGE); static::$marketingListMember->unrestrictedSave(); $marketingListMemberId = static::$marketingListMember->id; static::$marketingListMember->forgetAll(); static::$marketingListMember = MarketingListMember::getById($marketingListMemberId); $this->assertEquals(0, static::$marketingListMember->unsubscribed); $unsubscribedCount = MarketingListMember::getCountByMarketingListIdAndUnsubscribed(static::$marketingList->id, 1); $this->setGetArray(array('selectAll' => '1', 'MarketingListMembersPortletView_page' => 1, 'id' => static::$marketingListMember->id)); $this->setPostArray(array('selectedRecordCount' => MarketingListMember::getCount())); // Run Mass Unsubscribe $pageSize = Yii::app()->pagination->getForCurrentUserByType('massEditProgressPageSize'); $this->assertEquals(5, $pageSize); $this->runControllerWithRedirectExceptionAndGetUrl($this->marketingMassUnsubscribeUrl); $expectedUnsubscribedCountAfterFirstRequest = $unsubscribedCount + 1; $actualUnsubscribedCountAfterFirstRequest = MarketingListMember::getCountByMarketingListIdAndUnsubscribed(static::$marketingList->id, 1); $this->assertEquals($expectedUnsubscribedCountAfterFirstRequest, $actualUnsubscribedCountAfterFirstRequest); }