| @@ -36,4 +36,4 @@ | ||
| 36 | 36 |    public function getBehaviorsByCategory(array $decorated_behaviors) {} | 
| 37 | 37 |    public static function decorate(array $uo) {} | 
| 38 | 38 |    public function getBehaviorsWithCounts($limit) {} | 
| 39 | - } | |
| 40 | 39 | \ No newline at end of file | 
| 40 | + } | |
| 41 | 41 | \ No newline at end of file | 
| @@ -85,10 +85,10 @@ discard block | ||
| 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,60 +117,60 @@ discard block | ||
| 117 | 117 | $this->fakeModel(13, 281, 8), | 
| 118 | 118 | $this->fakeModel(28, 284, 8) | 
| 119 | 119 | ]), [ [ | 
| 120 | - 'behavior_id' => 280, | |
| 120 | + 'behavior_id' => 280, | |
| 121 | 121 | 'category_id' => 8, | 
| 122 | - 'user_bhvr_id' => 7, | |
| 123 | - 'question_id' => 1, | |
| 124 | - 'answer' => 'processing emotions', | |
| 125 | - ], [ | |
| 126 | - 'behavior_id' => 280, | |
| 122 | + 'user_bhvr_id' => 7, | |
| 123 | + 'question_id' => 1, | |
| 124 | + 'answer' => 'processing emotions', | |
| 125 | + ], [ | |
| 126 | + 'behavior_id' => 280, | |
| 127 | 127 | 'category_id' => 8, | 
| 128 | - 'user_bhvr_id' => 7, | |
| 129 | - 'question_id' => 2, | |
| 130 | - 'answer' => 'processing emotions', | |
| 131 | - ], [ | |
| 132 | - 'behavior_id' => 280, | |
| 128 | + 'user_bhvr_id' => 7, | |
| 129 | + 'question_id' => 2, | |
| 130 | + 'answer' => 'processing emotions', | |
| 131 | + ], [ | |
| 132 | + 'behavior_id' => 280, | |
| 133 | 133 | 'category_id' => 8, | 
| 134 | - 'user_bhvr_id' => 7, | |
| 135 | - 'question_id' => 3, | |
| 136 | - 'answer' => 'processing emotions', | |
| 137 | - ], [ | |
| 138 | - 'behavior_id' => 281, | |
| 134 | + 'user_bhvr_id' => 7, | |
| 135 | + 'question_id' => 3, | |
| 136 | + 'answer' => 'processing emotions', | |
| 137 | + ], [ | |
| 138 | + 'behavior_id' => 281, | |
| 139 | 139 | 'category_id' => 8, | 
| 140 | - 'user_bhvr_id' => 13, | |
| 141 | - 'question_id' => 1, | |
| 142 | - 'answer' => 'processing emotions', | |
| 143 | - ], [ | |
| 144 | - 'behavior_id' => 281, | |
| 140 | + 'user_bhvr_id' => 13, | |
| 141 | + 'question_id' => 1, | |
| 142 | + 'answer' => 'processing emotions', | |
| 143 | + ], [ | |
| 144 | + 'behavior_id' => 281, | |
| 145 | 145 | 'category_id' => 8, | 
| 146 | - 'user_bhvr_id' => 13, | |
| 147 | - 'question_id' => 2, | |
| 148 | - 'answer' => 'processing emotions', | |
| 149 | - ], [ | |
| 150 | - 'behavior_id' => 281, | |
| 146 | + 'user_bhvr_id' => 13, | |
| 147 | + 'question_id' => 2, | |
| 148 | + 'answer' => 'processing emotions', | |
| 149 | + ], [ | |
| 150 | + 'behavior_id' => 281, | |
| 151 | 151 | 'category_id' => 8, | 
| 152 | - 'user_bhvr_id' => 13, | |
| 153 | - 'question_id' => 3, | |
| 154 | - 'answer' => 'processing emotions', | |
| 155 | - ], [ | |
| 156 | - 'behavior_id' => 284, | |
| 152 | + 'user_bhvr_id' => 13, | |
| 153 | + 'question_id' => 3, | |
| 154 | + 'answer' => 'processing emotions', | |
| 155 | + ], [ | |
| 156 | + 'behavior_id' => 284, | |
| 157 | 157 | 'category_id' => 8, | 
| 158 | - 'user_bhvr_id' => 28, | |
| 159 | - 'question_id' => 1, | |
| 160 | - 'answer' => 'processing emotions', | |
| 161 | - ], [ | |
| 162 | - 'behavior_id' => 284, | |
| 158 | + 'user_bhvr_id' => 28, | |
| 159 | + 'question_id' => 1, | |
| 160 | + 'answer' => 'processing emotions', | |
| 161 | + ], [ | |
| 162 | + 'behavior_id' => 284, | |
| 163 | 163 | 'category_id' => 8, | 
| 164 | - 'user_bhvr_id' => 28, | |
| 165 | - 'question_id' => 2, | |
| 166 | - 'answer' => 'processing emotions', | |
| 167 | - ], [ | |
| 168 | - 'behavior_id' => 284, | |
| 164 | + 'user_bhvr_id' => 28, | |
| 165 | + 'question_id' => 2, | |
| 166 | + 'answer' => 'processing emotions', | |
| 167 | + ], [ | |
| 168 | + 'behavior_id' => 284, | |
| 169 | 169 | 'category_id' => 8, | 
| 170 | - 'user_bhvr_id' => 28, | |
| 171 | - 'question_id' => 3, | |
| 172 | - 'answer' => 'processing emotions', | |
| 173 | - ]])); | |
| 170 | + 'user_bhvr_id' => 28, | |
| 171 | + 'question_id' => 3, | |
| 172 | + 'answer' => 'processing emotions', | |
| 173 | + ]])); | |
| 174 | 174 | }); | 
| 175 | 175 | } | 
| 176 | 176 | |
| @@ -17,14 +17,14 @@ discard block | ||
| 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 | ||
| 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 | ||
| 116 | 116 | $this->fakeModel(7, 280, 8), | 
| 117 | 117 | $this->fakeModel(13, 281, 8), | 
| 118 | 118 | $this->fakeModel(28, 284, 8) | 
| 119 | - ]), [ [ | |
| 119 | + ]), [[ | |
| 120 | 120 | 'behavior_id' => 280, | 
| 121 | 121 | 'category_id' => 8, | 
| 122 | 122 | 'user_bhvr_id' => 7, | 
| @@ -25,12 +25,12 @@ | ||
| 25 | 25 | <th>Behavior</th> | 
| 26 | 26 | <th>Category</th> | 
| 27 | 27 | </tr> | 
| 28 | -  <?php foreach($top_behaviors as $key => $row) { | |
| 28 | +  <?php foreach ($top_behaviors as $key => $row) { | |
| 29 | 29 | $num = $key + 1; | 
| 30 | - print "<tr>". | |
| 31 | -    "<td>{$row['count']}</td>". | |
| 32 | -    "<td>{$row['behavior']['name']}</td>". | |
| 33 | -    "<td>{$row['category']['name']}</td>". | |
| 30 | + print "<tr>" . | |
| 31 | +    "<td>{$row['count']}</td>" . | |
| 32 | +    "<td>{$row['behavior']['name']}</td>" . | |
| 33 | +    "<td>{$row['category']['name']}</td>" . | |
| 34 | 34 | "</tr>"; | 
| 35 | 35 | } | 
| 36 | 36 | ?> | 
| @@ -148,12 +148,12 @@ | ||
| 148 | 148 |        foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { | 
| 149 | 149 | $question_id = \common\models\Question::$TYPES[$answer_letter]; | 
| 150 | 150 | array_push($answers, [ | 
| 151 | - 'behavior_id' => $user_bhvr->behavior_id, | |
| 152 | - 'category_id' => $user_bhvr->category_id, | |
| 153 | - 'user_bhvr_id' => $user_bhvr->id, | |
| 154 | - 'question_id' => $question_id, | |
| 155 | - 'answer' => $answer, | |
| 156 | - ]); | |
| 151 | + 'behavior_id' => $user_bhvr->behavior_id, | |
| 152 | + 'category_id' => $user_bhvr->category_id, | |
| 153 | + 'user_bhvr_id' => $user_bhvr->id, | |
| 154 | + 'question_id' => $question_id, | |
| 155 | + 'answer' => $answer, | |
| 156 | + ]); | |
| 157 | 157 | } | 
| 158 | 158 | } | 
| 159 | 159 | return $answers; | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 |    public function setBehaviors($behaviors) { | 
| 58 | 58 |      foreach($behaviors as $category_id => $bhvr_set) { | 
| 59 | 59 | $attribute = "behaviors$category_id"; | 
| 60 | - $this->$attribute = []; | |
| 60 | + $this->$attribute = []; | |
| 61 | 61 |        foreach($bhvr_set as $behavior) { | 
| 62 | 62 |          $this->{$attribute}[] = $behavior['id']; | 
| 63 | 63 | } | 
| @@ -76,12 +76,12 @@ discard block | ||
| 76 | 76 | |
| 77 | 77 |    public function compileBehaviors() { | 
| 78 | 78 | $behaviors = array_merge((array)$this->behaviors1, | 
| 79 | - (array)$this->behaviors2, | |
| 80 | - (array)$this->behaviors3, | |
| 81 | - (array)$this->behaviors4, | |
| 82 | - (array)$this->behaviors5, | |
| 83 | - (array)$this->behaviors6, | |
| 84 | - (array)$this->behaviors7); | |
| 79 | + (array)$this->behaviors2, | |
| 80 | + (array)$this->behaviors3, | |
| 81 | + (array)$this->behaviors4, | |
| 82 | + (array)$this->behaviors5, | |
| 83 | + (array)$this->behaviors6, | |
| 84 | + (array)$this->behaviors7); | |
| 85 | 85 | |
| 86 | 86 | return array_filter($behaviors); // strip out false values | 
| 87 | 87 | } | 
| @@ -55,10 +55,10 @@ discard block | ||
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | 57 |    public function setBehaviors($behaviors) { | 
| 58 | -    foreach($behaviors as $category_id => $bhvr_set) { | |
| 58 | +    foreach ($behaviors as $category_id => $bhvr_set) { | |
| 59 | 59 | $attribute = "behaviors$category_id"; | 
| 60 | 60 | $this->$attribute = []; | 
| 61 | -      foreach($bhvr_set as $behavior) { | |
| 61 | +      foreach ($bhvr_set as $behavior) { | |
| 62 | 62 |          $this->{$attribute}[] = $behavior['id']; | 
| 63 | 63 | } | 
| 64 | 64 | } | 
| @@ -66,8 +66,8 @@ discard block | ||
| 66 | 66 | |
| 67 | 67 |    public function validateBehaviors($attribute, $params) { | 
| 68 | 68 |      if (!$this->hasErrors()) { | 
| 69 | -      foreach($this->$attribute as $behavior) { | |
| 70 | -        if(!is_numeric($behavior)) { | |
| 69 | +      foreach ($this->$attribute as $behavior) { | |
| 70 | +        if (!is_numeric($behavior)) { | |
| 71 | 71 | $this->addError($attribute, 'One of your behaviors is not an integer!'); | 
| 72 | 72 | } | 
| 73 | 73 | } | 
| @@ -105,7 +105,7 @@ discard block | ||
| 105 | 105 | |
| 106 | 106 | // delete cached behaviors | 
| 107 | 107 |      array_map(function($period) use ($time) { | 
| 108 | -      $key = "checkins_".Yii::$app->user->id."_{$period}_".$time->getLocalDate(); | |
| 108 | +      $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $time->getLocalDate(); | |
| 109 | 109 | Yii::$app->cache->delete($key); | 
| 110 | 110 | }, [30, 90, 180]); | 
| 111 | 111 | } | 
| @@ -120,7 +120,7 @@ discard block | ||
| 120 | 120 |    public function mergeWithDefault(array $user_behaviors) { | 
| 121 | 121 | $behaviors = AH::index(Yii::$container->get(BehaviorInterface::class)::$behaviors, 'name', "category_id"); | 
| 122 | 122 |      array_walk($behaviors, function(&$bhvrs, $cat_id) use ($user_behaviors) { | 
| 123 | -      if(array_key_exists($cat_id, $user_behaviors)) { | |
| 123 | +      if (array_key_exists($cat_id, $user_behaviors)) { | |
| 124 | 124 | $bhvrs = AH::merge($bhvrs, $user_behaviors[$cat_id]); | 
| 125 | 125 | } | 
| 126 | 126 | }); | 
| @@ -128,14 +128,14 @@ discard block | ||
| 128 | 128 | } | 
| 129 | 129 | |
| 130 | 130 |    public function save() { | 
| 131 | -    if(empty($this->compiled_behaviors)) { | |
| 131 | +    if (empty($this->compiled_behaviors)) { | |
| 132 | 132 | $this->commpiled_behaviors = $this->compileBehaviors(); | 
| 133 | 133 | } | 
| 134 | 134 | |
| 135 | 135 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); | 
| 136 | 136 | |
| 137 | 137 | $rows = []; | 
| 138 | -    foreach($this->compiled_behaviors as $behavior_id) { | |
| 138 | +    foreach ($this->compiled_behaviors as $behavior_id) { | |
| 139 | 139 | $behavior_id = (int)$behavior_id; | 
| 140 | 140 |        $behavior = \common\models\Behavior::getBehavior('id', $behavior_id); | 
| 141 | 141 | $category_id = $behavior['category_id']; | 
| @@ -158,10 +158,10 @@ discard block | ||
| 158 | 158 | )->execute(); | 
| 159 | 159 | |
| 160 | 160 | // if the user has publicised their check-in graph, create the image | 
| 161 | -    if(Yii::$app->user->identity->expose_graph) { | |
| 161 | +    if (Yii::$app->user->identity->expose_graph) { | |
| 162 | 162 | $checkins_last_month = $user_behavior->getCheckInBreakdown(); | 
| 163 | 163 | |
| 164 | -      if($checkins_last_month) { | |
| 164 | +      if ($checkins_last_month) { | |
| 165 | 165 | Yii::$container | 
| 166 | 166 | ->get(\common\components\Graph::class, [Yii::$app->user->identity]) | 
| 167 | 167 | ->create($checkins_last_month, true); | 
| @@ -39,7 +39,7 @@ discard block | ||
| 39 | 39 |      if ($form->load(Yii::$app->request->post()) && $form->validate()) { | 
| 40 | 40 | $form->compiled_behaviors = $form->compileBehaviors(); | 
| 41 | 41 | |
| 42 | -      if(sizeof($form->compiled_behaviors) === 0) { | |
| 42 | +      if (sizeof($form->compiled_behaviors) === 0) { | |
| 43 | 43 | return $this->redirect(['view']); | 
| 44 | 44 | } | 
| 45 | 45 | |
| @@ -49,7 +49,7 @@ discard block | ||
| 49 | 49 | |
| 50 | 50 | return $this->redirect(['questions']); | 
| 51 | 51 |      } else { | 
| 52 | - $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors; | |
| 52 | + $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors; | |
| 53 | 53 |        return $this->render('index', [ | 
| 54 | 54 | 'categories' => Yii::$container->get(CategoryInterface::class)::$categories, | 
| 55 | 55 | 'model' => $form, | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | $date = Yii::$container->get(TimeInterface::class)->getLocalDate(); | 
| 64 | 64 | |
| 65 | 65 | $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date); | 
| 66 | -    if(count($user_behaviors) === 0) { | |
| 66 | +    if (count($user_behaviors) === 0) { | |
| 67 | 67 | return $this->redirect(['view']); | 
| 68 | 68 | } | 
| 69 | 69 | |
| @@ -73,10 +73,10 @@ discard block | ||
| 73 | 73 | $form->deleteToday(); | 
| 74 | 74 | |
| 75 | 75 | $behaviors = $user_behavior->findAll($form->getUserBehaviorIds()); | 
| 76 | -      if($result = $form->saveAnswers($behaviors)) { | |
| 76 | +      if ($result = $form->saveAnswers($behaviors)) { | |
| 77 | 77 | |
| 78 | -        if(Yii::$app->user->identity->send_email) { | |
| 79 | -          if(Yii::$app->user->identity->sendEmailReport($date)) { | |
| 78 | +        if (Yii::$app->user->identity->send_email) { | |
| 79 | +          if (Yii::$app->user->identity->sendEmailReport($date)) { | |
| 80 | 80 |              Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.'); | 
| 81 | 81 |            } else { | 
| 82 | 82 |              Yii::$app->session->setFlash('success', 'Your check-in is complete.'); | 
| @@ -131,7 +131,7 @@ discard block | ||
| 131 | 131 | $raw_pie_data = $user_behavior::decorate($user_behavior->getBehaviorsWithCounts()); | 
| 132 | 132 | $answer_pie = $user_behavior->getBehaviorsByCategory($raw_pie_data); | 
| 133 | 133 | |
| 134 | - $pie_data = [ | |
| 134 | + $pie_data = [ | |
| 135 | 135 | "labels" => array_column($answer_pie, "name"), | 
| 136 | 136 | "datasets" => [[ | 
| 137 | 137 |            "data"                 => array_map('intval', array_column($answer_pie, "count")), | 
| @@ -166,14 +166,14 @@ discard block | ||
| 166 | 166 | $checkins = $user_behavior->getCheckInBreakdown($period); | 
| 167 | 167 | |
| 168 | 168 | $accum = []; | 
| 169 | -    foreach($checkins as $date => $cats) { | |
| 170 | -      for($i = 1; $i <= 7; $i ++) { | |
| 169 | +    foreach ($checkins as $date => $cats) { | |
| 170 | +      for ($i = 1; $i <= 7; $i++) { | |
| 171 | 171 | $accum[$i][] = array_key_exists($i, $cats) ? $cats[$i]['count'] : []; | 
| 172 | 172 | } | 
| 173 | 173 | } | 
| 174 | 174 | |
| 175 | 175 | $bar_datasets = []; | 
| 176 | -    foreach($accum as $idx => $data) { | |
| 176 | +    foreach ($accum as $idx => $data) { | |
| 177 | 177 | $bar_datasets[] = [ | 
| 178 | 178 | 'label' => ($category::getCategories())[$idx], | 
| 179 | 179 | 'backgroundColor' => $category::$colors[$idx]['color'], | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | 'allow' => true, | 
| 28 | 28 | 'roles' => ['@'], | 
| 29 | 29 | ], [ | 
| 30 | - 'actions' => [ 'change-email', ], | |
| 30 | + 'actions' => ['change-email', ], | |
| 31 | 31 | 'allow' => true, | 
| 32 | 32 | ], | 
| 33 | 33 | ], | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | |
| 58 | 58 |      if ($editProfileForm->load(Yii::$app->request->post())) { | 
| 59 | 59 | $saved_user = $editProfileForm->saveProfile(); | 
| 60 | -      if($saved_user) { | |
| 60 | +      if ($saved_user) { | |
| 61 | 61 |          Yii::$app->session->setFlash('success', 'New profile data saved!'); | 
| 62 | 62 | } | 
| 63 | 63 | } | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 | $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]); | 
| 77 | 77 | |
| 78 | 78 |      if ($model->load(Yii::$app->request->post()) && $model->validate()) { | 
| 79 | -      if($model->deleteAccount()) { | |
| 79 | +      if ($model->deleteAccount()) { | |
| 80 | 80 | $this->redirect(['site/index']); | 
| 81 | 81 |        } else { | 
| 82 | 82 |          Yii::$app->session->setFlash('error', 'Wrong password!'); | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]); | 
| 91 | 91 | |
| 92 | 92 |      if ($model->load(Yii::$app->request->post())) { | 
| 93 | -      if($model->validate() && $model->changePassword()) { | |
| 93 | +      if ($model->validate() && $model->changePassword()) { | |
| 94 | 94 |          Yii::$app->session->setFlash('success', 'Password successfully changed'); | 
| 95 | 95 |        } else { | 
| 96 | 96 |          Yii::$app->session->setFlash('error', 'Wrong password!'); | 
| @@ -114,14 +114,14 @@ discard block | ||
| 114 | 114 |    public function actionChangeEmail(string $token) { | 
| 115 | 115 | $user = Yii::$container->get(\common\interfaces\UserInterface::class)->findByChangeEmailToken($token); | 
| 116 | 116 | |
| 117 | -    if($user) { | |
| 117 | +    if ($user) { | |
| 118 | 118 | $validator = new \yii\validators\EmailValidator(); | 
| 119 | -      if($validator->validate($user->desired_email, $error)) { | |
| 119 | +      if ($validator->validate($user->desired_email, $error)) { | |
| 120 | 120 | $user->removeChangeEmailToken(); | 
| 121 | 121 | $user->email = $user->desired_email; | 
| 122 | 122 | $user->desired_email = null; | 
| 123 | 123 | $user->save(); | 
| 124 | -        if(!Yii::$app->user->isGuest) { | |
| 124 | +        if (!Yii::$app->user->isGuest) { | |
| 125 | 125 | Yii::$app->user->logout(); | 
| 126 | 126 |            Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.'); | 
| 127 | 127 |          } else { | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 | |
| 142 | 142 |    public function actionExport() { | 
| 143 | 143 |      header("Content-Type: text/csv"); | 
| 144 | -    header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); | |
| 144 | +    header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); | |
| 145 | 145 | |
| 146 | 146 | $reader = Yii::$app->user->identity->getExportData(); | 
| 147 | 147 |      $fp = fopen('php://output', 'w'); | 
| @@ -157,7 +157,7 @@ discard block | ||
| 157 | 157 | |
| 158 | 158 | fputcsv($fp, $header); | 
| 159 | 159 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); | 
| 160 | -    while($row = $reader->read()) { | |
| 160 | +    while ($row = $reader->read()) { | |
| 161 | 161 | $row = $user_behavior::decorate([$row]); | 
| 162 | 162 | $row = Yii::$app->user->identity->cleanExportData($row); | 
| 163 | 163 | fputcsv($fp, $row[0]); | 
| @@ -19,387 +19,387 @@ | ||
| 19 | 19 | private $time; | 
| 20 | 20 | private $question; | 
| 21 | 21 | |
| 22 | - public $questionData = [ | |
| 23 | - [ | |
| 24 | - 'id' => 641, | |
| 25 | - 'user_id' => 2, | |
| 26 | - 'behavior_id' => 13, | |
| 27 | - 'user_behavior_id' => 821, | |
| 28 | - 'question' => 1, | |
| 29 | - 'answer' => 'alsgn', | |
| 30 | - 'date' => '2016-09-10 19:27:43', | |
| 31 | - 'behavior' => | |
| 32 | - [ | |
| 33 | - 'id' => 13, | |
| 34 | - 'name' => 'less time/energy for God, meetings, and church', | |
| 35 | - 'category_id' => 2, | |
| 36 | - ], | |
| 37 | - ], | |
| 38 | - [ | |
| 39 | - 'id' => 642, | |
| 40 | - 'user_id' => 2, | |
| 41 | - 'behavior_id' => 13, | |
| 42 | - 'user_behavior_id' => 821, | |
| 43 | - 'question' => 2, | |
| 44 | - 'answer' => 'loiun', | |
| 45 | - 'date' => '2016-09-10 19:27:43', | |
| 46 | - 'behavior' => | |
| 47 | - [ | |
| 48 | - 'id' => 13, | |
| 49 | - 'name' => 'less time/energy for God, meetings, and church', | |
| 50 | - 'category_id' => 2, | |
| 51 | - ], | |
| 52 | - ], | |
| 53 | - [ | |
| 54 | - 'id' => 643, | |
| 55 | - 'user_id' => 2, | |
| 56 | - 'behavior_id' => 13, | |
| 57 | - 'user_behavior_id' => 821, | |
| 58 | - 'question' => 3, | |
| 59 | - 'answer' => 'liun', | |
| 60 | - 'date' => '2016-09-10 19:27:43', | |
| 61 | - 'behavior' => | |
| 62 | - [ | |
| 63 | - 'id' => 13, | |
| 64 | - 'name' => 'less time/energy for God, meetings, and church', | |
| 65 | - 'category_id' => 2, | |
| 66 | - ], | |
| 67 | - ], | |
| 68 | - [ | |
| 69 | - 'id' => 644, | |
| 70 | - 'user_id' => 2, | |
| 71 | - 'behavior_id' => 29, | |
| 72 | - 'user_behavior_id' => 823, | |
| 73 | - 'question' => 1, | |
| 74 | - 'answer' => 'ljnb', | |
| 75 | - 'date' => '2016-09-10 19:27:43', | |
| 76 | - 'behavior' => | |
| 77 | - [ | |
| 78 | - 'id' => 29, | |
| 79 | - 'name' => 'using profanity', | |
| 80 | - 'category_id' => 3, | |
| 81 | - ], | |
| 82 | - ], | |
| 83 | - [ | |
| 84 | - 'id' => 645, | |
| 85 | - 'user_id' => 2, | |
| 86 | - 'behavior_id' => 29, | |
| 87 | - 'user_behavior_id' => 823, | |
| 88 | - 'question' => 2, | |
| 89 | - 'answer' => 'liunb', | |
| 90 | - 'date' => '2016-09-10 19:27:43', | |
| 91 | - 'behavior' => | |
| 92 | - [ | |
| 93 | - 'id' => 29, | |
| 94 | - 'name' => 'using profanity', | |
| 95 | - 'category_id' => 3, | |
| 96 | - ], | |
| 97 | - ], | |
| 98 | - [ | |
| 99 | - 'id' => 646, | |
| 100 | - 'user_id' => 2, | |
| 101 | - 'behavior_id' => 29, | |
| 102 | - 'user_behavior_id' => 823, | |
| 103 | - 'question' => 3, | |
| 104 | - 'answer' => 'ilub ', | |
| 105 | - 'date' => '2016-09-10 19:27:43', | |
| 106 | - 'behavior' => | |
| 107 | - [ | |
| 108 | - 'id' => 29, | |
| 109 | - 'name' => 'using profanity', | |
| 110 | - 'category_id' => 3, | |
| 111 | - ], | |
| 112 | - ], | |
| 113 | - [ | |
| 114 | - 'id' => 647, | |
| 115 | - 'user_id' => 2, | |
| 116 | - 'behavior_id' => 48, | |
| 117 | - 'user_behavior_id' => 825, | |
| 118 | - 'question' => 1, | |
| 119 | - 'answer' => 'liub', | |
| 120 | - 'date' => '2016-09-10 19:27:43', | |
| 121 | - 'behavior' => | |
| 122 | - [ | |
| 123 | - 'id' => 48, | |
| 124 | - 'name' => 'workaholic', | |
| 125 | - 'category_id' => 4, | |
| 126 | - ], | |
| 127 | - ], | |
| 128 | - [ | |
| 129 | - 'id' => 648, | |
| 130 | - 'user_id' => 2, | |
| 131 | - 'behavior_id' => 48, | |
| 132 | - 'user_behavior_id' => 825, | |
| 133 | - 'question' => 2, | |
| 134 | - 'answer' => 'liub', | |
| 135 | - 'date' => '2016-09-10 19:27:43', | |
| 136 | - 'behavior' => | |
| 137 | - [ | |
| 138 | - 'id' => 48, | |
| 139 | - 'name' => 'workaholic', | |
| 140 | - 'category_id' => 4, | |
| 141 | - ], | |
| 142 | - ], | |
| 143 | - [ | |
| 144 | - 'id' => 649, | |
| 145 | - 'user_id' => 2, | |
| 146 | - 'behavior_id' => 48, | |
| 147 | - 'user_behavior_id' => 825, | |
| 148 | - 'question' => 3, | |
| 149 | - 'answer' => 'liub ', | |
| 150 | - 'date' => '2016-09-10 19:27:43', | |
| 151 | - 'behavior' => | |
| 152 | - [ | |
| 153 | - 'id' => 48, | |
| 154 | - 'name' => 'workaholic', | |
| 155 | - 'category_id' => 4, | |
| 156 | - ], | |
| 157 | - ], | |
| 158 | - [ | |
| 159 | - 'id' => 650, | |
| 160 | - 'user_id' => 2, | |
| 161 | - 'behavior_id' => 89, | |
| 162 | - 'user_behavior_id' => 828, | |
| 163 | - 'question' => 1, | |
| 164 | - 'answer' => 'liub', | |
| 165 | - 'date' => '2016-09-10 19:27:43', | |
| 166 | - 'behavior' => | |
| 167 | - [ | |
| 168 | - 'id' => 89, | |
| 169 | - 'name' => 'obsessive (stuck) thoughts', | |
| 170 | - 'category_id' => 5, | |
| 171 | - ], | |
| 172 | - ], | |
| 173 | - [ | |
| 174 | - 'id' => 651, | |
| 175 | - 'user_id' => 2, | |
| 176 | - 'behavior_id' => 89, | |
| 177 | - 'user_behavior_id' => 828, | |
| 178 | - 'question' => 2, | |
| 179 | - 'answer' => 'liuby', | |
| 180 | - 'date' => '2016-09-10 19:27:43', | |
| 181 | - 'behavior' => | |
| 182 | - [ | |
| 183 | - 'id' => 89, | |
| 184 | - 'name' => 'obsessive (stuck) thoughts', | |
| 185 | - 'category_id' => 5, | |
| 186 | - ], | |
| 187 | - ], | |
| 188 | - [ | |
| 189 | - 'id' => 652, | |
| 190 | - 'user_id' => 2, | |
| 191 | - 'behavior_id' => 89, | |
| 192 | - 'user_behavior_id' => 828, | |
| 193 | - 'question' => 3, | |
| 194 | - 'answer' => 'uiylb', | |
| 195 | - 'date' => '2016-09-10 19:27:43', | |
| 196 | - 'behavior' => | |
| 197 | - [ | |
| 198 | - 'id' => 89, | |
| 199 | - 'name' => 'obsessive (stuck) thoughts', | |
| 200 | - 'category_id' => 5, | |
| 201 | - ], | |
| 202 | - ], | |
| 203 | - [ | |
| 204 | - 'id' => 653, | |
| 205 | - 'user_id' => 2, | |
| 206 | - 'behavior_id' => 111, | |
| 207 | - 'user_behavior_id' => 829, | |
| 208 | - 'question' => 1, | |
| 209 | - 'answer' => 'liub', | |
| 210 | - 'date' => '2016-09-10 19:27:43', | |
| 211 | - 'behavior' => | |
| 212 | - [ | |
| 213 | - 'id' => 111, | |
| 214 | - 'name' => 'seeking out old unhealthy people and places', | |
| 215 | - 'category_id' => 6, | |
| 216 | - ], | |
| 217 | - ], | |
| 218 | - [ | |
| 219 | - 'id' => 654, | |
| 220 | - 'user_id' => 2, | |
| 221 | - 'behavior_id' => 111, | |
| 222 | - 'user_behavior_id' => 829, | |
| 223 | - 'question' => 2, | |
| 224 | - 'answer' => 'liuyb', | |
| 225 | - 'date' => '2016-09-10 19:27:43', | |
| 226 | - 'behavior' => | |
| 227 | - [ | |
| 228 | - 'id' => 111, | |
| 229 | - 'name' => 'seeking out old unhealthy people and places', | |
| 230 | - 'category_id' => 6, | |
| 231 | - ], | |
| 232 | - ], | |
| 233 | - [ | |
| 234 | - 'id' => 655, | |
| 235 | - 'user_id' => 2, | |
| 236 | - 'behavior_id' => 111, | |
| 237 | - 'user_behavior_id' => 829, | |
| 238 | - 'question' => 3, | |
| 239 | - 'answer' => 'iuyb', | |
| 240 | - 'date' => '2016-09-10 19:27:43', | |
| 241 | - 'behavior' => | |
| 242 | - [ | |
| 243 | - 'id' => 111, | |
| 244 | - 'name' => 'seeking out old unhealthy people and places', | |
| 245 | - 'category_id' => 6, | |
| 246 | - ], | |
| 247 | - ], | |
| 248 | - [ | |
| 249 | - 'id' => 656, | |
| 250 | - 'user_id' => 2, | |
| 251 | - 'behavior_id' => 122, | |
| 252 | - 'user_behavior_id' => 831, | |
| 253 | - 'question' => 1, | |
| 254 | - 'answer' => 'iuyb', | |
| 255 | - 'date' => '2016-09-10 19:27:43', | |
| 256 | - 'behavior' => | |
| 257 | - [ | |
| 258 | - 'id' => 122, | |
| 259 | - 'name' => 'returning to the place you swore you would never go again', | |
| 260 | - 'category_id' => 7, | |
| 261 | - ], | |
| 262 | - ], | |
| 263 | - [ | |
| 264 | - 'id' => 657, | |
| 265 | - 'user_id' => 2, | |
| 266 | - 'behavior_id' => 122, | |
| 267 | - 'user_behavior_id' => 831, | |
| 268 | - 'question' => 2, | |
| 269 | - 'answer' => 'iuyb', | |
| 270 | - 'date' => '2016-09-10 19:27:43', | |
| 271 | - 'behavior' => | |
| 272 | - [ | |
| 273 | - 'id' => 122, | |
| 274 | - 'name' => 'returning to the place you swore you would never go again', | |
| 275 | - 'category_id' => 7, | |
| 276 | - ], | |
| 277 | - ], | |
| 278 | - [ | |
| 279 | - 'id' => 658, | |
| 280 | - 'user_id' => 2, | |
| 281 | - 'behavior_id' => 122, | |
| 282 | - 'user_behavior_id' => 831, | |
| 283 | - 'question' => 3, | |
| 284 | - 'answer' => 'liuyb', | |
| 285 | - 'date' => '2016-09-10 19:27:43', | |
| 286 | - 'behavior' => | |
| 287 | - [ | |
| 288 | - 'id' => 122, | |
| 289 | - 'name' => 'returning to the place you swore you would never go again', | |
| 290 | - 'category_id' => 7, | |
| 291 | - ], | |
| 292 | - ], | |
| 22 | + public $questionData = [ | |
| 23 | + [ | |
| 24 | + 'id' => 641, | |
| 25 | + 'user_id' => 2, | |
| 26 | + 'behavior_id' => 13, | |
| 27 | + 'user_behavior_id' => 821, | |
| 28 | + 'question' => 1, | |
| 29 | + 'answer' => 'alsgn', | |
| 30 | + 'date' => '2016-09-10 19:27:43', | |
| 31 | + 'behavior' => | |
| 32 | + [ | |
| 33 | + 'id' => 13, | |
| 34 | + 'name' => 'less time/energy for God, meetings, and church', | |
| 35 | + 'category_id' => 2, | |
| 36 | + ], | |
| 37 | + ], | |
| 38 | + [ | |
| 39 | + 'id' => 642, | |
| 40 | + 'user_id' => 2, | |
| 41 | + 'behavior_id' => 13, | |
| 42 | + 'user_behavior_id' => 821, | |
| 43 | + 'question' => 2, | |
| 44 | + 'answer' => 'loiun', | |
| 45 | + 'date' => '2016-09-10 19:27:43', | |
| 46 | + 'behavior' => | |
| 47 | + [ | |
| 48 | + 'id' => 13, | |
| 49 | + 'name' => 'less time/energy for God, meetings, and church', | |
| 50 | + 'category_id' => 2, | |
| 51 | + ], | |
| 52 | + ], | |
| 53 | + [ | |
| 54 | + 'id' => 643, | |
| 55 | + 'user_id' => 2, | |
| 56 | + 'behavior_id' => 13, | |
| 57 | + 'user_behavior_id' => 821, | |
| 58 | + 'question' => 3, | |
| 59 | + 'answer' => 'liun', | |
| 60 | + 'date' => '2016-09-10 19:27:43', | |
| 61 | + 'behavior' => | |
| 62 | + [ | |
| 63 | + 'id' => 13, | |
| 64 | + 'name' => 'less time/energy for God, meetings, and church', | |
| 65 | + 'category_id' => 2, | |
| 66 | + ], | |
| 67 | + ], | |
| 68 | + [ | |
| 69 | + 'id' => 644, | |
| 70 | + 'user_id' => 2, | |
| 71 | + 'behavior_id' => 29, | |
| 72 | + 'user_behavior_id' => 823, | |
| 73 | + 'question' => 1, | |
| 74 | + 'answer' => 'ljnb', | |
| 75 | + 'date' => '2016-09-10 19:27:43', | |
| 76 | + 'behavior' => | |
| 77 | + [ | |
| 78 | + 'id' => 29, | |
| 79 | + 'name' => 'using profanity', | |
| 80 | + 'category_id' => 3, | |
| 81 | + ], | |
| 82 | + ], | |
| 83 | + [ | |
| 84 | + 'id' => 645, | |
| 85 | + 'user_id' => 2, | |
| 86 | + 'behavior_id' => 29, | |
| 87 | + 'user_behavior_id' => 823, | |
| 88 | + 'question' => 2, | |
| 89 | + 'answer' => 'liunb', | |
| 90 | + 'date' => '2016-09-10 19:27:43', | |
| 91 | + 'behavior' => | |
| 92 | + [ | |
| 93 | + 'id' => 29, | |
| 94 | + 'name' => 'using profanity', | |
| 95 | + 'category_id' => 3, | |
| 96 | + ], | |
| 97 | + ], | |
| 98 | + [ | |
| 99 | + 'id' => 646, | |
| 100 | + 'user_id' => 2, | |
| 101 | + 'behavior_id' => 29, | |
| 102 | + 'user_behavior_id' => 823, | |
| 103 | + 'question' => 3, | |
| 104 | + 'answer' => 'ilub ', | |
| 105 | + 'date' => '2016-09-10 19:27:43', | |
| 106 | + 'behavior' => | |
| 107 | + [ | |
| 108 | + 'id' => 29, | |
| 109 | + 'name' => 'using profanity', | |
| 110 | + 'category_id' => 3, | |
| 111 | + ], | |
| 112 | + ], | |
| 113 | + [ | |
| 114 | + 'id' => 647, | |
| 115 | + 'user_id' => 2, | |
| 116 | + 'behavior_id' => 48, | |
| 117 | + 'user_behavior_id' => 825, | |
| 118 | + 'question' => 1, | |
| 119 | + 'answer' => 'liub', | |
| 120 | + 'date' => '2016-09-10 19:27:43', | |
| 121 | + 'behavior' => | |
| 122 | + [ | |
| 123 | + 'id' => 48, | |
| 124 | + 'name' => 'workaholic', | |
| 125 | + 'category_id' => 4, | |
| 126 | + ], | |
| 127 | + ], | |
| 128 | + [ | |
| 129 | + 'id' => 648, | |
| 130 | + 'user_id' => 2, | |
| 131 | + 'behavior_id' => 48, | |
| 132 | + 'user_behavior_id' => 825, | |
| 133 | + 'question' => 2, | |
| 134 | + 'answer' => 'liub', | |
| 135 | + 'date' => '2016-09-10 19:27:43', | |
| 136 | + 'behavior' => | |
| 137 | + [ | |
| 138 | + 'id' => 48, | |
| 139 | + 'name' => 'workaholic', | |
| 140 | + 'category_id' => 4, | |
| 141 | + ], | |
| 142 | + ], | |
| 143 | + [ | |
| 144 | + 'id' => 649, | |
| 145 | + 'user_id' => 2, | |
| 146 | + 'behavior_id' => 48, | |
| 147 | + 'user_behavior_id' => 825, | |
| 148 | + 'question' => 3, | |
| 149 | + 'answer' => 'liub ', | |
| 150 | + 'date' => '2016-09-10 19:27:43', | |
| 151 | + 'behavior' => | |
| 152 | + [ | |
| 153 | + 'id' => 48, | |
| 154 | + 'name' => 'workaholic', | |
| 155 | + 'category_id' => 4, | |
| 156 | + ], | |
| 157 | + ], | |
| 158 | + [ | |
| 159 | + 'id' => 650, | |
| 160 | + 'user_id' => 2, | |
| 161 | + 'behavior_id' => 89, | |
| 162 | + 'user_behavior_id' => 828, | |
| 163 | + 'question' => 1, | |
| 164 | + 'answer' => 'liub', | |
| 165 | + 'date' => '2016-09-10 19:27:43', | |
| 166 | + 'behavior' => | |
| 167 | + [ | |
| 168 | + 'id' => 89, | |
| 169 | + 'name' => 'obsessive (stuck) thoughts', | |
| 170 | + 'category_id' => 5, | |
| 171 | + ], | |
| 172 | + ], | |
| 173 | + [ | |
| 174 | + 'id' => 651, | |
| 175 | + 'user_id' => 2, | |
| 176 | + 'behavior_id' => 89, | |
| 177 | + 'user_behavior_id' => 828, | |
| 178 | + 'question' => 2, | |
| 179 | + 'answer' => 'liuby', | |
| 180 | + 'date' => '2016-09-10 19:27:43', | |
| 181 | + 'behavior' => | |
| 182 | + [ | |
| 183 | + 'id' => 89, | |
| 184 | + 'name' => 'obsessive (stuck) thoughts', | |
| 185 | + 'category_id' => 5, | |
| 186 | + ], | |
| 187 | + ], | |
| 188 | + [ | |
| 189 | + 'id' => 652, | |
| 190 | + 'user_id' => 2, | |
| 191 | + 'behavior_id' => 89, | |
| 192 | + 'user_behavior_id' => 828, | |
| 193 | + 'question' => 3, | |
| 194 | + 'answer' => 'uiylb', | |
| 195 | + 'date' => '2016-09-10 19:27:43', | |
| 196 | + 'behavior' => | |
| 197 | + [ | |
| 198 | + 'id' => 89, | |
| 199 | + 'name' => 'obsessive (stuck) thoughts', | |
| 200 | + 'category_id' => 5, | |
| 201 | + ], | |
| 202 | + ], | |
| 203 | + [ | |
| 204 | + 'id' => 653, | |
| 205 | + 'user_id' => 2, | |
| 206 | + 'behavior_id' => 111, | |
| 207 | + 'user_behavior_id' => 829, | |
| 208 | + 'question' => 1, | |
| 209 | + 'answer' => 'liub', | |
| 210 | + 'date' => '2016-09-10 19:27:43', | |
| 211 | + 'behavior' => | |
| 212 | + [ | |
| 213 | + 'id' => 111, | |
| 214 | + 'name' => 'seeking out old unhealthy people and places', | |
| 215 | + 'category_id' => 6, | |
| 216 | + ], | |
| 217 | + ], | |
| 218 | + [ | |
| 219 | + 'id' => 654, | |
| 220 | + 'user_id' => 2, | |
| 221 | + 'behavior_id' => 111, | |
| 222 | + 'user_behavior_id' => 829, | |
| 223 | + 'question' => 2, | |
| 224 | + 'answer' => 'liuyb', | |
| 225 | + 'date' => '2016-09-10 19:27:43', | |
| 226 | + 'behavior' => | |
| 227 | + [ | |
| 228 | + 'id' => 111, | |
| 229 | + 'name' => 'seeking out old unhealthy people and places', | |
| 230 | + 'category_id' => 6, | |
| 231 | + ], | |
| 232 | + ], | |
| 233 | + [ | |
| 234 | + 'id' => 655, | |
| 235 | + 'user_id' => 2, | |
| 236 | + 'behavior_id' => 111, | |
| 237 | + 'user_behavior_id' => 829, | |
| 238 | + 'question' => 3, | |
| 239 | + 'answer' => 'iuyb', | |
| 240 | + 'date' => '2016-09-10 19:27:43', | |
| 241 | + 'behavior' => | |
| 242 | + [ | |
| 243 | + 'id' => 111, | |
| 244 | + 'name' => 'seeking out old unhealthy people and places', | |
| 245 | + 'category_id' => 6, | |
| 246 | + ], | |
| 247 | + ], | |
| 248 | + [ | |
| 249 | + 'id' => 656, | |
| 250 | + 'user_id' => 2, | |
| 251 | + 'behavior_id' => 122, | |
| 252 | + 'user_behavior_id' => 831, | |
| 253 | + 'question' => 1, | |
| 254 | + 'answer' => 'iuyb', | |
| 255 | + 'date' => '2016-09-10 19:27:43', | |
| 256 | + 'behavior' => | |
| 257 | + [ | |
| 258 | + 'id' => 122, | |
| 259 | + 'name' => 'returning to the place you swore you would never go again', | |
| 260 | + 'category_id' => 7, | |
| 261 | + ], | |
| 262 | + ], | |
| 263 | + [ | |
| 264 | + 'id' => 657, | |
| 265 | + 'user_id' => 2, | |
| 266 | + 'behavior_id' => 122, | |
| 267 | + 'user_behavior_id' => 831, | |
| 268 | + 'question' => 2, | |
| 269 | + 'answer' => 'iuyb', | |
| 270 | + 'date' => '2016-09-10 19:27:43', | |
| 271 | + 'behavior' => | |
| 272 | + [ | |
| 273 | + 'id' => 122, | |
| 274 | + 'name' => 'returning to the place you swore you would never go again', | |
| 275 | + 'category_id' => 7, | |
| 276 | + ], | |
| 277 | + ], | |
| 278 | + [ | |
| 279 | + 'id' => 658, | |
| 280 | + 'user_id' => 2, | |
| 281 | + 'behavior_id' => 122, | |
| 282 | + 'user_behavior_id' => 831, | |
| 283 | + 'question' => 3, | |
| 284 | + 'answer' => 'liuyb', | |
| 285 | + 'date' => '2016-09-10 19:27:43', | |
| 286 | + 'behavior' => | |
| 287 | + [ | |
| 288 | + 'id' => 122, | |
| 289 | + 'name' => 'returning to the place you swore you would never go again', | |
| 290 | + 'category_id' => 7, | |
| 291 | + ], | |
| 292 | + ], | |
| 293 | 293 | ]; | 
| 294 | 294 | public $userQuestions = [ | 
| 295 | - 13 => [ | |
| 296 | - 'question' => [ | |
| 297 | - 'id' => 13, | |
| 298 | - 'title' => 'less time/energy for God, meetings, and church', | |
| 299 | - ], | |
| 300 | - 'answers' => [ | |
| 301 | - [ | |
| 302 | - 'title' => 'How does it affect me? How do I act and feel?', | |
| 303 | - 'answer' => 'alsgn', | |
| 304 | - ], [ | |
| 305 | - 'title' => 'How does it affect the important people in my life?', | |
| 306 | - 'answer' => 'loiun', | |
| 307 | - ], [ | |
| 308 | - 'title' => 'Why do I do this? What is the benefit for me?', | |
| 309 | - 'answer' => 'liun', | |
| 310 | - ], | |
| 311 | - ], | |
| 312 | - ], | |
| 313 | - 29 => [ | |
| 314 | - 'question' => [ | |
| 315 | - 'id' => 29, | |
| 316 | - 'title' => 'using profanity', | |
| 317 | - ], | |
| 318 | - 'answers' => [ | |
| 319 | - [ | |
| 320 | - 'title' => 'How does it affect me? How do I act and feel?', | |
| 321 | - 'answer' => 'ljnb', | |
| 322 | - ], [ | |
| 323 | - 'title' => 'How does it affect the important people in my life?', | |
| 324 | - 'answer' => 'liunb', | |
| 325 | - ], [ | |
| 326 | - 'title' => 'Why do I do this? What is the benefit for me?', | |
| 327 | - 'answer' => 'ilub ', | |
| 328 | - ], | |
| 329 | - ], | |
| 330 | - ], | |
| 331 | - 48 => [ | |
| 332 | - 'question' => [ | |
| 333 | - 'id' => 48, | |
| 334 | - 'title' => 'workaholic', | |
| 335 | - ], | |
| 336 | - 'answers' => [ | |
| 337 | - [ | |
| 338 | - 'title' => 'How does it affect me? How do I act and feel?', | |
| 339 | - 'answer' => 'liub', | |
| 340 | - ], [ | |
| 341 | - 'title' => 'How does it affect the important people in my life?', | |
| 342 | - 'answer' => 'liub', | |
| 343 | - ], [ | |
| 344 | - 'title' => 'Why do I do this? What is the benefit for me?', | |
| 345 | - 'answer' => 'liub ', | |
| 346 | - ], | |
| 347 | - ], | |
| 348 | - ], | |
| 349 | - 89 => [ | |
| 350 | - 'question' => [ | |
| 351 | - 'id' => 89, | |
| 352 | - 'title' => 'obsessive (stuck) thoughts', | |
| 353 | - ], | |
| 354 | - 'answers' => [ | |
| 355 | - [ | |
| 356 | - 'title' => 'How does it affect me? How do I act and feel?', | |
| 357 | - 'answer' => 'liub', | |
| 358 | - ], [ | |
| 359 | - 'title' => 'How does it affect the important people in my life?', | |
| 360 | - 'answer' => 'liuby', | |
| 361 | - ], [ | |
| 362 | - 'title' => 'Why do I do this? What is the benefit for me?', | |
| 363 | - 'answer' => 'uiylb', | |
| 364 | - ], | |
| 365 | - ], | |
| 366 | - ], | |
| 367 | - 111 => [ | |
| 368 | - 'question' => [ | |
| 369 | - 'id' => 111, | |
| 370 | - 'title' => 'seeking out old unhealthy people and places', | |
| 371 | - ], | |
| 372 | - 'answers' => [ | |
| 373 | - [ | |
| 374 | - 'title' => 'How does it affect me? How do I act and feel?', | |
| 375 | - 'answer' => 'liub', | |
| 376 | - ], [ | |
| 377 | - 'title' => 'How does it affect the important people in my life?', | |
| 378 | - 'answer' => 'liuyb', | |
| 379 | - ], [ | |
| 380 | - 'title' => 'Why do I do this? What is the benefit for me?', | |
| 381 | - 'answer' => 'iuyb', | |
| 382 | - ], | |
| 383 | - ], | |
| 384 | - ], | |
| 385 | - 122 => [ | |
| 386 | - 'question' => [ | |
| 387 | - 'id' => 122, | |
| 388 | - 'title' => 'returning to the place you swore you would never go again', | |
| 389 | - ], | |
| 390 | - 'answers' => [ | |
| 391 | - [ | |
| 392 | - 'title' => 'How does it affect me? How do I act and feel?', | |
| 393 | - 'answer' => 'iuyb', | |
| 394 | - ], [ | |
| 395 | - 'title' => 'How does it affect the important people in my life?', | |
| 396 | - 'answer' => 'iuyb', | |
| 397 | - ], [ | |
| 398 | - 'title' => 'Why do I do this? What is the benefit for me?', | |
| 399 | - 'answer' => 'liuyb', | |
| 400 | - ], | |
| 401 | - ], | |
| 402 | - ], | |
| 295 | + 13 => [ | |
| 296 | + 'question' => [ | |
| 297 | + 'id' => 13, | |
| 298 | + 'title' => 'less time/energy for God, meetings, and church', | |
| 299 | + ], | |
| 300 | + 'answers' => [ | |
| 301 | + [ | |
| 302 | + 'title' => 'How does it affect me? How do I act and feel?', | |
| 303 | + 'answer' => 'alsgn', | |
| 304 | + ], [ | |
| 305 | + 'title' => 'How does it affect the important people in my life?', | |
| 306 | + 'answer' => 'loiun', | |
| 307 | + ], [ | |
| 308 | + 'title' => 'Why do I do this? What is the benefit for me?', | |
| 309 | + 'answer' => 'liun', | |
| 310 | + ], | |
| 311 | + ], | |
| 312 | + ], | |
| 313 | + 29 => [ | |
| 314 | + 'question' => [ | |
| 315 | + 'id' => 29, | |
| 316 | + 'title' => 'using profanity', | |
| 317 | + ], | |
| 318 | + 'answers' => [ | |
| 319 | + [ | |
| 320 | + 'title' => 'How does it affect me? How do I act and feel?', | |
| 321 | + 'answer' => 'ljnb', | |
| 322 | + ], [ | |
| 323 | + 'title' => 'How does it affect the important people in my life?', | |
| 324 | + 'answer' => 'liunb', | |
| 325 | + ], [ | |
| 326 | + 'title' => 'Why do I do this? What is the benefit for me?', | |
| 327 | + 'answer' => 'ilub ', | |
| 328 | + ], | |
| 329 | + ], | |
| 330 | + ], | |
| 331 | + 48 => [ | |
| 332 | + 'question' => [ | |
| 333 | + 'id' => 48, | |
| 334 | + 'title' => 'workaholic', | |
| 335 | + ], | |
| 336 | + 'answers' => [ | |
| 337 | + [ | |
| 338 | + 'title' => 'How does it affect me? How do I act and feel?', | |
| 339 | + 'answer' => 'liub', | |
| 340 | + ], [ | |
| 341 | + 'title' => 'How does it affect the important people in my life?', | |
| 342 | + 'answer' => 'liub', | |
| 343 | + ], [ | |
| 344 | + 'title' => 'Why do I do this? What is the benefit for me?', | |
| 345 | + 'answer' => 'liub ', | |
| 346 | + ], | |
| 347 | + ], | |
| 348 | + ], | |
| 349 | + 89 => [ | |
| 350 | + 'question' => [ | |
| 351 | + 'id' => 89, | |
| 352 | + 'title' => 'obsessive (stuck) thoughts', | |
| 353 | + ], | |
| 354 | + 'answers' => [ | |
| 355 | + [ | |
| 356 | + 'title' => 'How does it affect me? How do I act and feel?', | |
| 357 | + 'answer' => 'liub', | |
| 358 | + ], [ | |
| 359 | + 'title' => 'How does it affect the important people in my life?', | |
| 360 | + 'answer' => 'liuby', | |
| 361 | + ], [ | |
| 362 | + 'title' => 'Why do I do this? What is the benefit for me?', | |
| 363 | + 'answer' => 'uiylb', | |
| 364 | + ], | |
| 365 | + ], | |
| 366 | + ], | |
| 367 | + 111 => [ | |
| 368 | + 'question' => [ | |
| 369 | + 'id' => 111, | |
| 370 | + 'title' => 'seeking out old unhealthy people and places', | |
| 371 | + ], | |
| 372 | + 'answers' => [ | |
| 373 | + [ | |
| 374 | + 'title' => 'How does it affect me? How do I act and feel?', | |
| 375 | + 'answer' => 'liub', | |
| 376 | + ], [ | |
| 377 | + 'title' => 'How does it affect the important people in my life?', | |
| 378 | + 'answer' => 'liuyb', | |
| 379 | + ], [ | |
| 380 | + 'title' => 'Why do I do this? What is the benefit for me?', | |
| 381 | + 'answer' => 'iuyb', | |
| 382 | + ], | |
| 383 | + ], | |
| 384 | + ], | |
| 385 | + 122 => [ | |
| 386 | + 'question' => [ | |
| 387 | + 'id' => 122, | |
| 388 | + 'title' => 'returning to the place you swore you would never go again', | |
| 389 | + ], | |
| 390 | + 'answers' => [ | |
| 391 | + [ | |
| 392 | + 'title' => 'How does it affect me? How do I act and feel?', | |
| 393 | + 'answer' => 'iuyb', | |
| 394 | + ], [ | |
| 395 | + 'title' => 'How does it affect the important people in my life?', | |
| 396 | + 'answer' => 'iuyb', | |
| 397 | + ], [ | |
| 398 | + 'title' => 'Why do I do this? What is the benefit for me?', | |
| 399 | + 'answer' => 'liuyb', | |
| 400 | + ], | |
| 401 | + ], | |
| 402 | + ], | |
| 403 | 403 | ]; | 
| 404 | 404 | |
| 405 | 405 | public $exportData = [ | 
| @@ -470,7 +470,7 @@ discard block | ||
| 470 | 470 | $this->container = new \yii\di\Container; | 
| 471 | 471 |      $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); | 
| 472 | 472 |      $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); | 
| 473 | -    $this->container->set('common\interfaces\TimeInterface', function () { | |
| 473 | +    $this->container->set('common\interfaces\TimeInterface', function() { | |
| 474 | 474 |        return new \common\components\Time('America/Los_Angeles'); | 
| 475 | 475 | }); | 
| 476 | 476 | |
| @@ -516,14 +516,14 @@ discard block | ||
| 516 | 516 | } | 
| 517 | 517 | |
| 518 | 518 |    public function testParseQuestionData() { | 
| 519 | -    $this->specify('parseQuestionData should function correctly', function () { | |
| 519 | +    $this->specify('parseQuestionData should function correctly', function() { | |
| 520 | 520 |        expect('parseQuestionData should return the correct structure with expected data', $this->assertEquals($this->user->parseQuestionData($this->questionData), $this->userQuestions)); | 
| 521 | 521 |        expect('parseQuestionData should return empty with the empty set', $this->assertEmpty($this->user->parseQuestionData([]))); | 
| 522 | 522 | }); | 
| 523 | 523 | } | 
| 524 | 524 | |
| 525 | 525 |    public function testIsTokenCurrent() { | 
| 526 | -    $this->specify('isTokenCurrent should function correctly', function () { | |
| 526 | +    $this->specify('isTokenCurrent should function correctly', function() { | |
| 527 | 527 | $good_token = \Yii::$app | 
| 528 | 528 | ->getSecurity() | 
| 529 | 529 | ->generateRandomString() . '_' . time(); | 
| @@ -557,7 +557,7 @@ discard block | ||
| 557 | 557 |    public function testConfirmVerifyEmailToken() { | 
| 558 | 558 | $this->user->verify_email_token = 'hello_world'; | 
| 559 | 559 | $this->user->confirmVerifyEmailToken(); | 
| 560 | -    expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world'.$this->user::CONFIRMED_STRING)); | |
| 560 | +    expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world' . $this->user::CONFIRMED_STRING)); | |
| 561 | 561 | } | 
| 562 | 562 | |
| 563 | 563 |    public function testIsVerified() { | 
| @@ -651,7 +651,7 @@ discard block | ||
| 651 | 651 | ->disableOriginalConstructor() | 
| 652 | 652 | ->setMethods(['save', 'attributes', 'getCheckinBreakdown']) | 
| 653 | 653 | ->getMock(); | 
| 654 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); | |
| 654 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); | |
| 655 | 655 |      $user_behavior->method('getCheckinBreakdown')->willReturn($expected); | 
| 656 | 656 | |
| 657 | 657 |      $user = $this->getMockBuilder('\common\models\User') | 
| @@ -449,6 +449,6 @@ | ||
| 449 | 449 | $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php'); | 
| 450 | 450 | $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); | 
| 451 | 451 |      $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs); | 
| 452 | -		expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown())); | |
| 452 | +    expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown())); | |
| 453 | 453 | } | 
| 454 | 454 | } | 
| @@ -287,7 +287,7 @@ discard block | ||
| 287 | 287 | |
| 288 | 288 |    public function setUp() { | 
| 289 | 289 | // pull in test data | 
| 290 | - $data = require(__DIR__.'/../data/checkinData.php'); | |
| 290 | + $data = require(__DIR__ . '/../data/checkinData.php'); | |
| 291 | 291 | $this->singleBhvr = $data['singleBhvr']; | 
| 292 | 292 | $this->manyBhvrs = $data['manyBhvrs']; | 
| 293 | 293 | $this->allBhvrs = $data['allBhvrs']; | 
| @@ -297,7 +297,7 @@ discard block | ||
| 297 | 297 |      $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); | 
| 298 | 298 |      $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion'); | 
| 299 | 299 |      $this->container->set('common\interfaces\BehaviorInterface', 'common\models\Behavior'); | 
| 300 | -    $this->container->set('common\interfaces\TimeInterface', function () { | |
| 300 | +    $this->container->set('common\interfaces\TimeInterface', function() { | |
| 301 | 301 |          return new \common\components\Time('America/Los_Angeles'); | 
| 302 | 302 | }); | 
| 303 | 303 | |
| @@ -446,8 +446,8 @@ discard block | ||
| 446 | 446 | ->setMethods(['getIsNewRecord', 'save', 'getBehaviorsWithCounts']) | 
| 447 | 447 | ->getMock(); | 
| 448 | 448 | |
| 449 | - $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php'); | |
| 450 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); | |
| 449 | + $bhvrs = require(__DIR__ . '/../data/behaviorsWithCounts.php'); | |
| 450 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); | |
| 451 | 451 |      $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs); | 
| 452 | 452 |  		expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown())); | 
| 453 | 453 | } |