@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | use _generated\UnitTesterActions; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Define custom actions here |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * Define custom actions here |
|
| 25 | + */ |
|
| 26 | 26 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); |
| 8 | 8 | require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); |
| 9 | 9 | |
| 10 | - Yii::setAlias('@web', '/'); |
|
| 10 | + Yii::setAlias('@web', '/'); |
|
| 11 | 11 | |
| 12 | 12 | require(YII_APP_BASE_PATH . '/common/config/aliases.php'); |
| 13 | 13 | Yii::setAlias('@tests', dirname(__DIR__)); |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | <th style="Margin:0;color:#0a0a0a;font-family:Lato,Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> |
| 126 | 126 | |
| 127 | 127 | <?php |
| 128 | -if($questions) { |
|
| 129 | - foreach($questions as $behavior_id => $behavior_questions) { |
|
| 128 | +if ($questions) { |
|
| 129 | + foreach ($questions as $behavior_id => $behavior_questions) { |
|
| 130 | 130 | ?> |
| 131 | 131 | |
| 132 | 132 | <h4 style="Margin:0;Margin-bottom:10px;color:#37b98f;font-family:Lato,Helvetica,Arial,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;margin-bottom:5px;padding:0 8px;text-align:left;word-wrap:normal"> <?= $behavior_questions['question']['title'] ?> </h4> |
| 133 | 133 | |
| 134 | 134 | <?php |
| 135 | - foreach($behavior_questions['answers'] as $key => $question) { ?> |
|
| 135 | + foreach ($behavior_questions['answers'] as $key => $question) { ?> |
|
| 136 | 136 | <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Lato,Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0 8px 4px 8px;text-align:left"><strong><?=$question['title']?></strong> <?=$question['answer']?></p> |
| 137 | 137 | <?php |
| 138 | 138 | } |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | <th style="Margin:0;color:#0a0a0a;font-family:Lato,Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> |
| 190 | 190 | |
| 191 | 191 | <?php |
| 192 | -if($user_behaviors) { |
|
| 193 | - foreach($user_behaviors as $user_behavior) { ?> |
|
| 192 | +if ($user_behaviors) { |
|
| 193 | + foreach ($user_behaviors as $user_behavior) { ?> |
|
| 194 | 194 | <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Lato,Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0 8px 4px 8px;text-align:left"> |
| 195 | 195 | <strong style="color:#37b98f"><?= $user_behavior['category_name'] ?></strong> |
| 196 | 196 | <?php |
| 197 | - foreach($user_behavior['behaviors'] as $behavior) { ?> |
|
| 197 | + foreach ($user_behavior['behaviors'] as $behavior) { ?> |
|
| 198 | 198 | <br><?= $behavior['name'] ?> |
| 199 | 199 | <?php |
| 200 | 200 | } |
@@ -561,28 +561,28 @@ |
||
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | public function cleanExportData($data) { |
| 564 | - $order = array_flip(["date", "behavior", "category", "question1", "question2", "question3"]); |
|
| 564 | + $order = array_flip(["date", "behavior", "category", "question1", "question2", "question3"]); |
|
| 565 | 565 | |
| 566 | - $ret = array_map( |
|
| 567 | - function($row) use ($order) { |
|
| 568 | - // change timestamp to local time (for the user) |
|
| 569 | - $row['date'] = $this->time->convertUTCToLocal($row['date'], false); |
|
| 566 | + $ret = array_map( |
|
| 567 | + function($row) use ($order) { |
|
| 568 | + // change timestamp to local time (for the user) |
|
| 569 | + $row['date'] = $this->time->convertUTCToLocal($row['date'], false); |
|
| 570 | 570 | |
| 571 | - // clean up things we don't need |
|
| 572 | - $row['category'] = $row['behavior']['category']['name']; |
|
| 573 | - $row['behavior'] = $row['behavior']['name']; |
|
| 574 | - unset($row['id']); |
|
| 575 | - unset($row['behavior_id']); |
|
| 576 | - |
|
| 577 | - // sort the array into a sensible order |
|
| 578 | - uksort($row, function($a, $b) use ($order) { |
|
| 571 | + // clean up things we don't need |
|
| 572 | + $row['category'] = $row['behavior']['category']['name']; |
|
| 573 | + $row['behavior'] = $row['behavior']['name']; |
|
| 574 | + unset($row['id']); |
|
| 575 | + unset($row['behavior_id']); |
|
| 576 | + |
|
| 577 | + // sort the array into a sensible order |
|
| 578 | + uksort($row, function($a, $b) use ($order) { |
|
| 579 | 579 | return $order[$a] <=> $order[$b]; |
| 580 | - }); |
|
| 581 | - return $row; |
|
| 582 | - }, |
|
| 583 | - $data |
|
| 584 | - ); |
|
| 585 | - return $ret; |
|
| 580 | + }); |
|
| 581 | + return $row; |
|
| 582 | + }, |
|
| 583 | + $data |
|
| 584 | + ); |
|
| 585 | + return $ret; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /* |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function findByPasswordResetToken($token) |
| 145 | 145 | { |
| 146 | - if(!$this->isTokenCurrent($token)) { |
|
| 146 | + if (!$this->isTokenCurrent($token)) { |
|
| 147 | 147 | return null; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function findByVerifyEmailToken($token) |
| 163 | 163 | { |
| 164 | - if($this->isTokenConfirmed($token)) return null; |
|
| 164 | + if ($this->isTokenConfirmed($token)) return null; |
|
| 165 | 165 | |
| 166 | 166 | $user = $this->findOne([ |
| 167 | 167 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
| 168 | 168 | 'status' => self::STATUS_ACTIVE, |
| 169 | 169 | ]); |
| 170 | 170 | |
| 171 | - if($user) { |
|
| 172 | - if(!$this->isTokenConfirmed($token) && |
|
| 171 | + if ($user) { |
|
| 172 | + if (!$this->isTokenConfirmed($token) && |
|
| 173 | 173 | !$this->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
| 174 | 174 | return null; |
| 175 | 175 | } |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | 'status' => self::STATUS_ACTIVE, |
| 192 | 192 | ]); |
| 193 | 193 | |
| 194 | - if($user) { |
|
| 195 | - if(!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
| 194 | + if ($user) { |
|
| 195 | + if (!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
| 196 | 196 | return null; |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function isTokenCurrent($token, String $paramPath = 'user.passwordResetTokenExpire') { |
| 211 | 211 | $expire = \Yii::$app->params[$paramPath]; |
| 212 | 212 | $parts = explode('_', $token); |
| 213 | - $timestamp = (int) end($parts); |
|
| 213 | + $timestamp = (int)end($parts); |
|
| 214 | 214 | if ($timestamp + $expire < time()) { |
| 215 | 215 | // token expired |
| 216 | 216 | return false; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param string $match the needle to search for |
| 226 | 226 | */ |
| 227 | 227 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
| 228 | - if(is_null($token)) $token = $this->verify_email_token; |
|
| 228 | + if (is_null($token)) $token = $this->verify_email_token; |
|
| 229 | 229 | return substr($token, -strlen($match)) === $match; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | public function isVerified() { |
| 253 | - if(is_null($this->verify_email_token)) { |
|
| 253 | + if (is_null($this->verify_email_token)) { |
|
| 254 | 254 | // for old users who verified their accounts before the addition of |
| 255 | 255 | // '_confirmed' to the token |
| 256 | 256 | return true; |
@@ -358,14 +358,14 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | public function sendEmailReport($date) { |
| 361 | - if(!$this->send_email) return false; // no partner emails set |
|
| 361 | + if (!$this->send_email) return false; // no partner emails set |
|
| 362 | 362 | list($start, $end) = $this->time->getUTCBookends($date); |
| 363 | - $user_behaviors = $this->getUserBehaviors($date); |
|
| 363 | + $user_behaviors = $this->getUserBehaviors($date); |
|
| 364 | 364 | $user_questions = $this->getUserQuestions($date); |
| 365 | 365 | |
| 366 | 366 | $messages = []; |
| 367 | - foreach($this->getPartnerEmails() as $email) { |
|
| 368 | - if($email) { |
|
| 367 | + foreach ($this->getPartnerEmails() as $email) { |
|
| 368 | + if ($email) { |
|
| 369 | 369 | $messages[] = Yii::$app->mailer->compose('checkinReport', [ |
| 370 | 370 | 'user' => $this, |
| 371 | 371 | 'email' => $email, |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | 'behaviors_list' => \common\models\Behavior::$behaviors, |
| 378 | 378 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
| 379 | 379 | ->setReplyTo($this->email) |
| 380 | - ->setSubject($this->email." has completed a Faster Scale check-in") |
|
| 380 | + ->setSubject($this->email . " has completed a Faster Scale check-in") |
|
| 381 | 381 | ->setTo($email); |
| 382 | 382 | } |
| 383 | 383 | } |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | return \Yii::$app->mailer->compose('signupNotification') |
| 451 | 451 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
| 452 | 452 | ->setTo(\Yii::$app->params['adminEmail']) |
| 453 | - ->setSubject('A new user has signed up for '.\Yii::$app->name) |
|
| 453 | + ->setSubject('A new user has signed up for ' . \Yii::$app->name) |
|
| 454 | 454 | ->send(); |
| 455 | 455 | } |
| 456 | 456 | |
@@ -458,20 +458,20 @@ discard block |
||
| 458 | 458 | return \Yii::$app->mailer->compose('verifyEmail', ['user' => $this]) |
| 459 | 459 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
| 460 | 460 | ->setTo($this->email) |
| 461 | - ->setSubject('Please verify your '.\Yii::$app->name .' account') |
|
| 461 | + ->setSubject('Please verify your ' . \Yii::$app->name . ' account') |
|
| 462 | 462 | ->send(); |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | public function sendDeleteNotificationEmail() { |
| 466 | 466 | $messages = []; |
| 467 | - foreach(array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
| 468 | - if($email) { |
|
| 467 | + foreach (array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
| 468 | + if ($email) { |
|
| 469 | 469 | $messages[] = Yii::$app->mailer->compose('deleteNotification', [ |
| 470 | 470 | 'user' => $this, |
| 471 | 471 | 'email' => $email |
| 472 | 472 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
| 473 | 473 | ->setReplyTo($this->email) |
| 474 | - ->setSubject($this->email." has deleted their The Faster Scale App account") |
|
| 474 | + ->setSubject($this->email . " has deleted their The Faster Scale App account") |
|
| 475 | 475 | ->setTo($email); |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -480,13 +480,13 @@ discard block |
||
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | public function getUserQuestions($local_date = null) { |
| 483 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 483 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 484 | 484 | $questions = $this->getQuestionData($local_date); |
| 485 | 485 | return $this->parseQuestionData($questions); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | public function getUserBehaviors($local_date = null) { |
| 489 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 489 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 490 | 490 | |
| 491 | 491 | $behaviors = $this->getBehaviorData($local_date); |
| 492 | 492 | $behaviors = $this->user_behavior::decorateWithCategory($behaviors); |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | public function parseQuestionData($questions) { |
| 497 | - if(!$questions) return []; |
|
| 497 | + if (!$questions) return []; |
|
| 498 | 498 | |
| 499 | 499 | $question_answers = []; |
| 500 | - foreach($questions as $question) { |
|
| 500 | + foreach ($questions as $question) { |
|
| 501 | 501 | $behavior = $question['behavior']; |
| 502 | 502 | |
| 503 | 503 | $question_answers[$behavior['id']]['question'] = [ |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | public function parseBehaviorData($behaviors) { |
| 518 | - if(!$behaviors) return []; |
|
| 518 | + if (!$behaviors) return []; |
|
| 519 | 519 | |
| 520 | 520 | $opts_by_cat = []; |
| 521 | - foreach($behaviors as $behavior) { |
|
| 521 | + foreach ($behaviors as $behavior) { |
|
| 522 | 522 | $indx = $behavior['behavior']['category_id']; |
| 523 | 523 | |
| 524 | 524 | $opts_by_cat[$indx]['category_name'] = $behavior['behavior']['category']['name']; |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | return rtrim( |
| 611 | 611 | strtr( |
| 612 | 612 | base64_encode( |
| 613 | - hash('sha256', $this->id."::".$this->created_at, true) |
|
| 613 | + hash('sha256', $this->id . "::" . $this->created_at, true) |
|
| 614 | 614 | ), |
| 615 | 615 | '+/', '-_'), |
| 616 | 616 | '='); |
@@ -161,7 +161,9 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function findByVerifyEmailToken($token) |
| 163 | 163 | { |
| 164 | - if($this->isTokenConfirmed($token)) return null; |
|
| 164 | + if($this->isTokenConfirmed($token)) { |
|
| 165 | + return null; |
|
| 166 | + } |
|
| 165 | 167 | |
| 166 | 168 | $user = $this->findOne([ |
| 167 | 169 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
@@ -225,7 +227,9 @@ discard block |
||
| 225 | 227 | * @param string $match the needle to search for |
| 226 | 228 | */ |
| 227 | 229 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
| 228 | - if(is_null($token)) $token = $this->verify_email_token; |
|
| 230 | + if(is_null($token)) { |
|
| 231 | + $token = $this->verify_email_token; |
|
| 232 | + } |
|
| 229 | 233 | return substr($token, -strlen($match)) === $match; |
| 230 | 234 | } |
| 231 | 235 | |
@@ -358,7 +362,10 @@ discard block |
||
| 358 | 362 | } |
| 359 | 363 | |
| 360 | 364 | public function sendEmailReport($date) { |
| 361 | - if(!$this->send_email) return false; // no partner emails set |
|
| 365 | + if(!$this->send_email) { |
|
| 366 | + return false; |
|
| 367 | + } |
|
| 368 | + // no partner emails set |
|
| 362 | 369 | list($start, $end) = $this->time->getUTCBookends($date); |
| 363 | 370 | $user_behaviors = $this->getUserBehaviors($date); |
| 364 | 371 | $user_questions = $this->getUserQuestions($date); |
@@ -480,13 +487,17 @@ discard block |
||
| 480 | 487 | } |
| 481 | 488 | |
| 482 | 489 | public function getUserQuestions($local_date = null) { |
| 483 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 490 | + if(is_null($local_date)) { |
|
| 491 | + $local_date = $this->time->getLocalDate(); |
|
| 492 | + } |
|
| 484 | 493 | $questions = $this->getQuestionData($local_date); |
| 485 | 494 | return $this->parseQuestionData($questions); |
| 486 | 495 | } |
| 487 | 496 | |
| 488 | 497 | public function getUserBehaviors($local_date = null) { |
| 489 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 498 | + if(is_null($local_date)) { |
|
| 499 | + $local_date = $this->time->getLocalDate(); |
|
| 500 | + } |
|
| 490 | 501 | |
| 491 | 502 | $behaviors = $this->getBehaviorData($local_date); |
| 492 | 503 | $behaviors = $this->user_behavior::decorateWithCategory($behaviors); |
@@ -494,7 +505,9 @@ discard block |
||
| 494 | 505 | } |
| 495 | 506 | |
| 496 | 507 | public function parseQuestionData($questions) { |
| 497 | - if(!$questions) return []; |
|
| 508 | + if(!$questions) { |
|
| 509 | + return []; |
|
| 510 | + } |
|
| 498 | 511 | |
| 499 | 512 | $question_answers = []; |
| 500 | 513 | foreach($questions as $question) { |
@@ -515,7 +528,9 @@ discard block |
||
| 515 | 528 | } |
| 516 | 529 | |
| 517 | 530 | public function parseBehaviorData($behaviors) { |
| 518 | - if(!$behaviors) return []; |
|
| 531 | + if(!$behaviors) { |
|
| 532 | + return []; |
|
| 533 | + } |
|
| 519 | 534 | |
| 520 | 535 | $opts_by_cat = []; |
| 521 | 536 | foreach($behaviors as $behavior) { |
@@ -60,10 +60,10 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | public function login() |
| 62 | 62 | { |
| 63 | - if($this->validate()) { |
|
| 63 | + if ($this->validate()) { |
|
| 64 | 64 | $user = $this->getUser(); |
| 65 | - if($user->isVerified()) { |
|
| 66 | - return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0); |
|
| 65 | + if ($user->isVerified()) { |
|
| 66 | + return Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0); |
|
| 67 | 67 | } else { |
| 68 | 68 | Yii::$app->getSession()->setFlash('warning', 'You must verify your account before you can proceed. Please check your email inbox for a verification email and follow the instructions.'); |
| 69 | 69 | } |
@@ -4,8 +4,8 @@ |
||
| 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']; |
@@ -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,51 +117,51 @@ discard block |
||
| 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 | |
@@ -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), |
| 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, |
@@ -33,13 +33,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -232,7 +232,9 @@ |
||
| 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; |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | expect('the form should validate correctly', $this->assertTrue($form->validate())); |
| 137 | 137 | $user = $form->signup(); |
| 138 | 138 | expect('signup() should return a newly-saved user when the user does not already exist with the submitted values', |
| 139 | - $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1))); |
|
| 139 | + $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1))); |
|
| 140 | 140 | expect('the "Remember Me" auth_key value should be set to a random string (defaults to a 32 char length)', |
| 141 | - $this->assertEquals(32, strlen($user->auth_key))); |
|
| 141 | + $this->assertEquals(32, strlen($user->auth_key))); |
|
| 142 | 142 | expect('password_hash to be set to something like a hash', |
| 143 | - $this->assertStringStartsWith('$2y$13$', $user->password_hash)); |
|
| 143 | + $this->assertStringStartsWith('$2y$13$', $user->password_hash)); |
|
| 144 | 144 | expect('when the user is created, signup() should call save()', |
| 145 | - $this->assertTrue($saved)); |
|
| 145 | + $this->assertTrue($saved)); |
|
| 146 | 146 | expect('This user should be an isNewRecord -- they should NOT already exist', $this->assertTrue($user->getIsNewRecord())); |
| 147 | 147 | }); |
| 148 | 148 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $user = $form3->signup(); |
| 187 | 187 | expect('This user should not be an isNewRecord -- they should already exist', $this->assertFalse($user->getIsNewRecord())); |
| 188 | 188 | expect('signup() should return a newly-saved user when the user does not already exist with the submitted values', |
| 189 | - $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1))); |
|
| 189 | + $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1))); |
|
| 190 | 190 | expect('when the user exists and is NOT confirmed, signup() should call save() to UPDATE their info', $this->assertTrue($saved)); |
| 191 | 191 | }); |
| 192 | 192 | } |
@@ -8,103 +8,103 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(), [ |