Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ContactWebFormsSuperUserWalkthroughTest.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 
38  {
39  public static function setUpBeforeClass()
40  {
41  parent::setUpBeforeClass();
42  SecurityTestHelper::createSuperAdmin();
43  $super = User::getByUsername('super');
44  Yii::app()->user->userModel = $super;
45 
46  ContactWebFormTestHelper::createContactWebFormByName("Web Form 1");
47  ContactWebFormTestHelper::createContactWebFormByName("Web Form 2");
48  ContactWebFormTestHelper::createContactWebFormByName("Web Form 3");
49  ContactWebFormTestHelper::createContactWebFormByName("Web Form 4");
50  ContactWebFormTestHelper::createContactWebFormByName("Web Form 5");
51  ContactWebFormTestHelper::createContactWebFormByName("Web Form 6");
52  ContactWebFormTestHelper::createContactWebFormByName("Web Form 7");
53  ContactWebFormTestHelper::createContactWebFormByName("Web Form 8");
54  ContactWebFormTestHelper::createContactWebFormByName("Web Form 9");
55  ContactWebFormTestHelper::createContactWebFormByName("Web Form 10");
56  ContactWebFormTestHelper::createContactWebFormByName("Web Form 11");
57  ContactWebFormTestHelper::createContactWebFormByName("Web Form 12");
58  }
59 
60  public function testSuperUserAllDefaultControllerActions()
61  {
62  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
63 
64  //Test all default controller actions that do not require any POST/GET variables to be passed.
65  //This does not include portlet controller actions.
66  $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default');
67  $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/index');
68  $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/create');
69 
70  $content = $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/list');
71  $this->assertContains('anyMixedAttributes', $content);
72  //Test the search or paging of the listview.
73  Yii::app()->clientScript->reset(); //to make sure old js doesn't make it to the UI
74  $this->setGetArray(array('ajax' => 'list-view'));
75  $content = $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/list');
76  $this->assertNotContains('anyMixedAttributes', $content);
77  $this->resetGetArray();
78 
79  //Default Controller actions requiring some sort of parameter via POST or GET
80  //Load Model Edit Views
81  $contactWebForms = ContactWebForm::getAll();
82  $this->assertEquals(12, count($contactWebForms));
83  $contactWebFormId = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 1');
84  $contactWebFormId2 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 2');
85  $contactWebFormId3 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 3');
86  $contactWebFormId4 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 4');
87  $contactWebFormId5 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 5');
88  $contactWebFormId6 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 6');
89  $contactWebFormId7 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 7');
90  $contactWebFormId8 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 8');
91  $contactWebFormId9 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 9');
92  $contactWebFormId10 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 10');
93  $contactWebFormId10 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 11');
94  $contactWebFormId10 = self::getModelIdByModelNameAndName('ContactWebForm', 'Web Form 12');
95 
96  $this->setGetArray(array('id' => $contactWebFormId));
97  $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/edit');
98  //Save web form.
99  $contactWebForm = ContactWebForm::getById($contactWebFormId);
100  $attributes = ContactWebFormTestHelper::getContactWebFormAttributes();
101  $this->setPostArray(array('ContactWebForm' => array('submitButtonLabel' => 'Test Save'),
102  'ContactWebFormAttributeForm' => $attributes));
103  $this->runControllerWithRedirectExceptionAndGetContent('contactWebForms/default/edit');
104  $contactWebForm = ContactWebForm::getById($contactWebFormId);
105  $this->assertEquals('Test Save', $contactWebForm->submitButtonLabel);
106  //Test having a failed validation on the contact during save.
107  $this->setGetArray (array('id' => $contactWebFormId));
108  $this->setPostArray(array('ContactWebForm' => array('name' => ''), 'ContactWebFormAttributeForm' => $attributes));
109  $content = $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/edit');
110  $this->assertContains('Name cannot be blank', $content);
111 
112  //Load Model Detail Views
113  $this->setGetArray(array('id' => $contactWebFormId));
114  $this->resetPostArray();
115  $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/details');
116  }
117 
118  public function testSuperUserCreateAction()
119  {
120  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
121  Yii::app()->user->userModel = $super;
122  $this->resetGetArray();
123  $attributes = ContactWebFormTestHelper::getContactWebFormAttributes();
125  $contactStates = ContactState::getByName('New');
126  $contactWebForm = array();
127  $contactWebForm['name'] = 'External Web Form (Drupal)';
128  $contactWebForm['redirectUrl'] = 'http://www.zurmo.com/';
129  $contactWebForm['submitButtonLabel'] = 'Save & Next';
130  $contactWebForm['defaultState'] = $contactStates[0];
131  $contactWebForm['defaultOwner'] = $super;
132  $this->setPostArray(array('ContactWebForm' => $contactWebForm, 'ContactWebFormAttributeForm' => $attributes));
133  $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('contactWebForms/default/create');
134  $contactWebForms = ContactWebForm::getByName('External Web Form (Drupal)');
135  $this->assertEquals(1, count($contactWebForms));
136  $this->assertTrue ($contactWebForms[0]->id > 0);
137  $this->assertEquals('Save & Next', $contactWebForms[0]->submitButtonLabel);
138  $this->assertEquals($attributes, unserialize($contactWebForms[0]->serializedData));
139  $compareRedirectUrl = Yii::app()->createUrl('contactWebForms/default/details', array('id' => $contactWebForms[0]->id));
140  $this->assertEquals($compareRedirectUrl, $redirectUrl);
141  }
142  }
143 ?>
static getByUsername($username)
Definition: User.php:49
runControllerWithRedirectExceptionAndGetContent($route, $compareUrl=null, $compareUrlContains=false)
static loadStartingData()
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
static getByName($name)
Generated on Mon Jul 6 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.