All Data Structures Functions Variables Pages
AutoresponderDefaultControllerRegularUserWalkthroughTest.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  protected $user;
40 
41  protected static $superUserMarketingListId;
42 
43  protected static $regularUserMarketingListId;
44 
45  protected static $superUserAutoresponderId;
46 
47  protected static $regularUserAutoresponderId;
48 
49  public static function setUpBeforeClass()
50  {
51  parent::setUpBeforeClass();
52  SecurityTestHelper::createSuperAdmin();
53  Yii::app()->user->userModel = User::getByUsername('super');
54  $superUserMarketingList = MarketingListTestHelper::createMarketingListByName(
55  'superMarketingList');
56  static::$superUserMarketingListId = $superUserMarketingList->id;
57  $superUserAutoresponder = AutoresponderTestHelper::createAutoresponder('superAutoresponder',
58  'superText', 'superHtml', 10, Autoresponder::OPERATION_SUBSCRIBE,
59  true, $superUserMarketingList);
60  static::$superUserAutoresponderId = $superUserAutoresponder->id;
61  Yii::app()->user->userModel = UserTestHelper::createBasicUser('nobody');
62  $regularUserMarketingList = MarketingListTestHelper::createMarketingListByName(
63  'regularMarketingList');
64  static::$regularUserMarketingListId = $regularUserMarketingList->id;
65  $regularUserAutoresponder = AutoresponderTestHelper::createAutoresponder('regularAutoresponder',
66  'regularText', 'regularHtml', 10, Autoresponder::OPERATION_SUBSCRIBE,
67  true, $regularUserMarketingList);
68  static::$regularUserAutoresponderId = $regularUserAutoresponder->id;
70  }
71 
72  public function setUp()
73  {
74  parent::setUp();
75  $this->user = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
76  Yii::app()->user->userModel = $this->user;
77  }
78 
79  public function testRegularUserAllActionsWithNoMarketingListRight()
80  {
81  $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/create');
82  $this->assertContains('<div id="UserIsMissingMarketingListAccessSplashView"', $content);
83  $this->assertContains('<div class="Warning"><h2>Not so fast!</h2>', $content);
84  $this->assertContains('<p>To manage Marketing Lists related features you must have access ' .
85  'to marketing lists first. Contact the CRM administrator' .
86  ' about this issue.</p>', $content);
87  $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/edit');
88  $this->assertContains('<div id="UserIsMissingMarketingListAccessSplashView"', $content);
89  $this->assertContains('<div class="Warning"><h2>Not so fast!</h2>', $content);
90  $this->assertContains('<p>To manage Marketing Lists related features you must have access ' .
91  'to marketing lists first. Contact the CRM administrator' .
92  ' about this issue.</p>', $content);
93  $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/details');
94  $this->assertContains('<div id="UserIsMissingMarketingListAccessSplashView"', $content);
95  $this->assertContains('<div class="Warning"><h2>Not so fast!</h2>', $content);
96  $this->assertContains('<p>To manage Marketing Lists related features you must have access ' .
97  'to marketing lists first. Contact the CRM administrator' .
98  ' about this issue.</p>', $content);
99  $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/delete');
100  $this->assertContains('<div class="Warning"><h2>Not so fast!</h2>', $content);
101  $this->assertContains('<p>To manage Marketing Lists related features you must have access ' .
102  'to marketing lists first. Contact the CRM administrator' .
103  ' about this issue.</p>', $content);
104  }
105 
106  public function testRegularUserActionsWithMarketingListRightButInsufficientPermission()
107  {
108  $this->user->setRight('MarketingListsModule', MarketingListsModule::getAccessRight());
109  $this->assertTrue($this->user->save());
110  $this->setGetArray(array(
111  'marketingListId' => static::$superUserMarketingListId,
112  'redirectUrl' => 'http://www.zurmo.com/',
113  ));
114  $content = $this->runControllerWithExitExceptionAndGetContent('autoresponders/default/create');
115  $this->assertContains('You have tried to access a page you do not have access to.', $content);
116 
117  $this->setGetArray(array(
118  'id' => static::$superUserAutoresponderId,
119  'redirectUrl' => 'http://www.zurmo.com/',
120  ));
121  $content = $this->runControllerWithExitExceptionAndGetContent('autoresponders/default/edit');
122  $this->assertContains('You have tried to access a page you do not have access to.', $content);
123  $content = $this->runControllerWithExitExceptionAndGetContent('autoresponders/default/details');
124  $this->assertContains('You have tried to access a page you do not have access to.', $content);
125  $content = $this->runControllerWithExitExceptionAndGetContent('autoresponders/default/delete');
126  $this->assertContains('You have tried to access a page you do not have access to.', $content);
127  }
128 
129  public function testRegularUserActionsWithMarketingListRightAndRequiredPermissions()
130  {
131  $this->setGetArray(array(
132  'marketingListId' => static::$regularUserMarketingListId,
133  'redirectUrl' => 'http://www.zurmo.com/',
134  ));
135  $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/create');
136 
137  $this->setGetArray(array(
138  'id' => static::$regularUserAutoresponderId,
139  'redirectUrl' => 'http://www.zurmo.com/',
140  ));
141  $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/edit');
142  $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/details');
143  $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/delete');
144  }
145  }
146 ?>
static rebuild($overwriteExistingTables=true, $forcePhp=false, $messageStreamer=null)
static getByUsername($username)
Definition: User.php:49
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
Generated on Thu Apr 2 2020 07:10:40