Completed
Pull Request — master (#159)
by Corey
03:50
created
common/models/UserBehavior.php 2 patches
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,7 +114,9 @@  discard block
 block discarded – undo
114 114
 
115 115
   public function getDailyScore($date = null) {
116 116
     // default to today's score
117
-    if(is_null($date)) $date = $this->time->getLocalDate();
117
+    if(is_null($date)) {
118
+      $date = $this->time->getLocalDate();
119
+    }
118 120
 
119 121
     list($start, $end) = $this->time->getUTCBookends($date);
120 122
     $score = $this->calculateScoreByUTCRange($start, $end);
@@ -166,8 +168,12 @@  discard block
 block discarded – undo
166 168
   }
167 169
 
168 170
   public function calculateScore($usr_bhvrs, $all_cats = null) {
169
-    if(!!!$usr_bhvrs) return [];
170
-    if(!!!$all_cats)  $all_cats = $this->behavior->getCategories();
171
+    if(!!!$usr_bhvrs) {
172
+      return [];
173
+    }
174
+    if(!!!$all_cats) {
175
+      $all_cats = $this->behavior->getCategories();
176
+    }
171 177
 
172 178
     $usr_bhvrs = array_reduce($usr_bhvrs, function($carry, $bhvr) {
173 179
       $date = $this->time->convertUTCToLocal($bhvr['date']);
@@ -190,7 +196,9 @@  discard block
 block discarded – undo
190 196
   }
191 197
 
192 198
   private function _getCatGrades($picked, $all_cats = null) {
193
-    if(!!!$all_cats) $all_cats = $this->behavior->getCategories();
199
+    if(!!!$all_cats) {
200
+      $all_cats = $this->behavior->getCategories();
201
+    }
194 202
 
195 203
     return array_reduce($all_cats, function($carry, $cat) use($picked) {
196 204
       if(array_key_exists($cat['category_id'], $picked)) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
       ->groupBy('date, user_id')
86 86
       ->having('user_id = :user_id');
87 87
     $temp_dates = $query->all();
88
-    foreach($temp_dates as $temp_date) {
88
+    foreach ($temp_dates as $temp_date) {
89 89
       $past_checkin_dates[] = $this->time->convertUTCToLocal($temp_date['date']);
90 90
     }
91 91
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
   public function getDailyScore($date = null) {
116 116
     // default to today's score
117
-    if(is_null($date)) $date = $this->time->getLocalDate();
117
+    if (is_null($date)) $date = $this->time->getLocalDate();
118 118
 
119 119
     list($start, $end) = $this->time->getUTCBookends($date);
120 120
     $score = $this->calculateScoreByUTCRange($start, $end);
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
   }
148 148
 
149 149
   public function calculateScoresOfLastMonth() {
150
-    $key = "scores_of_last_month_".Yii::$app->user->id."_".$this->time->getLocalDate();
150
+    $key = "scores_of_last_month_" . Yii::$app->user->id . "_" . $this->time->getLocalDate();
151 151
     $scores = Yii::$app->cache->get($key);
152
-    if($scores === false) {
152
+    if ($scores === false) {
153 153
       $scores = [];
154 154
 
155 155
       $dt = new DateTime("now", new DateTimeZone("UTC"));
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
   }
167 167
 
168 168
   public function calculateScore($usr_bhvrs, $all_cats = null) {
169
-    if(!!!$usr_bhvrs) return [];
170
-    if(!!!$all_cats)  $all_cats = $this->behavior->getCategories();
169
+    if (!!!$usr_bhvrs) return [];
170
+    if (!!!$all_cats)  $all_cats = $this->behavior->getCategories();
171 171
 
172 172
     $usr_bhvrs = array_reduce($usr_bhvrs, function($carry, $bhvr) {
173 173
       $date = $this->time->convertUTCToLocal($bhvr['date']);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     }, []);
177 177
 
178 178
     $scores = [];
179
-    foreach($usr_bhvrs as $date => $bhvrs) {
179
+    foreach ($usr_bhvrs as $date => $bhvrs) {
180 180
       $picked = array_reduce($bhvrs, function($carry, $bhvr) {
181 181
         $carry[$bhvr['category_id']][] = $bhvr['id'];
182 182
         return $carry;
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
   }
191 191
 
192 192
   private function _getCatGrades($picked, $all_cats = null) {
193
-    if(!!!$all_cats) $all_cats = $this->behavior->getCategories();
193
+    if (!!!$all_cats) $all_cats = $this->behavior->getCategories();
194 194
 
195 195
     return array_reduce($all_cats, function($carry, $cat) use($picked) {
196
-      if(array_key_exists($cat['category_id'], $picked)) {
196
+      if (array_key_exists($cat['category_id'], $picked)) {
197 197
         $count = count($picked[$cat['category_id']]);
198
-        $prcnt_2x = ($count / $cat['behavior_count']) * 2;
198
+        $prcnt_2x = ($count/$cat['behavior_count'])*2;
199 199
         // because we're doubling the % we want to ensure we don't take more than 100%
200
-        $carry[$cat['category_id']] = $cat['weight'] * min($prcnt_2x, 1);
200
+        $carry[$cat['category_id']] = $cat['weight']*min($prcnt_2x, 1);
201 201
       } else {
202 202
         $carry[$cat['category_id']] = 0;
203 203
       }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     $colors = \common\models\Category::$colors;
221 221
     $arr = array_reduce(self::decorateWithCategory($this->getBehaviorsWithCounts()), function($acc, $row) use ($colors) {
222 222
       $cat_id = $row['behavior']['category']['id'];
223
-      if(array_key_exists($cat_id, $acc)) {
223
+      if (array_key_exists($cat_id, $acc)) {
224 224
         $acc[$cat_id]['count'] += $row['count'];
225 225
       } else {
226 226
         $acc[$cat_id] = [
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
   }
238 238
 
239 239
   public static function decorate(Array $uo, $with_category = false) {
240
-    foreach($uo as &$o) {
241
-      if($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
240
+    foreach ($uo as &$o) {
241
+      if ($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
242 242
         $o['behavior'] = $behavior;
243
-        if($with_category) {
243
+        if ($with_category) {
244 244
           $o['behavior']['category'] = \common\models\Category::getCategory('id', $o['behavior']['category_id']);
245 245
         }
246 246
       }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
       ->groupBy('behavior_id, user_id')
261 261
       ->having('user_id = :user_id')
262 262
       ->orderBy('count DESC');
263
-    if($limit) {
263
+    if ($limit) {
264 264
       $query->limit($limit);
265 265
     }
266 266
 
Please login to merge, or discard this patch.
common/config/main.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
       'common\interfaces\QuestionInterface' => '\common\models\Question',
11 11
       'common\interfaces\BehaviorInterface' => '\common\models\Behavior',
12 12
       'common\interfaces\CategoryInterface' => '\common\models\Category',
13
-      'common\interfaces\TimeInterface' => function () {
14
-        if(Yii::$app->user->getIsGuest()) {
13
+      'common\interfaces\TimeInterface' => function() {
14
+        if (Yii::$app->user->getIsGuest()) {
15 15
           return new \common\components\Time('UTC');
16 16
         } else {
17 17
           return new \common\components\Time(Yii::$app->user->identity->timezone);
Please login to merge, or discard this patch.
site/assets/assets.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
  */
5 5
 
6 6
 // In the console environment, some path aliases may not exist. Please define these:
7
- Yii::setAlias('@webroot', __DIR__ . '/../web');
8
- Yii::setAlias('@web', '/');
7
+  Yii::setAlias('@webroot', __DIR__ . '/../web');
8
+  Yii::setAlias('@web', '/');
9 9
 
10 10
 $mainConf = require(Yii::getAlias('@site/config/main.php'));
11 11
 $converter = $mainConf['components']['assetManager']['converter'];
Please login to merge, or discard this patch.
site/tests/unit/models/QuestionFormTest.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
       $model->answer_2c = 'answering question c';
86 86
 
87 87
       expect('behaviorToAnswers should return the answer properties related to the behavior number supplied', $this->assertEquals($model->behaviorToAnswers(1), [
88
-                                                               'a' => 'answering question a',
89
-                                                               'b' => 'answering question b',
90
-                                                               'c' => 'answering question c'
91
-                                                             ]));
88
+                                                                'a' => 'answering question a',
89
+                                                                'b' => 'answering question b',
90
+                                                                'c' => 'answering question c'
91
+                                                              ]));
92 92
 
93 93
       expect('behaviorToAnswers should return the the empty set when there are no answers associated with the supplied behavior number', $this->assertEmpty($model->behaviorToAnswers(7)));
94 94
     });
@@ -117,51 +117,51 @@  discard block
 block discarded – undo
117 117
         $this->fakeModel(13, 281),
118 118
         $this->fakeModel(28, 284)
119 119
       ]), [ [
120
-										'behavior_id' => 280,
121
-										'user_bhvr_id' => 7,
122
-										'question_id' => 1,
123
-										'answer' => 'processing emotions',
124
-									], [
125
-										'behavior_id' => 280,
126
-										'user_bhvr_id' => 7,
127
-										'question_id' => 2,
128
-										'answer' => 'processing emotions',
129
-									], [
130
-										'behavior_id' => 280,
131
-										'user_bhvr_id' => 7,
132
-										'question_id' => 3,
133
-										'answer' => 'processing emotions',
134
-									], [
135
-										'behavior_id' => 281,
136
-										'user_bhvr_id' => 13,
137
-										'question_id' => 1,
138
-										'answer' => 'processing emotions',
139
-									], [
140
-										'behavior_id' => 281,
141
-										'user_bhvr_id' => 13,
142
-										'question_id' => 2,
143
-										'answer' => 'processing emotions',
144
-									], [
145
-										'behavior_id' => 281,
146
-										'user_bhvr_id' => 13,
147
-										'question_id' => 3,
148
-										'answer' => 'processing emotions',
149
-									], [
150
-										'behavior_id' => 284,
151
-										'user_bhvr_id' => 28,
152
-										'question_id' => 1,
153
-										'answer' => 'processing emotions',
154
-									], [
155
-										'behavior_id' => 284,
156
-										'user_bhvr_id' => 28,
157
-										'question_id' => 2,
158
-										'answer' => 'processing emotions',
159
-									], [
160
-										'behavior_id' => 284,
161
-										'user_bhvr_id' => 28,
162
-										'question_id' => 3,
163
-										'answer' => 'processing emotions',
164
-									]]));
120
+                    'behavior_id' => 280,
121
+                    'user_bhvr_id' => 7,
122
+                    'question_id' => 1,
123
+                    'answer' => 'processing emotions',
124
+                  ], [
125
+                    'behavior_id' => 280,
126
+                    'user_bhvr_id' => 7,
127
+                    'question_id' => 2,
128
+                    'answer' => 'processing emotions',
129
+                  ], [
130
+                    'behavior_id' => 280,
131
+                    'user_bhvr_id' => 7,
132
+                    'question_id' => 3,
133
+                    'answer' => 'processing emotions',
134
+                  ], [
135
+                    'behavior_id' => 281,
136
+                    'user_bhvr_id' => 13,
137
+                    'question_id' => 1,
138
+                    'answer' => 'processing emotions',
139
+                  ], [
140
+                    'behavior_id' => 281,
141
+                    'user_bhvr_id' => 13,
142
+                    'question_id' => 2,
143
+                    'answer' => 'processing emotions',
144
+                  ], [
145
+                    'behavior_id' => 281,
146
+                    'user_bhvr_id' => 13,
147
+                    'question_id' => 3,
148
+                    'answer' => 'processing emotions',
149
+                  ], [
150
+                    'behavior_id' => 284,
151
+                    'user_bhvr_id' => 28,
152
+                    'question_id' => 1,
153
+                    'answer' => 'processing emotions',
154
+                  ], [
155
+                    'behavior_id' => 284,
156
+                    'user_bhvr_id' => 28,
157
+                    'question_id' => 2,
158
+                    'answer' => 'processing emotions',
159
+                  ], [
160
+                    'behavior_id' => 284,
161
+                    'user_bhvr_id' => 28,
162
+                    'question_id' => 3,
163
+                    'answer' => 'processing emotions',
164
+                  ]]));
165 165
     });
166 166
   }
167 167
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
18 18
     $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
19 19
     $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion');
20
-    $this->container->set('common\interfaces\TimeInterface', function () {
20
+    $this->container->set('common\interfaces\TimeInterface', function() {
21 21
       return new \common\components\Time('America/Los_Angeles');
22 22
     });
23 23
   }
24 24
 
25 25
   public function testAttributeLabels()
26 26
   {
27
-    $this->specify('setBehaviors should function properly', function () {
27
+    $this->specify('setBehaviors should function properly', function() {
28 28
       $model = $this->container->get('\site\models\QuestionForm');
29 29
       expect('attributeLabels should be correct', $this->assertEquals($model->attributeLabels(), [
30 30
         'user_behavior_id1' => 'Restoration',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     $model = $this->container->get('\site\models\QuestionForm');
44 44
     $validator = $model->getBhvrValidator();
45 45
 
46
-    $this->specify('getBhvrValidator should function properly', function () use($model, $validator) {
46
+    $this->specify('getBhvrValidator should function properly', function() use($model, $validator) {
47 47
       expect('getBhvrValidator should return false when nothing is set on the form', $this->assertFalse($validator($model, "user_behavior_id1")));
48 48
       expect('getBhvrValidator should return false when nothing is set on the form', $this->assertFalse($validator($model, "user_behavior_id7")));
49 49
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $this->fakeModel(7, 280),
117 117
         $this->fakeModel(13, 281),
118 118
         $this->fakeModel(28, 284)
119
-      ]), [ [
119
+      ]), [[
120 120
 										'behavior_id' => 280,
121 121
 										'user_bhvr_id' => 7,
122 122
 										'question_id' => 1,
Please login to merge, or discard this patch.
site/tests/unit/models/SignupFormTest.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
       expect('the form should validate correctly', $this->assertTrue($form->validate()));
142 142
       $user = $form->signup();
143 143
       expect('signup() should return a newly-saved user when the user does not already exist with the submitted values',
144
-             $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 2)));
144
+              $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 2)));
145 145
       expect('the "Remember Me" auth_key value should be set to a random string (defaults to a 32 char length)',
146
-             $this->assertEquals(32, strlen($user->auth_key)));
146
+              $this->assertEquals(32, strlen($user->auth_key)));
147 147
       expect('password_hash to be set to something like a hash',
148
-             $this->assertStringStartsWith('$2y$13$', $user->password_hash));
148
+              $this->assertStringStartsWith('$2y$13$', $user->password_hash));
149 149
       expect('when the user is created, signup() should call save()',
150
-             $this->assertTrue($saved));
150
+              $this->assertTrue($saved));
151 151
       expect('This user should be an isNewRecord -- they should NOT already exist', $this->assertTrue($user->getIsNewRecord()));
152 152
     });
153 153
   }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
       $user = $form3->signup();
192 192
       expect('This user should not be an isNewRecord -- they should already exist', $this->assertFalse($user->getIsNewRecord()));
193 193
       expect('signup() should return a newly-saved user when the user does not already exist with the submitted values',
194
-             $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 2)));
194
+              $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 2)));
195 195
       expect('when the user exists and is NOT confirmed, signup() should call save() to UPDATE their info', $this->assertTrue($saved));
196 196
     });
197 197
   }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
     $this->container = new \yii\di\Container;
34 34
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
35 35
     $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
36
-    $this->container->set('common\interfaces\TimeInterface', function () {
36
+    $this->container->set('common\interfaces\TimeInterface', function() {
37 37
       return new \common\components\Time('America/Los_Angeles');
38 38
     });
39 39
 
40 40
     // instantiate mock objects
41 41
     $user_behavior = $this->container->get('common\interfaces\UserBehaviorInterface');
42
-    $time        = $this->container->get('common\interfaces\TimeInterface');
42
+    $time = $this->container->get('common\interfaces\TimeInterface');
43 43
 
44 44
     $question = $this->getMockBuilder('\common\models\Question')
45 45
       ->setMethods(['save', 'attributes'])
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
     // set up a side effect to occur when the user's save() function is called
130 130
     $saved = false;
131
-    $this->user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) {
131
+    $this->user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) {
132 132
       $saved = true;
133 133
       return $this->user;
134 134
     }));
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
  
155 155
   public function testSignupExistingConfirmedUser() {
156 156
     $saved = false;
157
-    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) {
157
+    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) {
158 158
       $saved = true;
159 159
       return $this->existing_user;
160 160
     }));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
   public function testSignupExistingUnconfirmedUser() {
175 175
     $saved = false;
176
-    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) {
176
+    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) {
177 177
       $saved = true;
178 178
       return $this->existing_user;
179 179
     }));
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 
205 205
     $result = $form->setFields($this->user);
206 206
     $this->specify('populate should set the values of the user model from the form', function() use ($result) {
207
-      foreach($this->whitelist as $attr) {
207
+      foreach ($this->whitelist as $attr) {
208 208
         $this->assertEquals($this->vals[$attr], $result->$attr);
209 209
       }
210 210
     });
211 211
   }
212 212
 
213 213
   private function setAttrs($form, Array $vals) {
214
-    foreach($vals as $key => $val) {
214
+    foreach ($vals as $key => $val) {
215 215
       $form->$key = $val;
216 216
     }
217 217
     return $form;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
   }
233 233
 
234 234
   private function getForm($user = null) {
235
-    if(is_null($user)) $user = $this->user;
235
+    if (is_null($user)) $user = $this->user;
236 236
     $form = $this->container->get('\site\models\SignupForm', [$user]);
237 237
     $form->attributes = $this->vals; // massive assignment
238 238
     return $form;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -232,7 +232,9 @@
 block discarded – undo
232 232
   }
233 233
 
234 234
   private function getForm($user = null) {
235
-    if(is_null($user)) $user = $this->user;
235
+    if(is_null($user)) {
236
+      $user = $this->user;
237
+    }
236 238
     $form = $this->container->get('\site\models\SignupForm', [$user]);
237 239
     $form->attributes = $this->vals; // massive assignment
238 240
     return $form;
Please login to merge, or discard this patch.
site/tests/unit/models/CheckinFormTest.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -8,103 +8,103 @@  discard block
 block discarded – undo
8 8
 {
9 9
     use \Codeception\Specify;
10 10
 
11
-		public $behaviors = [
12
-			1 => [
13
-				'category_name' => 'Restoration',
14
-				'behaviors' => [
15
-					0 => [
16
-						'id' => 7,
17
-						'name' => 'making eye contact',
18
-					],
19
-				],
20
-			],
21
-			2 => [
22
-				'category_name' => 'Forgetting Priorities',
23
-				'behaviors' => [
24
-					0 => [
25
-						'id' => 12,
26
-						'name' => 'bored',
27
-					],
28
-					1 => [
29
-						'id' => 13,
30
-						'name' => 'less time/energy for God, meetings, and church',
31
-					],
32
-					2 => [
33
-						'id' => 17,
34
-						'name' => 'isolating yourself',
35
-					],
36
-					3 => [
37
-						'id' => 18,
38
-						'name' => 'changes in goals',
39
-					],
40
-				],
41
-			],
42
-			3 => [
43
-				'category_name' => 'Anxiety',
44
-				'behaviors' => [
45
-					0 => [
46
-						'id' => 28,
47
-						'name' => 'worry',
48
-					],
49
-					1 => [
50
-						'id' => 38,
51
-						'name' => 'fantasy',
52
-					],
53
-					2 => [
54
-						'id' => 46,
55
-						'name' => 'using over-the-counter medication for pain, sleep, and weight control',
56
-					],
57
-				],
58
-			],
59
-			4 => [
60
-				'category_name' => 'Speeding Up',
61
-				'behaviors' => [
62
-					0 => [
63
-						'id' => 47,
64
-						'name' => 'super busy',
65
-					],
66
-					1 => [
67
-						'id' => 56,
68
-						'name' => 'binge eating (usually at night]',
69
-					],
70
-					2 => [
71
-						'id' => 62,
72
-						'name' => 'dramatic mood swings',
73
-					],
74
-				],
75
-			],
76
-			5 => [
77
-				'category_name' => 'Ticked Off',
78
-				'behaviors' => [
79
-					0 => [
80
-						'id' => 78,
81
-						'name' => 'increased isolation',
82
-					],
83
-					1 => [
84
-						'id' => 79,
85
-						'name' => 'blaming',
86
-					],
87
-				],
88
-			],
89
-			6 => [
90
-				'category_name' => 'Exhausted',
91
-				'behaviors' => [
92
-					0 => [
93
-						'id' => 104,
94
-						'name' => 'pessimistic',
95
-					],
96
-				],
97
-			],
98
-			7 => [
99
-				'category_name' => 'Relapse/Moral Failure',
100
-				'behaviors' => [
101
-					0 => [
102
-						'id' => 128,
103
-						'name' => 'feeling you just can\'t manage without your coping behavior, at least for now',
104
-					],
105
-				],
106
-			],
107
-		];
11
+    public $behaviors = [
12
+      1 => [
13
+        'category_name' => 'Restoration',
14
+        'behaviors' => [
15
+          0 => [
16
+            'id' => 7,
17
+            'name' => 'making eye contact',
18
+          ],
19
+        ],
20
+      ],
21
+      2 => [
22
+        'category_name' => 'Forgetting Priorities',
23
+        'behaviors' => [
24
+          0 => [
25
+            'id' => 12,
26
+            'name' => 'bored',
27
+          ],
28
+          1 => [
29
+            'id' => 13,
30
+            'name' => 'less time/energy for God, meetings, and church',
31
+          ],
32
+          2 => [
33
+            'id' => 17,
34
+            'name' => 'isolating yourself',
35
+          ],
36
+          3 => [
37
+            'id' => 18,
38
+            'name' => 'changes in goals',
39
+          ],
40
+        ],
41
+      ],
42
+      3 => [
43
+        'category_name' => 'Anxiety',
44
+        'behaviors' => [
45
+          0 => [
46
+            'id' => 28,
47
+            'name' => 'worry',
48
+          ],
49
+          1 => [
50
+            'id' => 38,
51
+            'name' => 'fantasy',
52
+          ],
53
+          2 => [
54
+            'id' => 46,
55
+            'name' => 'using over-the-counter medication for pain, sleep, and weight control',
56
+          ],
57
+        ],
58
+      ],
59
+      4 => [
60
+        'category_name' => 'Speeding Up',
61
+        'behaviors' => [
62
+          0 => [
63
+            'id' => 47,
64
+            'name' => 'super busy',
65
+          ],
66
+          1 => [
67
+            'id' => 56,
68
+            'name' => 'binge eating (usually at night]',
69
+          ],
70
+          2 => [
71
+            'id' => 62,
72
+            'name' => 'dramatic mood swings',
73
+          ],
74
+        ],
75
+      ],
76
+      5 => [
77
+        'category_name' => 'Ticked Off',
78
+        'behaviors' => [
79
+          0 => [
80
+            'id' => 78,
81
+            'name' => 'increased isolation',
82
+          ],
83
+          1 => [
84
+            'id' => 79,
85
+            'name' => 'blaming',
86
+          ],
87
+        ],
88
+      ],
89
+      6 => [
90
+        'category_name' => 'Exhausted',
91
+        'behaviors' => [
92
+          0 => [
93
+            'id' => 104,
94
+            'name' => 'pessimistic',
95
+          ],
96
+        ],
97
+      ],
98
+      7 => [
99
+        'category_name' => 'Relapse/Moral Failure',
100
+        'behaviors' => [
101
+          0 => [
102
+            'id' => 128,
103
+            'name' => 'feeling you just can\'t manage without your coping behavior, at least for now',
104
+          ],
105
+        ],
106
+      ],
107
+    ];
108 108
 
109 109
     protected function setUp() {
110 110
       $this->container = new \yii\di\Container;
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
       parent::setUp();
116 116
     }
117 117
 
118
-		public function testAttributeLabels()
119
-		{
118
+    public function testAttributeLabels()
119
+    {
120 120
         $this->specify('setBehaviors should function properly', function () {
121 121
           $model = $this->container->get('\site\models\CheckinForm');
122 122
           expect('attributeLabels should be correct', $this->assertEquals($model->attributeLabels(), [
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $this->specify('setBehaviors should function properly', function () {
137 137
           $model = $this->container->get('\site\models\CheckinForm');
138
-					$model->setBehaviors($this->behaviors);
138
+          $model->setBehaviors($this->behaviors);
139 139
 
140 140
           expect('behaviors1 should be correct', $this->assertEquals($model->behaviors1, [ 0 => 7 ]));
141 141
           expect('behaviors2 should be correct', $this->assertEquals($model->behaviors2, [ 0 => 12, 1 => 13, 2 => 17, 3 => 18 ]));
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
           expect('behaviors6 should be correct', $this->assertEquals($model->behaviors6, [ 0 => 104 ]));
146 146
           expect('behaviors7 should be correct', $this->assertEquals($model->behaviors7, [ 0 => 128 ]));
147 147
 
148
-					$model->setBehaviors($this->behaviors);
148
+          $model->setBehaviors($this->behaviors);
149 149
           expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors1, [ 0 => 7 ]));
150 150
           expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors2, [ 0 => 12, 1 => 13, 2 => 17, 3 => 18 ]));
151 151
           expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors3, [ 0 => 28, 1 => 38, 2 => 46 ]));
@@ -156,64 +156,64 @@  discard block
 block discarded – undo
156 156
         });
157 157
     }
158 158
 
159
-		public function testValidateBehaviors()
160
-		{
159
+    public function testValidateBehaviors()
160
+    {
161 161
         $this->specify('validateBehaviors should function properly', function () {
162 162
           $model = $this->container->get('\site\models\CheckinForm');
163
-					$model->setBehaviors($this->behaviors);
163
+          $model->setBehaviors($this->behaviors);
164 164
           expect('validation should be good', $this->assertTrue($model->validate()));
165 165
 
166 166
           $model->behaviors1[0] = 'bad';
167 167
           expect('validation should be bad', $this->assertFalse($model->validate()));
168 168
         });
169
-		}
169
+    }
170 170
 
171
-		public function testCompileBehaviors()
172
-		{
171
+    public function testCompileBehaviors()
172
+    {
173 173
         $this->specify('compileBehaviors should function properly', function () {
174 174
           $model = $this->container->get('\site\models\CheckinForm');
175
-					$model->setBehaviors($this->behaviors);
175
+          $model->setBehaviors($this->behaviors);
176 176
           expect('compiling behaviors should be return a correct array', $this->assertEquals($model->compileBehaviors(), [
177
-											  	0 => 7,
178
-											  	1 => 12,
179
-											  	2 => 13,
180
-											  	3 => 17,
181
-											  	4 => 18,
182
-											  	5 => 28,
183
-											  	6 => 38,
184
-											  	7 => 46,
185
-											  	8 => 47,
186
-											  	9 => 56,
187
-											  	10 => 62,
188
-											  	11 => 78,
189
-											  	12 => 79,
190
-											  	13 => 104,
191
-											  	14 => 128,
192
-											  ]));
177
+                          0 => 7,
178
+                          1 => 12,
179
+                          2 => 13,
180
+                          3 => 17,
181
+                          4 => 18,
182
+                          5 => 28,
183
+                          6 => 38,
184
+                          7 => 46,
185
+                          8 => 47,
186
+                          9 => 56,
187
+                          10 => 62,
188
+                          11 => 78,
189
+                          12 => 79,
190
+                          13 => 104,
191
+                          14 => 128,
192
+                        ]));
193 193
 
194 194
           $model = $this->container->get('\site\models\CheckinForm');
195
-					$model->setBehaviors($this->behaviors);
195
+          $model->setBehaviors($this->behaviors);
196 196
           $model->behaviors1[0] = null;
197 197
           $model->behaviors2[0] = null;
198 198
           $model->behaviors3[0] = null;
199 199
           expect('compiling behaviors should strip out any falsy values', $this->assertEquals($model->compileBehaviors(), [
200
-											  	2 => 13,
201
-											  	3 => 17,
202
-											  	4 => 18,
203
-											  	6 => 38,
204
-											  	7 => 46,
205
-											  	8 => 47,
206
-											  	9 => 56,
207
-											  	10 => 62,
208
-											  	11 => 78,
209
-											  	12 => 79,
210
-											  	13 => 104,
211
-											  	14 => 128,
212
-											  ]));
200
+                          2 => 13,
201
+                          3 => 17,
202
+                          4 => 18,
203
+                          6 => 38,
204
+                          7 => 46,
205
+                          8 => 47,
206
+                          9 => 56,
207
+                          10 => 62,
208
+                          11 => 78,
209
+                          12 => 79,
210
+                          13 => 104,
211
+                          14 => 128,
212
+                        ]));
213 213
 
214 214
           $model = $this->container->get('\site\models\CheckinForm');
215
-					$model->setBehaviors([]);
215
+          $model->setBehaviors([]);
216 216
           expect('compiling behaviors should return an empty array when no behaviors are set', $this->assertEmpty($model->compileBehaviors()));
217 217
         });
218
-		}
218
+    }
219 219
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     protected function setUp() {
110 110
       $this->container = new \yii\di\Container;
111 111
       $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
112
-    $this->container->set('common\interfaces\TimeInterface', function () {
112
+    $this->container->set('common\interfaces\TimeInterface', function() {
113 113
       return new \common\components\Time('America/Los_Angeles');
114 114
     });
115 115
       parent::setUp();
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 		public function testAttributeLabels()
119 119
 		{
120
-        $this->specify('setBehaviors should function properly', function () {
120
+        $this->specify('setBehaviors should function properly', function() {
121 121
           $model = $this->container->get('\site\models\CheckinForm');
122 122
           expect('attributeLabels should be correct', $this->assertEquals($model->attributeLabels(), [
123 123
             'behaviors1' => 'Restoration',
@@ -133,32 +133,32 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function testSetBehaviors()
135 135
     {
136
-        $this->specify('setBehaviors should function properly', function () {
136
+        $this->specify('setBehaviors should function properly', function() {
137 137
           $model = $this->container->get('\site\models\CheckinForm');
138 138
 					$model->setBehaviors($this->behaviors);
139 139
 
140
-          expect('behaviors1 should be correct', $this->assertEquals($model->behaviors1, [ 0 => 7 ]));
141
-          expect('behaviors2 should be correct', $this->assertEquals($model->behaviors2, [ 0 => 12, 1 => 13, 2 => 17, 3 => 18 ]));
142
-          expect('behaviors3 should be correct', $this->assertEquals($model->behaviors3, [ 0 => 28, 1 => 38, 2 => 46 ]));
143
-          expect('behaviors4 should be correct', $this->assertEquals($model->behaviors4, [ 0 => 47, 1 => 56, 2 => 62 ]));
144
-          expect('behaviors5 should be correct', $this->assertEquals($model->behaviors5, [ 0 => 78, 1 => 79 ]));
145
-          expect('behaviors6 should be correct', $this->assertEquals($model->behaviors6, [ 0 => 104 ]));
146
-          expect('behaviors7 should be correct', $this->assertEquals($model->behaviors7, [ 0 => 128 ]));
140
+          expect('behaviors1 should be correct', $this->assertEquals($model->behaviors1, [0 => 7]));
141
+          expect('behaviors2 should be correct', $this->assertEquals($model->behaviors2, [0 => 12, 1 => 13, 2 => 17, 3 => 18]));
142
+          expect('behaviors3 should be correct', $this->assertEquals($model->behaviors3, [0 => 28, 1 => 38, 2 => 46]));
143
+          expect('behaviors4 should be correct', $this->assertEquals($model->behaviors4, [0 => 47, 1 => 56, 2 => 62]));
144
+          expect('behaviors5 should be correct', $this->assertEquals($model->behaviors5, [0 => 78, 1 => 79]));
145
+          expect('behaviors6 should be correct', $this->assertEquals($model->behaviors6, [0 => 104]));
146
+          expect('behaviors7 should be correct', $this->assertEquals($model->behaviors7, [0 => 128]));
147 147
 
148 148
 					$model->setBehaviors($this->behaviors);
149
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors1, [ 0 => 7 ]));
150
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors2, [ 0 => 12, 1 => 13, 2 => 17, 3 => 18 ]));
151
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors3, [ 0 => 28, 1 => 38, 2 => 46 ]));
152
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors4, [ 0 => 47, 1 => 56, 2 => 62 ]));
153
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors5, [ 0 => 78, 1 => 79 ]));
154
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors6, [ 0 => 104 ]));
155
-          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors7, [ 0 => 128 ]));
149
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors1, [0 => 7]));
150
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors2, [0 => 12, 1 => 13, 2 => 17, 3 => 18]));
151
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors3, [0 => 28, 1 => 38, 2 => 46]));
152
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors4, [0 => 47, 1 => 56, 2 => 62]));
153
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors5, [0 => 78, 1 => 79]));
154
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors6, [0 => 104]));
155
+          expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals($model->behaviors7, [0 => 128]));
156 156
         });
157 157
     }
158 158
 
159 159
 		public function testValidateBehaviors()
160 160
 		{
161
-        $this->specify('validateBehaviors should function properly', function () {
161
+        $this->specify('validateBehaviors should function properly', function() {
162 162
           $model = $this->container->get('\site\models\CheckinForm');
163 163
 					$model->setBehaviors($this->behaviors);
164 164
           expect('validation should be good', $this->assertTrue($model->validate()));
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 		public function testCompileBehaviors()
172 172
 		{
173
-        $this->specify('compileBehaviors should function properly', function () {
173
+        $this->specify('compileBehaviors should function properly', function() {
174 174
           $model = $this->container->get('\site\models\CheckinForm');
175 175
 					$model->setBehaviors($this->behaviors);
176 176
           expect('compiling behaviors should be return a correct array', $this->assertEquals($model->compileBehaviors(), [
Please login to merge, or discard this patch.
site/tests/_support/AcceptanceTester.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 {
21 21
     use _generated\AcceptanceTesterActions;
22 22
 
23
-   /**
24
-    * Define custom actions here
25
-    */
23
+    /**
24
+     * Define custom actions here
25
+     */
26 26
 }
Please login to merge, or discard this patch.
site/tests/_support/MockUser.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
   public $timezone = 'America/Los_Angeles';
8 8
   public $password;
9 9
 
10
- public static function findIdentity($id) {}
11
- public static function findIdentityByAccessToken($token, $type = null) {}
12
- public function getId() {}
13
- public function getAuthKey() {}
14
- public function validateAuthKey($authKey) {}
15
- public function validatePassword($password) {}
16
- public function setPassword($password) {}
10
+  public static function findIdentity($id) {}
11
+  public static function findIdentityByAccessToken($token, $type = null) {}
12
+  public function getId() {}
13
+  public function getAuthKey() {}
14
+  public function validateAuthKey($authKey) {}
15
+  public function validatePassword($password) {}
16
+  public function setPassword($password) {}
17 17
 
18 18
   public static function primaryKey() {}
19 19
   public function attributes() {}
Please login to merge, or discard this patch.
site/tests/_support/FunctionalTester.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 {
21 21
     use _generated\FunctionalTesterActions;
22 22
 
23
-   /**
24
-    * Define custom actions here
25
-    */
23
+    /**
24
+     * Define custom actions here
25
+     */
26 26
 }
Please login to merge, or discard this patch.