Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
AccountContactAffiliationsSuperUserWalkthroughTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
44  {
45  protected static $account;
46 
47  protected static $account2;
48 
49  protected static $contact;
50 
51  protected static $contact2;
52 
53  public static function setUpBeforeClass()
54  {
55  parent::setUpBeforeClass();
56  SecurityTestHelper::createSuperAdmin();
57  $super = User::getByUsername('super');
58  Yii::app()->user->userModel = $super;
59 
60  //Setup test data owned by the super user.
61  self::$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
62  self::$account2 = AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
63  self::$contact = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, self::$account);
64  self::$contact2 = ContactTestHelper::createContactByNameForOwner('superContact2', $super);
65  }
66 
67  public function testSuperUserAllDefaultControllerActions()
68  {
69  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
70  $accountContactAffiliations = AccountContactAffiliation::getAll();
71  $this->assertEquals(1, count($accountContactAffiliations));
72 
73  //Default Controller actions requiring some sort of parameter via POST or GET
74  $this->setGetArray(array('id' => $accountContactAffiliations[0]->id));
75  $this->runControllerWithNoExceptionsAndGetContent('accountContactAffiliations/default/edit');
76  //Save accountContactAffiliation.
77  $this->assertEquals(null, $accountContactAffiliations[0]->role->value);
78  $this->setPostArray(array('AccountContactAffiliation' => array('role' => array('value' => 'Technical'))));
79  $this->runControllerWithRedirectExceptionAndGetContent('accountContactAffiliations/default/edit');
80  $accountContactAffiliation = AccountContactAffiliation::getById($accountContactAffiliations[0]->id);
81  $this->assertEquals('Technical', $accountContactAffiliation->role->value);
82 
83  //actionAuditEventsModalList
84  $this->setGetArray(array('id' => $accountContactAffiliation->id));
85  $this->resetPostArray();
86  $this->runControllerWithNoExceptionsAndGetContent('accountContactAffiliations/default/auditEventsModalList');
87  }
88 
93  {
94  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
95 
96  $this->setGetArray(array('id' => self::$contact->id));
97  $this->resetPostArray();
98  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
99  //Add the portlet in for the account and contact detailview. then load up the details to make sure it is ok
100  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition(
101  'ContactDetailsAndRelationsView', $super->id, array());
102  $this->assertEquals (4, count($portlets[2]));
103  $this->setGetArray(array(
104  'modelId' => self::$contact->id,
105  'portletType' => 'AccountAffiliationsForContactRelatedList',
106  'uniqueLayoutId' => 'ContactDetailsAndRelationsView'));
107  $this->resetPostArray();
108  $this->runControllerWithRedirectExceptionAndGetContent('contacts/defaultPortlet/add');
109  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition(
110  'ContactDetailsAndRelationsView', $super->id, array());
111  $this->assertEquals (5, count($portlets[2]));
112 
113  //Now add portlet in on account detailview
114  $this->setGetArray(array('id' => self::$account->id));
115  $this->resetPostArray();
116  $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
117  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition(
118  'AccountDetailsAndRelationsView', $super->id, array());
119  $this->assertEquals (5, count($portlets[2]));
120  $this->setGetArray(array(
121  'modelId' => self::$account->id,
122  'portletType' => 'ContactAffiliationsForAccountRelatedList',
123  'uniqueLayoutId' => 'AccountDetailsAndRelationsView'));
124  $this->resetPostArray();
125  $this->runControllerWithRedirectExceptionAndGetContent('accounts/defaultPortlet/add');
126  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition(
127  'AccountDetailsAndRelationsView', $super->id, array());
128  $this->assertEquals (6, count($portlets[2]));
129 
130  //Load Details View again to make sure everything is ok after the layout change.
131  $this->setGetArray(array('id' => self::$contact->id));
132  $this->resetPostArray();
133  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
134  $this->setGetArray(array('id' => self::$account->id));
135  $this->resetPostArray();
136  $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
137  }
138 
139  public function testSuperUserCreateFromRelationAction()
140  {
141  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
142  $accountContactAffiliations = AccountContactAffiliation::getAll();
143  $this->assertEquals(1, count($accountContactAffiliations));
144 
145  //Create a new AccountContactAffiliation from a related account.
146  $this->setGetArray(array( 'relationAttributeName' => 'account',
147  'relationModelId' => self::$account2->id,
148  'relationModuleId' => 'accounts',
149  'redirectUrl' => 'someRedirect'));
150  $this->setPostArray(array('AccountContactAffiliation' => array(
151  'role' => array('value' => 'TechnicalX'),
152  'contact' => array('id' => self::$contact2->id))));
153  $this->runControllerWithRedirectExceptionAndGetContent('accountContactAffiliations/default/createFromRelation');
154  $accountContactAffiliations = AccountContactAffiliation::getAll();
155  $this->assertEquals(2, count($accountContactAffiliations));
156  $this->assertEquals('TechnicalX', $accountContactAffiliations[1]->role->value);
157  $this->assertTrue($accountContactAffiliations[1]->account->isSame(self::$account2));
158  $this->assertTrue($accountContactAffiliations[1]->contact->isSame(self::$contact2));
159  }
160 
161  public function testSuperUserDeleteAction()
162  {
163  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
164  $accountContactAffiliations = AccountContactAffiliation::getAll();
165  $this->assertEquals(2, count($accountContactAffiliations));
166 
167  //Delete an AccountContactAffiliation model.
168  $this->setGetArray(array('id' => $accountContactAffiliations[0]->id));
169  $this->resetPostArray();
170  $this->runControllerWithNoExceptionsAndGetContent('accountContactAffiliations/default/delete', true);
171  $accountContactAffiliations = AccountContactAffiliation::getAll();
172  $this->assertEquals(1, count($accountContactAffiliations));
173  }
174  }
175 ?>
static getByUsername($username)
Definition: User.php:49
runControllerWithRedirectExceptionAndGetContent($route, $compareUrl=null, $compareUrlContains=false)
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
Generated on Wed Jul 8 2020 07:10:31
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.