public function testSuperUserAllDefaultControllerActions() { // key used to test persistance of user settings $configKey = 'rollup'; //Set the current user as the super user. $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $accounts = Account::getAll(); $this->assertEquals(1, count($accounts)); $superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount'); //Load Details view to generate the portlets. $this->setGetArray(array('id' => $superAccountId)); $this->resetPostArray(); $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details'); //Find the LatestActivity portlet. $portletToUse = null; $portlets = Portlet::getAll(); foreach ($portlets as $portlet) { if ($portlet->viewType == 'AccountLatestActivitiesForPortlet') { $portletToUse = $portlet; break; } } $this->assertNotNull($portletToUse); $this->assertEquals('AccountLatestActivitiesForPortletView', get_class($portletToUse->getView())); //Load the portlet details for latest activity $getData = array('id' => $superAccountId, 'portletId' => $portletToUse->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portletToUse->id, 'LatestActivitiesConfigurationForm' => array('filteredByModelName' => 'all', 'rollup' => '')); $this->setGetArray($getData); $this->resetPostArray(); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($getData['portletId'], $configKey) === ''); //Now add roll up $getData['LatestActivitiesConfigurationForm']['rollup'] = '1'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($getData['portletId'], $configKey) === '1'); //Now filter by meeting, task, and note $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Meeting'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Note'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Task'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); //Now do the same thing with filtering but turn off rollup. $getData['LatestActivitiesConfigurationForm']['rollup'] = ''; $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Meeting'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $this->assertTrue(LatestActivitiesPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($getData['portletId'], $configKey) === ''); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Note'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Task'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); }
public function testDashboardGroupByActions() { $portets = Portlet::getAll(); $this->assertCount(1, $portets); $this->setGetArray(array('portletId' => $portets[0]->id, 'uniqueLayoutId' => 'MarketingDashboard')); $this->setPostArray(array('MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_DAY))); $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave'); $this->setPostArray(array('MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_MONTH))); $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave'); $this->setPostArray(array('MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_WEEK))); $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave'); }
public function testMarketingListDashboardGroupByActions() { $portlets = Portlet::getAll(); foreach ($portlets as $portlet) { if ($portlet->viewType = 'MarketingListOverallMetrics') { $marketingListPortlet = $portlet; } } $marketingLists = MarketingList::getAll(); $this->setGetArray(array('portletId' => $portlet->id, 'uniqueLayoutId' => 'MarketingListDetailsAndRelationsViewLeftBottomView', 'portletParams' => array('relationModelId' => $marketingLists[0]->id, 'relationModuleId' => 'marketingLists'))); $this->setPostArray(array('MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_DAY))); $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave'); $this->setPostArray(array('MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_MONTH))); $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave'); $this->setPostArray(array('MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_WEEK))); $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave'); }
/** * @depends testUserEditAndDeletePermissions */ public function testDetailViewPortletFilteringOnConversations() { if (!SECURITY_OPTIMIZED) { return; } $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $accounts = Account::getByName('superAccount'); $superAccountId = $accounts[0]->id; //Load Details view to generate the portlets. $this->setGetArray(array('id' => $superAccountId)); $this->resetPostArray(); $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details'); //Find the LatestActivity portlet. $portletToUse = null; $portlets = Portlet::getAll(); foreach ($portlets as $portlet) { if ($portlet->viewType == 'AccountLatestActivitiesForPortlet') { $portletToUse = $portlet; break; } } $this->assertNotNull($portletToUse); $this->assertEquals('AccountLatestActivitiesForPortletView', get_class($portletToUse->getView())); //Load the portlet details for latest activity $getData = array('id' => $superAccountId, 'portletId' => $portletToUse->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_2', 'LatestActivitiesConfigurationForm' => array('filteredByModelName' => 'all', 'rollup' => false)); $this->setGetArray($getData); $this->resetPostArray(); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); //Now add roll up $getData['LatestActivitiesConfigurationForm']['rollup'] = true; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); //Now filter by conversation $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Conversation'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); //Now do the same thing with filtering but turn off rollup. $getData['LatestActivitiesConfigurationForm']['rollup'] = true; $getData['LatestActivitiesConfigurationForm']['filteredByModelName'] = 'Conversation'; $this->setGetArray($getData); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/details'); }
/** * testGetRowsByUserId */ public function testDeleteDashboardAndRelatedPortlets() { Yii::app()->user->userModel = User::getByUsername('billy'); $dashboardCount = count(Dashboard::getAll()); $this->assertTrue($dashboardCount > 0); $user = User::getByUserName('billy'); Yii::app()->user->userModel = $user; $dashboard = new Dashboard(); $dashboard->name = "Dashboard TESTING"; $dashboard->layoutId = 3; $dashboard->owner = $user; $dashboard->layoutType = '100'; $dashboard->isDefault = false; $this->assertTrue($dashboard->save()); $this->assertEquals(count(Portlet::getAll()), 0); $this->assertEquals(count(Dashboard::getAll()), $dashboardCount + 1); for ($i = 1; $i <= 3; $i++) { $portlet = new Portlet(); $portlet->column = 1; $portlet->position = 1 + $i; $portlet->layoutId = 'TEST' . $dashboard->layoutId; $portlet->collapsed = false; $portlet->viewType = 'TasksMyList'; $portlet->user = $user; $this->assertTrue($portlet->save()); } $this->assertEquals(count(Portlet::getAll()), 3); $portlets = Portlet::getByLayoutIdAndUserSortedById('TEST' . $dashboard->layoutId, $user->id); foreach ($portlets as $portlet) { $portlet->delete(); } $dashboard->delete(); $this->assertEquals(count(Portlet::getAll()), 0); $this->assertEquals(count(Dashboard::getAll()), $dashboardCount); }