Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
KanbanBoardTest.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  $values = array(
44  'Automotive',
45  'Adult Entertainment',
46  'Financial Services',
47  'Mercenaries & Armaments',
48  );
49  $industryFieldData = CustomFieldData::getByName('Industries');
50  $industryFieldData->defaultValue = $values[1];
51  $industryFieldData->serializedData = serialize($values);
52  if (!$industryFieldData->save())
53  {
54  throw new FailedToSaveRedBeanModelException();
55  }
56  }
57 
58  public function setUp()
59  {
60  parent::setUp();
61  Yii::app()->user->userModel = User::getByUsername('super');
62  }
63 
64  public function testResolveKanbanBoardOptionsForSearchModelFromGetArray()
65  {
66  $_GET['test'] = array('groupByAttributeVisibleValues' => '', 'selectedTheme' => '');
67  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
68  $kanbanBoard->setGroupByAttributeVisibleValues(array('a', 'b'));
69  $kanbanBoard->setSelectedTheme('someTheme');
70  $this->assertEquals(array('a', 'b'), $kanbanBoard->getGroupByAttributeVisibleValues());
71  $this->assertEquals('someTheme', $kanbanBoard->getSelectedTheme());
72  $this->assertNull($kanbanBoard->getIsActive());
73  $searchModel = new AAASearchFormTestModel(new AAA());
74  $searchModel->setKanbanBoard($kanbanBoard);
76  $this->assertNull($kanbanBoard->getGroupByAttributeVisibleValues());
77  $this->assertNull($kanbanBoard->getSelectedTheme());
78  $this->assertNull($kanbanBoard->getIsActive());
79 
80  //Now test setting in a selectedTheme and visibleValues
81  $_GET['test'] = array('groupByAttributeVisibleValues' => array('c', 'd'), 'selectedTheme' => 'aTheme');
83  $this->assertEquals(array('c', 'd'), $kanbanBoard->getGroupByAttributeVisibleValues());
84  $this->assertEquals('aTheme', $kanbanBoard->getSelectedTheme());
85  $this->assertTrue($kanbanBoard->getIsActive());
86  }
87 
88  public function testGetGridViewWidgetPath()
89  {
90  $compareString = 'application.core.kanbanBoard.widgets.KanbanBoardExtendedGridView';
91  $this->assertEquals($compareString, KanbanBoard::getGridViewWidgetPath());
92  }
93 
94  public function testGetSetIsActive()
95  {
96  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
97  $this->assertNull($kanbanBoard->getIsActive());
98  $kanbanBoard->setIsActive();
99  $this->assertTrue($kanbanBoard->getIsActive());
100  $kanbanBoard->setIsNotActive();
101  $this->assertFalse($kanbanBoard->getIsActive());
102  }
103 
104  public function testGetGridViewParams()
105  {
106  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
107  $params = $kanbanBoard->getGridViewParams();
108  $compareData = array('groupByAttribute' => 'industry',
109  'groupByAttributeVisibleValues' => array(
110  'Automotive',
111  'Adult Entertainment',
112  'Financial Services',
113  'Mercenaries & Armaments'),
114  'groupByDataAndTranslatedLabels' => array(
115  'Automotive' => 'Automotive',
116  'Adult Entertainment' => 'Adult Entertainment',
117  'Financial Services' => 'Financial Services',
118  'Mercenaries & Armaments' => 'Mercenaries & Armaments'),
119  'selectedTheme' => $kanbanBoard->getSelectedTheme());
120  $this->assertEquals($compareData, $params);
121  }
122 
123  public function testGetAndSetGroupByAttributeVisibleValues()
124  {
125  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
126  $kanbanBoard->setGroupByAttributeVisibleValues(array('c', 'd'));
127  $this->assertEquals(array('c', 'd'), $kanbanBoard->getGroupByAttributeVisibleValues());
128  }
129 
130  public function testGetAndSetSelectedTheme()
131  {
132  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
133  $kanbanBoard->setSelectedTheme('red');
134  $this->assertEquals('red', $kanbanBoard->getSelectedTheme());
135  $themeNamesAndLabelsCompare = array('' => 'White',
136  'kanban-background-football' => 'Football',
137  'kanban-background-tennis' => 'Tennis',
138  'kanban-background-motor' => 'Motor Sport',
139  'kanban-background-yoga' => 'Yoga',
140  'kanban-background-blurred-lights' => 'Blurred Lights',
141  'kanban-background-blurred-city' => 'Blurred City',
142  'kanban-background-blurred-vera' => 'Vera in Blur',
143  'kanban-background-perfect-beach' => 'Perfect Beach',
144  'kanban-background-flip-flops' => 'Flip Flops',
145  'kanban-background-blue-structure' => 'Blue Structure',
146  'kanban-background-sepia-sf' => 'Sepia SF',
147  'kanban-background-men-on-bridge' => 'Men on Bridge');
148  $this->assertEquals($themeNamesAndLabelsCompare, $kanbanBoard->getThemeNamesAndLabels());
149  }
150 
151  public function getAndSetClearSticky()
152  {
153  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
154  $this->assertFalse($kanbanBoard->getClearSticky());
155  $kanbanBoard->setClearSticky();
156  $this->assertFalse($kanbanBoard->getClearSticky());
157  }
158 
159  public function testResolveVisibleValuesForAdaptedMetadata()
160  {
161  $metadata = array('clauses' => array(), 'structure' => '');
162  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
163  $kanbanBoard->resolveVisibleValuesForAdaptedMetadata($metadata);
164  $compareData = array();
165  $compareData['structure'] = '(1 or 2 or 3 or 4)';
166  $compareData['clauses'][1] = array('attributeName' => 'industry',
167  'relatedAttributeName' => 'value',
168  'operatorType' => 'equals',
169  'value' => 'Automotive');
170  $compareData['clauses'][2] = array('attributeName' => 'industry',
171  'relatedAttributeName' => 'value',
172  'operatorType' => 'equals',
173  'value' => 'Adult Entertainment');
174  $compareData['clauses'][3] = array('attributeName' => 'industry',
175  'relatedAttributeName' => 'value',
176  'operatorType' => 'equals',
177  'value' => 'Financial Services');
178  $compareData['clauses'][4] = array('attributeName' => 'industry',
179  'relatedAttributeName' => 'value',
180  'operatorType' => 'equals',
181  'value' => 'Mercenaries & Armaments');
182  $this->assertEquals($compareData, $metadata);
183 
184  //Now resolve with pre-existing metadata
185  $metadata = array('clauses' => array(1 => 'firstClause'), 'structure' => '1');
186  $kanbanBoard = new KanbanBoard(new AAA(), 'industry');
187  $kanbanBoard->resolveVisibleValuesForAdaptedMetadata($metadata);
188  $compareData['structure'] = '(1) and (2 or 3 or 4 or 5)';
189  $compareData['clauses'][1] = 'firstClause';
190  $compareData['clauses'][2] = array('attributeName' => 'industry',
191  'relatedAttributeName' => 'value',
192  'operatorType' => 'equals',
193  'value' => 'Automotive');
194  $compareData['clauses'][3] = array('attributeName' => 'industry',
195  'relatedAttributeName' => 'value',
196  'operatorType' => 'equals',
197  'value' => 'Adult Entertainment');
198  $compareData['clauses'][4] = array('attributeName' => 'industry',
199  'relatedAttributeName' => 'value',
200  'operatorType' => 'equals',
201  'value' => 'Financial Services');
202  $compareData['clauses'][5] = array('attributeName' => 'industry',
203  'relatedAttributeName' => 'value',
204  'operatorType' => 'equals',
205  'value' => 'Mercenaries & Armaments');
206  $this->assertEquals($compareData, $metadata);
207  }
208  }
209 ?>
static getGridViewWidgetPath()
static getByUsername($username)
Definition: User.php:49
static resolveKanbanBoardOptionsForSearchModelFromArray($searchModel, $getArrayName, $sourceData)
Definition: KanbanBoard.php:76
Definition: AAA.php:37
static getByName($name, $shouldCache=true)
Generated on Mon Jul 6 2020 07:10:30
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.