本文整理汇总了PHP中Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition方法的典型用法代码示例。如果您正苦于以下问题:PHP Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition方法的具体用法?PHP Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition怎么用?PHP Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portlet
的用法示例。
在下文中一共展示了Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAdditionOfPortletsInEmptyRightPanel
public function testAdditionOfPortletsInEmptyRightPanel()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$superLeadId = self::getModelIdByModelNameAndName('Contact', 'superLead superLeadson');
$marketingListId = self::getModelIdByModelNameAndName('MarketingList', 'MarketingListName');
$leads = Contact::getAll();
$this->assertEquals(1, count($leads));
//Load Model Detail Views
$this->setGetArray(array('id' => $superLeadId, 'lockPortlets' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('leads/default/details');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('LeadDetailsAndRelationsView', $super->id, array());
$this->assertEquals(3, count($portlets[1]));
$this->assertFalse(array_key_exists(3, $portlets));
$this->assertEquals(2, count($portlets[2]));
foreach ($portlets[2] as $position => $portlet) {
$portlet->delete();
}
$this->setGetArray(array('modelId' => $superLeadId, 'uniqueLayoutId' => 'LeadDetailsAndRelationsView', 'portletType' => 'MarketingListsForContactRelatedList', 'redirect' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('leads/defaultPortlet/add', true);
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('LeadDetailsAndRelationsView', $super->id, array());
$this->assertEquals(1, count($portlets[2]));
//Test subscribe to list link
$portlet = $portlets[2][1];
$this->setGetArray(array('portletId' => $portlet->id, 'relationAttributeName' => 'lead', 'relationModelId' => $superLeadId, 'relationModuleId' => 'leads', 'uniqueLayoutId' => $portlet->getUniquePortletPageId(), 'relationModelClassName' => null));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/selectFromRelatedList');
//Test subscribe a marketing list
$this->setGetArray(array('modelId' => $marketingListId, 'portletId' => $portlet->id, 'relationAttributeName' => 'lead', 'relationModelId' => $superLeadId, 'relationModuleId' => 'leads', 'uniqueLayoutId' => $portlet->getUniquePortletPageId(), 'relationModelClassName' => null));
$this->resetPostArray();
$content = $this->runControllerWithRedirectExceptionAndGetContent('marketingLists/defaultPortlet/selectFromRelatedListSave');
}
示例2: getPortlets
/**
* Override to allow for making a default set of portlets
* via metadata optional.
*
*/
protected function getPortlets($uniqueLayoutId, $metadata)
{
assert('is_string($uniqueLayoutId)');
assert('is_array($metadata)');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, $this->params);
if (empty($portlets) && $this->isDefaultDashboard) {
$portlets = Portlet::makePortletsUsingMetadataSortedByColumnIdAndPosition($uniqueLayoutId, $metadata, Yii::app()->user->userModel, $this->params);
Portlet::savePortlets($portlets);
}
return PortletsSecurityUtil::resolvePortletsForCurrentUser($portlets);
}
示例3: getPortlets
protected function getPortlets($uniqueLayoutId, $metadata)
{
assert('is_string($uniqueLayoutId)');
assert('is_array($metadata)');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, $this->params);
if (empty($portlets)) {
$portlets = Portlet::makePortletsUsingMetadataSortedByColumnIdAndPosition($uniqueLayoutId, $metadata, Yii::app()->user->userModel, $this->params);
Portlet::savePortlets($portlets);
}
return $portlets;
}
示例4: testSuperUserDefaultPortletControllerActions
public function testSuperUserDefaultPortletControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$this->setGetArray(array('id' => self::$account->id));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertEquals(4, count($portlets[2]));
$this->setGetArray(array('modelId' => self::$account->id, 'portletType' => 'AccountAccountAffiliationsRelatedList', 'uniqueLayoutId' => 'AccountDetailsAndRelationsView'));
$this->resetPostArray();
$this->runControllerWithRedirectExceptionAndGetContent('accounts/defaultPortlet/add');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertEquals(5, count($portlets[2]));
//Load Details View again to make sure everything is ok after the layout change.
$this->setGetArray(array('id' => self::$account->id));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:18,代码来源:AccountAccountAffiliationsSuperUserWalkthroughTest.php
示例5: actionAdd
/**
* Add portlet to first column, first position
* and if there are other portlets in the first
* column, shift their postion by 1 to accomodate
* the new portlet
*
*/
public function actionAdd()
{
assert('!empty($_GET["uniqueLayoutId"])');
assert('!empty($_GET["portletType"])');
$maximumColumns = $this->resolveMaximumColumnsByDashboardId();
$portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($_GET['uniqueLayoutId'], Yii::app()->user->userModel->id, array());
if (!empty($portletCollection)) {
if (isset($portletCollection[$maximumColumns])) {
foreach ($portletCollection[$maximumColumns] as $position => $portlet) {
$portlet->position = $portlet->position + 1;
$portlet->save();
}
}
}
if (!empty($_GET['dashboardId'])) {
$dashboardId = $_GET['dashboardId'];
} else {
$dashboardId = '';
}
Portlet::makePortletUsingViewType($_GET['portletType'], $_GET['uniqueLayoutId'], Yii::app()->user->userModel, $maximumColumns);
$this->redirect(array('default/dashboardDetails', 'id' => $dashboardId));
}
示例6: testAdditionOfPortletsInEmptyRightPanel
public function testAdditionOfPortletsInEmptyRightPanel()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
$accounts = Account::getAll();
$this->assertEquals(1, count($accounts));
//Load Model Detail Views
$this->setGetArray(array('id' => $superAccountId, 'lockPortlets' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertEquals(3, count($portlets[1]));
$this->assertFalse(array_key_exists(3, $portlets));
$this->assertEquals(4, count($portlets[2]));
foreach ($portlets[2] as $position => $portlet) {
$portlet->delete();
}
$this->setGetArray(array('modelId' => $superAccountId, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView', 'portletType' => 'ProductsForAccountRelatedList', 'redirect' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/add', true);
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertEquals(1, count($portlets[2]));
}
示例7: testSuperUserDefaultPortletControllerActions
/**
* @depends testSuperUserAllDefaultControllerActions
*/
public function testSuperUserDefaultPortletControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Save a layout change. Collapse all portlets in the GameReward Details View.
//At this point portlets for this view should be created because we have already loaded the 'details' page in a request above.
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('GameRewardDetailsAndRelationsView', $super->id, array());
$this->assertEquals(2, count($portlets[1]));
$this->assertFalse(array_key_exists(2, $portlets));
$portletPostData = array();
$portletCount = 0;
foreach ($portlets as $column => $columnPortlets) {
foreach ($columnPortlets as $position => $portlet) {
$this->assertEquals('0', $portlet->collapsed);
$portletPostData['GameRewardDetailsAndRelationsView_' . $portlet->id] = array('collapsed' => 'true', 'column' => 0, 'id' => 'GameRewardDetailsAndRelationsView_' . $portlet->id, 'position' => $portletCount);
$portletCount++;
}
}
//There should have been a total of 2 portlets.
$this->assertEquals(2, $portletCount);
}
示例8: testSuperUserDefaultPortletControllerActions
/**
* @depends testSuperUserAllDefaultControllerActions
*/
public function testSuperUserDefaultPortletControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$superLeadId4 = self::getModelIdByModelNameAndName('Contact', 'superLead4 superLead4son');
//Save a layout change. Collapse all portlets in the Lead Details View.
//At this point portlets for this view should be created because we have already loaded the 'details' page in a request above.
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('LeadDetailsAndRelationsView', $super->id, array());
$this->assertEquals(3, count($portlets[1]));
$this->assertFalse(array_key_exists(3, $portlets));
$portletPostData = array();
$portletCount = 0;
foreach ($portlets as $column => $columnPortlets) {
foreach ($columnPortlets as $position => $portlet) {
$this->assertEquals('0', $portlet->collapsed);
$portletPostData['LeadDetailsAndRelationsView_' . $portlet->id] = array('collapsed' => 'true', 'column' => 0, 'id' => 'LeadDetailsAndRelationsView_' . $portlet->id, 'position' => $portletCount);
$portletCount++;
}
}
//There should have been a total of 5 portlets.
$this->assertEquals(5, $portletCount);
$this->resetGetArray();
$this->setPostArray(array('portletLayoutConfiguration' => array('portlets' => $portletPostData, 'uniqueLayoutId' => 'LeadDetailsAndRelationsView')));
$this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/saveLayout', true);
//Now test that all the portlets are collapsed and moved to the first column.
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('LeadDetailsAndRelationsView', $super->id, array());
$this->assertEquals(5, count($portlets[1]));
$this->assertFalse(array_key_exists(2, $portlets));
foreach ($portlets as $column => $columns) {
foreach ($columns as $position => $positionPortlets) {
$this->assertEquals('1', $positionPortlets->collapsed);
}
}
//Load Details View again to make sure everything is ok after the layout change.
$this->setGetArray(array('id' => $superLeadId4));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('leads/default/details');
}
示例9: resetPortletsInColumnToAccomodateNewPortlet
/**
* Reset portlet positions when a new portlet is added on the detail view
* @param int $maximumColumns
*/
private function resetPortletsInColumnToAccomodateNewPortlet($maximumColumns)
{
$portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($_GET['uniqueLayoutId'], Yii::app()->user->userModel->id, array());
$maximumIndexFromCollection = max(array_keys($portletCollection));
$maximumIterativeIndex = min($maximumIndexFromCollection, $maximumColumns);
if (!empty($portletCollection)) {
if ($maximumIterativeIndex > 1) {
foreach ($portletCollection[$maximumIterativeIndex] as $position => $portlet) {
$portlet->position = $portlet->position + 1;
$portlet->save();
}
}
}
}
示例10: testShiftPositionsBasedOnColumnReduction
public function testShiftPositionsBasedOnColumnReduction()
{
$user = User::getByUserName('billy');
for ($i = 1; $i <= 3; $i++) {
$portlet = new Portlet();
$portlet->column = 1;
$portlet->position = $i;
$portlet->layoutId = 'shiftTest';
$portlet->collapsed = true;
$portlet->viewType = 'RssReader';
$portlet->user = $user;
$this->assertTrue($portlet->save());
}
for ($i = 1; $i <= 5; $i++) {
$portlet = new Portlet();
$portlet->column = 2;
$portlet->position = $i;
$portlet->layoutId = 'shiftTest';
$portlet->collapsed = true;
$portlet->viewType = 'RssReader';
$portlet->user = $user;
$this->assertTrue($portlet->save());
}
for ($i = 1; $i <= 4; $i++) {
$portlet = new Portlet();
$portlet->column = 3;
$portlet->position = $i;
$portlet->layoutId = 'shiftTest';
$portlet->collapsed = true;
$portlet->viewType = 'RssReader';
$portlet->user = $user;
$this->assertTrue($portlet->save());
}
$this->assertEquals(count(Portlet::getByLayoutIdAndUserSortedById('shiftTest', $user->id)), 12);
$portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('shiftTest', $user->id, array());
Portlet::shiftPositionsBasedOnColumnReduction($portletCollection, 2);
$portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('shiftTest', $user->id, array());
$this->assertEquals(count($portletCollection), 2);
$this->assertEquals(count($portletCollection[1]), 7);
Portlet::shiftPositionsBasedOnColumnReduction($portletCollection, 1);
$portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('shiftTest', $user->id, array());
$this->assertEquals(count($portletCollection), 1);
$this->assertEquals(count($portletCollection[1]), 12);
}
示例11: testAddProductsMyListPortletToDashboard
public function testAddProductsMyListPortletToDashboard()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$superDashboard1 = Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
//load details view
$this->setGetArray(array('id' => $superDashboard1->id));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('home/default/dashboardDetails');
//Portlet Controller Actions
$uniqueLayoutId = 'HomeDashboard' . $superDashboard1->layoutId;
$this->setGetArray(array('dashboardId' => $superDashboard1->id, 'uniqueLayoutId' => $uniqueLayoutId));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/addList');
//Add ProductsMyList Portlet to dashboard
$this->setGetArray(array('dashboardId' => $superDashboard1->id, 'portletType' => 'ProductsMyList', 'uniqueLayoutId' => $uniqueLayoutId));
$this->resetPostArray();
$this->runControllerWithRedirectExceptionAndGetContent('home/defaultPortlet/add');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, $super->id, array());
$this->assertEquals(9, count($portlets[1]));
$this->assertEquals(2, count($portlets[2]));
$portletPostData = array();
$portletCount = 0;
foreach ($portlets as $column => $columnPortlets) {
foreach ($columnPortlets as $position => $portlet) {
$portletPostData['HomeDashboard1_' . $portlet->id] = array('collapsed' => 'true', 'column' => 0, 'id' => 'HomeDashboard1_' . $portlet->id, 'position' => $portletCount);
$portletCount++;
}
}
$this->assertEquals(11, $portletCount);
$this->resetGetArray();
$this->setPostArray(array('portletLayoutConfiguration' => array('portlets' => $portletPostData, 'uniqueLayoutId' => $uniqueLayoutId)));
$this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/saveLayout', true);
//load details view
$this->setGetArray(array('id' => $superDashboard1->id));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('home/default/dashboardDetails');
}
示例12: actionEditDashboard
/**
* Only supports saving 4 layoutTypes (max 2 column)
*
*/
public function actionEditDashboard($id)
{
$id = intval($id);
$dashboard = Dashboard::getById(intval($id));
ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($dashboard);
if (isset($_POST['Dashboard'])) {
$oldLayoutType = $dashboard->layoutType;
$_POST['Dashboard'] = PostUtil::sanitizePostByDesignerTypeForSavingModel($dashboard, $_POST['Dashboard']);
$dashboard->setAttributes($_POST['Dashboard']);
assert('in_array($dashboard->layoutType, array_keys(Dashboard::getLayoutTypesData()))');
if ($dashboard->save()) {
if ($oldLayoutType != $dashboard->layoutType && $dashboard->layoutType == '100') {
$uniqueLayoutId = 'HomeDashboard' . $dashboard->layoutId;
$portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, array());
Portlet::shiftPositionsBasedOnColumnReduction($portletCollection, 1);
}
GeneralCache::forgetAll();
//Ensure menu refreshes
$this->redirect(array('default/dashboardDetails', 'id' => $dashboard->id));
}
}
$editView = new DashboardEditView($this->getId(), $this->getModule()->getId(), $dashboard, strval($dashboard));
$view = new AccountsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editView));
echo $view->render();
}
示例13: testAddingMapPortletToAccountsDetailView
public function testAddingMapPortletToAccountsDetailView()
{
//Lougout previous use and log in as super user
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Retriving the super account id.
$superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
//Create address array for the super account id.
$address = array('street1' => '123 Knob Street', 'street2' => 'Apartment 4b', 'city' => 'Chicago', 'state' => 'Illinois', 'postalCode' => '60606', 'country' => 'USA');
//Assign Address to the super user account.
AddressGeoCodeTestHelper::updateTestAccountsWithBillingAddress($superAccountId, $address, $super);
//Fetch Latitute and Longitude values for address and save in Address.
AddressMappingUtil::updateChangedAddresses();
$accounts = Account::getByName('superAccount');
$this->assertEquals(1, count($accounts));
$this->assertEquals(round('41.8817767', 4), round($accounts[0]->billingAddress->latitude, 4));
$this->assertEquals(round('-87.6371461', 4), round($accounts[0]->billingAddress->longitude, 4));
$this->assertEquals(0, $accounts[0]->billingAddress->invalid);
$addressString = $accounts[0]->billingAddress->makeAddress();
$this->setGetArray(array('addressString' => $addressString, 'latitude' => $accounts[0]->billingAddress->latitude, 'longitude' => $accounts[0]->billingAddress->longitude));
$content = $this->runControllerWithNoExceptionsAndGetContent('maps/default/mapAndPoint');
$this->assertContains('plotMap', $content);
$accounts = Account::getAll();
$this->assertEquals(1, count($accounts));
//Load Model Detail Views
$this->setGetArray(array('id' => $superAccountId, 'lockPortlets' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertEquals(3, count($portlets[1]));
$this->assertFalse(array_key_exists(3, $portlets));
$this->assertEquals(4, count($portlets[2]));
foreach ($portlets[2] as $position => $portlet) {
$portlet->delete();
}
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertFalse(array_key_exists(2, $portlets));
$this->setGetArray(array('modelId' => $superAccountId, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView', 'portletType' => 'MapForAccountAddress', 'redirect' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/add', true);
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition('AccountDetailsAndRelationsView', $super->id, array());
$this->assertEquals(1, count($portlets[2]));
//Load Model Detail Views
$this->setGetArray(array('id' => $superAccountId, 'lockPortlets' => '0'));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
}
示例14: testSuperUserAllDefaultControllerActions
public function testSuperUserAllDefaultControllerActions()
{
//Set the current user as the super user.
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Test all default controller actions that do not require any POST/GET variables to be passed.
//This does not include portlet controller actions.
$this->runControllerWithNoExceptionsAndGetContent('home/default');
$this->runControllerWithNoExceptionsAndGetContent('home/default/index');
$this->runControllerWithNoExceptionsAndGetContent('home/default/createDashboard');
//Default Controller actions requiring some sort of parameter via POST or GET
//Load Model Edit Views
$superDashboard = Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
$this->setGetArray(array('id' => $superDashboard->id));
$this->runControllerWithNoExceptionsAndGetContent('home/default/editDashboard');
//Save dashboard.
$superDashboard = Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
$this->assertEquals('Dashboard', $superDashboard->name);
$this->setPostArray(array('Dashboard' => array('name' => '456765421')));
$this->runControllerWithRedirectExceptionAndGetContent('home/default/editDashboard');
$superDashboard = Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
$this->assertEquals('456765421', $superDashboard->name);
//Test having a failed validation on the dashboard during save.
$this->setGetArray(array('id' => $superDashboard->id));
$this->setPostArray(array('Dashboard' => array('name' => '')));
$content = $this->runControllerWithNoExceptionsAndGetContent('home/default/editDashboard');
$this->assertFalse(strpos($content, 'Name cannot be blank') === false);
//Load Model Detail Views
$this->setGetArray(array('id' => -1));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('home/default/dashboardDetails');
$this->setGetArray(array('id' => $superDashboard->id));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('home/default/dashboardDetails');
//Add second dashboard for use in deletion tests.
$secondDashboard = DashboardTestHelper::createDashboardByNameForOwner('Dashboard2', $super);
$this->assertTrue($secondDashboard->isDefault == 0);
$this->assertFalse($secondDashboard->isDefault === 0);
//Just to prove it does not evaluate to this.
//Attempt to delete the default dashboard and have it through an exception.
$dashboards = Dashboard::getRowsByUserId($super->id);
$this->assertEquals(2, count($dashboards));
$this->setGetArray(array('dashboardId' => $superDashboard->id));
$this->resetPostArray();
$this->runControllerWithNotSupportedExceptionAndGetContent('home/default/deleteDashboard');
//Delete dashboard that you can delete.
$dashboards = Dashboard::getRowsByUserId($super->id);
$this->assertEquals(2, count($dashboards));
$this->setGetArray(array('dashboardId' => $secondDashboard->id));
$this->resetPostArray();
$this->runControllerWithRedirectExceptionAndGetContent('home/default/deleteDashboard');
$dashboards = Dashboard::getRowsByUserId($super->id);
$this->assertEquals(1, count($dashboards));
//Add a dashboard via the create dashboard action.
$this->assertEquals(1, count(Dashboard::getAll()));
$this->resetGetArray();
$this->setPostArray(array('Dashboard' => array('name' => 'myTestDashboard', 'layoutType' => '50,50')));
// Not Coding Standard
$this->runControllerWithRedirectExceptionAndGetContent('home/default/createDashboard');
$dashboards = Dashboard::getAll();
$this->assertEquals(2, count($dashboards));
$this->assertEquals('myTestDashboard', $dashboards[1]->name);
$this->assertEquals($super, $dashboards[1]->owner);
$this->assertEquals('50,50', $dashboards[1]->layoutType);
// Not Coding Standard
//Portlet Controller Actions
$uniqueLayoutId = 'HomeDashboard' . $superDashboard->layoutId;
$this->setGetArray(array('dashboardId' => $superDashboard->id, 'uniqueLayoutId' => $uniqueLayoutId));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/addList');
//Add AccountsMyList Portlet to dashboard
$this->setGetArray(array('dashboardId' => $superDashboard->id, 'portletType' => 'AccountsMyList', 'uniqueLayoutId' => $uniqueLayoutId));
$this->resetPostArray();
$this->runControllerWithRedirectExceptionAndGetContent('home/defaultPortlet/add');
//Save a layout change. Collapse all portlets
//At this point portlets for this view should be created because we have already loaded the 'details' page in a request above.
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, $super->id, array());
$this->assertEquals(4, count($portlets[1]));
$this->assertEquals(4, count($portlets[2]));
$portletPostData = array();
$portletCount = 0;
foreach ($portlets as $column => $columnPortlets) {
foreach ($columnPortlets as $position => $portlet) {
$this->assertEquals('0', $portlet->collapsed);
$portletPostData['HomeDashboard1_' . $portlet->id] = array('collapsed' => 'true', 'column' => 0, 'id' => 'HomeDashboard1_' . $portlet->id, 'position' => $portletCount);
$portletCount++;
}
}
//There should have been a total of 3 portlets. Checking positions as 4 will confirm this.
$this->assertEquals(8, $portletCount);
$this->resetGetArray();
$this->setPostArray(array('portletLayoutConfiguration' => array('portlets' => $portletPostData, 'uniqueLayoutId' => $uniqueLayoutId)));
$this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/saveLayout', true);
//Now test that all the portlets are collapsed.
$portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, $super->id, array());
$this->assertEquals(8, count($portlets[1]));
$this->assertFalse(array_key_exists(8, $portlets));
foreach ($portlets as $column => $columns) {
foreach ($columns as $position => $positionPortlets) {
$this->assertEquals('1', $positionPortlets->collapsed);
}
//.........这里部分代码省略.........