All Data Structures Functions Variables Pages
ContactsSuperUserKanbanBoardWalkthroughTest.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 
41  {
42  public static function setUpBeforeClass()
43  {
44  parent::setUpBeforeClass();
45  SecurityTestHelper::createSuperAdmin();
46  $super = User::getByUsername('super');
47  Yii::app()->user->userModel = $super;
48 
49  //Setup test data owned by the super user.
50  $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
51 
52  //Setup test data owned by the super user.
53  ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
54  ContactTestHelper::createContactWithAccountByNameForOwner('superContact1', $super, $account);
55  }
56 
57  public function testKanbanViewForContactDetails()
58  {
59  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
60  $superContactId = self::getModelIdByModelNameAndName ('Contact', 'superContact superContactson');
61  $contact = Contact::getById($superContactId);
62 
63  $task = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask', $super, $contact, Task::STATUS_IN_PROGRESS);
64  $taskNew = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask New', $super, $contact, Task::STATUS_NEW);
65  $this->setGetArray(array('id' => $task->id, 'kanbanBoard' => '1'));
66  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
67  $matcher = array(
68  'tag' => 'h4',
69  //Multiple ancestors
70  'ancestor' => array('tag' => 'li', 'id' => 'items_' . $task->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-3'),
71  'content' => 'MyTask'
72  );
73  $this->assertTag($matcher, $content);
74 
75  $matcher = array(
76  'tag' => 'h4',
77  //Multiple ancestors
78  'ancestor' => array('tag' => 'li', 'id' => 'items_' . $taskNew->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-1'),
79  'content' => 'MyTask New'
80  );
81  $this->assertTag($matcher, $content);
82 
83  $this->assertContains('<a id="hide-completed-search-link" href="#">Hide Completed</a>', $content);
84  }
85 
86  public function testStickySearchActions()
87  {
88  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
89  StickySearchUtil::clearDataByKey('TasksForRelatedKanbanSearchView');
90  $value = StickySearchUtil::getDataByKey('TasksForRelatedKanbanSearchView');
91  $this->assertNull($value);
92  $superContactId = self::getModelIdByModelNameAndName ('Contact', 'superContact1 superContact1son');
93  $contact = Contact::getById($superContactId);
94  $task = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask', $super, $contact, Task::STATUS_IN_PROGRESS);
95  $taskNew = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask New', $super, $contact, Task::STATUS_NEW);
96  // Asserting the kanban board contains both tasks before search
97  $this->resetPostArray();
98  $this->setGetArray(array(
99  'id' => $superContactId,
100  'kanbanBoard' => '1',
101  ));
102  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
103  $this->assertContains('<a id="hide-completed-search-link" href="#">Hide Completed</a>', $content);
104  $matcher = array(
105  'tag' => 'h4',
106  //Multiple ancestors
107  'ancestor' => array('tag' => 'li', 'id' => 'items_' . $taskNew->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-1'),
108  'content' => 'MyTask New'
109  );
110  $this->assertTag($matcher, $content);
111  $matcher = array(
112  'tag' => 'h4',
113  //Multiple ancestors
114  'ancestor' => array('tag' => 'li', 'id' => 'items_' . $task->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-3'),
115  'content' => 'MyTask'
116  );
117  $this->assertTag($matcher, $content);
118  $this->setGetArray(array(
119  'formModelClassName' => 'TasksForRelatedKanbanSearchForm',
120  'modelClassName' => 'Task',
121  'viewClassName' => 'TasksForRelatedKanbanSearchView',
122  ));
123  $this->setPostArray(array('TasksForRelatedKanbanSearchForm' =>
124  array('dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'name',
125  'name' => 'MyTask New',
126  'structurePosition' => '1',
127  )),
128  'anyMixedAttributesScope' => array('All'),
129  'dynamicStructure' => '1',
130  ),
131  'ajax' => 'search-form'));
132 
133  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/validateDynamicSearch', true);
134  // Asserting the kanban board contains only one task after search is done
135  $this->resetPostArray();
136  $this->setGetArray(array(
137  'id' => $superContactId,
138  'kanbanBoard' => '1',
139  ));
140  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
141  $this->assertContains('<a id="hide-completed-search-link" href="#">Hide Completed</a>', $content);
142  $matcher = array(
143  'tag' => 'h4',
144  //Multiple ancestors
145  'ancestor' => array('tag' => 'li', 'id' => 'items_' . $taskNew->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-1'),
146  'content' => 'MyTask New'
147  );
148  $this->assertTag($matcher, $content);
149  $matcher = array(
150  'tag' => 'h4',
151  //Multiple ancestors
152  'ancestor' => array('tag' => 'li', 'id' => 'items_' . $task->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-3'),
153  'content' => 'MyTask'
154  );
155  $this->assertNotTag($matcher, $content);
156  $data = StickySearchUtil::getDataByKey('TasksForRelatedKanbanSearchView');
157  $compareData = array(
158  'dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'name',
159  'name' => 'MyTask New',
160  'structurePosition' => '1',
161  )),
162  'dynamicStructure' => '1',
163  'anyMixedAttributesScope' => null,
164  SearchForm::SELECTED_LIST_ATTRIBUTES => null,
165  'savedSearchId' => null,
166  );
167  $this->assertEquals($compareData, $data);
168  }
169  }
170 ?>
static getByUsername($username)
Definition: User.php:49
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
Generated on Tue Jan 28 2020 07:10:15