Completed
Pull Request — master (#171)
by Corey
02:59
created
site/views/site/error.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 $exception = Yii::$app->errorHandler->exception;
17 17
 
18
-if($exception instanceof \yii\web\NotFoundHttpException):
18
+if ($exception instanceof \yii\web\NotFoundHttpException):
19 19
   $this->title = "The Faster Scale App | Page Not Found";
20 20
 ?>
21 21
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
   <p>Otherwise, please ensure your attempted url is correct.</p>
26 26
 
27 27
 <?php
28
-elseif($exception instanceof \yii\web\ServerErrorHttpException):
28
+elseif ($exception instanceof \yii\web\ServerErrorHttpException):
29 29
   $this->title = "The Faster Scale App | Oops";
30 30
 ?>
31 31
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
33 33
   <div class="alert alert-danger"><?= nl2br(Html::encode($name)) ?></div>
34 34
   <p>Well this is embarrassing...we're having an error on our side. So sorry for the annoyance. If you'd like to help, please send us a message on our <a href='<?=Url::to(['site/contact'])?>'>contact form</a>.</p>
35 35
 
36
-<?php else: ?>
36
+<?php else {
37
+  : ?>
37 38
 
38 39
 <div class="site-error">
39 40
   <h1><?= Html::encode($name) ?></h1>
@@ -41,4 +42,6 @@  discard block
 block discarded – undo
41 42
   <p>The above error occurred while the Web server was processing your request.</p>
42 43
   <p>Please contact us if you think this is a server error. Thank you.</p>
43 44
 </div>
44
-<?php endif; ?>
45
+<?php endif;
46
+}
47
+?>
Please login to merge, or discard this patch.
site/controllers/ProfileController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]);
76 76
 
77 77
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
78
-      if($model->deleteAccount()) {
78
+      if ($model->deleteAccount()) {
79 79
         $this->redirect(['site/index']);
80 80
       } else {
81 81
         Yii::$app->session->setFlash('error', 'Wrong password!');
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]);
90 90
 
91 91
     if ($model->load(Yii::$app->request->post())) {
92
-      if($model->validate() && $model->changePassword()) {
92
+      if ($model->validate() && $model->changePassword()) {
93 93
         Yii::$app->session->setFlash('success', 'Password successfully changed');
94 94
       } else {
95 95
         Yii::$app->session->setFlash('error', 'Wrong password!');
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
   public function actionChangeEmail(string $token) {
114 114
     $user = Yii::$container->get(\common\interfaces\UserInterface::class)->findByChangeEmailToken($token);
115 115
 
116
-    if($user) {
116
+    if ($user) {
117 117
       $validator = new \yii\validators\EmailValidator();
118
-      if($validator->validate($user->desired_email, $error)) {
118
+      if ($validator->validate($user->desired_email, $error)) {
119 119
         $user->removeChangeEmailToken();
120 120
         $user->email = $user->desired_email;
121 121
         $user->desired_email = null;
122 122
         $user->save();
123
-        if(!Yii::$app->user->isGuest) {
123
+        if (!Yii::$app->user->isGuest) {
124 124
           Yii::$app->user->logout();
125 125
           Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.');
126 126
         } else {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
   public function actionExport() {
142 142
     header("Content-Type: text/csv");
143
-    header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv");
143
+    header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv");
144 144
 
145 145
     $reader = Yii::$app->user->identity->getExportData();
146 146
     $fp = fopen('php://output', 'w');
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
     fputcsv($fp, $header);
158 158
     $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class);
159
-    while($row = $reader->read()) {
159
+    while ($row = $reader->read()) {
160 160
       $row = $user_behavior::decorateWithCategory([$row]);
161 161
       $row = Yii::$app->user->identity->cleanExportData($row);
162 162
       fputcsv($fp, $row[0]);
Please login to merge, or discard this patch.
site/controllers/SiteController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
   public function actionBlog()
56 56
   {
57 57
     $time = Yii::$container->get(\common\interfaces\TimeInterface::class); 
58
-    $key = "index_blog_".$time->getLocalDate('UTC');
58
+    $key = "index_blog_" . $time->getLocalDate('UTC');
59 59
     $posts = Yii::$app->cache->get($key);
60
-    if($posts === false) {
60
+    if ($posts === false) {
61 61
       $posts = \Yii::$app->getModule('blog')
62 62
                             ->fetch()
63 63
                             ->parse()
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
   {
91 91
     $model = new \site\models\ContactForm();
92 92
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
93
-      if($model->sendEmail(Yii::$app->params['adminEmail'])) {
93
+      if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
94 94
         Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
95 95
       } else {
96 96
         Yii::$app->session->setFlash('error', 'There was an error sending email.');
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
   public function actionSignup()
123 123
   {
124 124
     $model = Yii::$container->get(\site\models\SignupForm::class);
125
-    if($model->load(Yii::$app->request->post()) && $model->validate()) {
125
+    if ($model->load(Yii::$app->request->post()) && $model->validate()) {
126 126
       $model->signup();
127 127
       Yii::$app->session->setFlash('success', 'We have sent a verification email to the email address you provided. Please check your inbox and follow the instructions to verify your account.');
128
-      return $this->redirect('/',302);
128
+      return $this->redirect('/', 302);
129 129
     }
130 130
 
131 131
     return $this->render('signup', [
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
   public function actionRequestPasswordReset()
137 137
   {
138 138
     $model = Yii::$container->get(\site\models\PasswordResetRequestForm::class);
139
-    if($model->load(Yii::$app->request->post()) && $model->validate()) {
140
-      if(!$model->sendEmail()) {
139
+    if ($model->load(Yii::$app->request->post()) && $model->validate()) {
140
+      if (!$model->sendEmail()) {
141 141
         $ip = Yii::$app->getRequest()->getUserIP() ?: "UNKNOWN";
142
-        Yii::warning("$ip has tried to reset the password for ".$model->email);
142
+        Yii::warning("$ip has tried to reset the password for " . $model->email);
143 143
       }
144 144
 
145 145
       Yii::$app->session->setFlash('success', 'If there is an account with the submitted email address you will receive further instructions in your email inbox.');
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
       throw new BadRequestHttpException("Wrong or expired email verification token. If you aren't sure why this error occurs perhaps you've already verified your account. Please try logging in.");
184 184
     }
185 185
 
186
-    if($user->isTokenConfirmed($user->verify_email_token)) {
186
+    if ($user->isTokenConfirmed($user->verify_email_token)) {
187 187
       Yii::$app->session->setFlash('success', 'Your account has already been verified. Please log in.');
188
-      return $this->redirect('/login',302);
188
+      return $this->redirect('/login', 302);
189 189
     } else if (Yii::$app->getUser()->login($user)) {
190 190
       $user->confirmVerifyEmailToken();
191 191
       $user->save();
192 192
       Yii::$app->session->setFlash('success', 'Your account has been verified. Please continue with your check-in.');
193
-      return $this->redirect('/welcome',302);
193
+      return $this->redirect('/welcome', 302);
194 194
     }
195 195
   }
196 196
 
Please login to merge, or discard this patch.
common/components/Controller.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
33 33
   {
34 34
     return [
35 35
       'error' => [
36
-         'class' => 'yii\web\ErrorAction',
37
-       ],
36
+          'class' => 'yii\web\ErrorAction',
37
+        ],
38 38
       'captcha' => [
39 39
         'class' => 'yii\captcha\CaptchaAction',
40 40
       ],
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
       return false;
20 20
     }
21 21
 
22
-    if(!parent::beforeAction($action)) {
22
+    if (!parent::beforeAction($action)) {
23 23
       return false;
24 24
     }
25 25
 
Please login to merge, or discard this patch.
common/models/LoginForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@
 block discarded – undo
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->session->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
       }
Please login to merge, or discard this patch.
site/tests/unit/models/EditProfileFormTest.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@  discard block
 block discarded – undo
6 6
 use \site\models\EditProfileForm;
7 7
 
8 8
 class EditProfileFormTest extends \Codeception\Test\Unit {
9
-	public $graph;
10
-	public $values = [
11
-			'timezone' => 'America/Los_Angeles',
12
-			'email_threshold' => 5,
13
-			'partner_email1' => '[email protected]',
14
-			'partner_email2' => '[email protected]',
15
-			'partner_email3' => '[email protected]',
16
-			'expose_graph' => true,
17
-		];
18
-
19
-	public function setUp() {
20
-		$this->graph = $this->getMockBuilder(common\components\Graph::class)
21
-			->setMethods(['create', 'destroy'])
22
-			->getMock();
23
-		parent::setUp();
24
-	}
9
+  public $graph;
10
+  public $values = [
11
+      'timezone' => 'America/Los_Angeles',
12
+      'email_threshold' => 5,
13
+      'partner_email1' => '[email protected]',
14
+      'partner_email2' => '[email protected]',
15
+      'partner_email3' => '[email protected]',
16
+      'expose_graph' => true,
17
+    ];
18
+
19
+  public function setUp() {
20
+    $this->graph = $this->getMockBuilder(common\components\Graph::class)
21
+      ->setMethods(['create', 'destroy'])
22
+      ->getMock();
23
+    parent::setUp();
24
+  }
25 25
 
26 26
   public function testLoadUser() {
27 27
     $user = $this->getUser();
@@ -58,37 +58,37 @@  discard block
 block discarded – undo
58 58
 
59 59
     $form->attributes = $this->values;
60 60
     expect('saveProfile should return the user', $this->assertEquals($user, $form->saveProfile()));
61
-		expect('saveProfile should set the user\'s attributes to be the form values', $this->assertEquals($this->values, $user->attributes));
61
+    expect('saveProfile should set the user\'s attributes to be the form values', $this->assertEquals($this->values, $user->attributes));
62 62
 
63 63
     $form->send_email = 'not_a_boolean';
64
-		$ret = $form->saveProfile();
64
+    $ret = $form->saveProfile();
65 65
     expect('saveProfile should return the user with the partner-related settings equal to null', $this->assertNull($ret));
66 66
 
67
-		$null_vals = [
68
-			'email_threshold' => null,
69
-			'partner_email1'  => null,
70
-			'partner_email2'  => null,
71
-			'partner_email3'  => null,
72
-			'timezone'        => 'America/Los_Angeles',
73
-			'expose_graph'    => true,
74
-		];
67
+    $null_vals = [
68
+      'email_threshold' => null,
69
+      'partner_email1'  => null,
70
+      'partner_email2'  => null,
71
+      'partner_email3'  => null,
72
+      'timezone'        => 'America/Los_Angeles',
73
+      'expose_graph'    => true,
74
+    ];
75 75
     $form->send_email = false;
76
-		$ret = $form->saveProfile();
76
+    $ret = $form->saveProfile();
77 77
     expect('saveProfile should return the user with the partner-related settings equal to null', $this->assertEquals($null_vals, $user->attributes));
78 78
 
79
-		$this->graph
80
-			->expects($this->once())
81
-			->method('destroy');
82
-		$form->expose_graph = false;
83
-		$ret = $form->saveProfile();
84
-		expect('if form->expose_graph is set to false, destroy the graph and set user->expose_graph to false', $this->assertFalse($ret->expose_graph));
85
-
86
-		$this->graph
87
-			->expects($this->once())
88
-			->method('create');
89
-		$form->expose_graph = true;
90
-		$ret = $form->saveProfile();
91
-		expect('if form->expose_graph is set to true, create the graph and set user->expose_graph to true', $this->assertTrue($ret->expose_graph));
79
+    $this->graph
80
+      ->expects($this->once())
81
+      ->method('destroy');
82
+    $form->expose_graph = false;
83
+    $ret = $form->saveProfile();
84
+    expect('if form->expose_graph is set to false, destroy the graph and set user->expose_graph to false', $this->assertFalse($ret->expose_graph));
85
+
86
+    $this->graph
87
+      ->expects($this->once())
88
+      ->method('create');
89
+    $form->expose_graph = true;
90
+    $ret = $form->saveProfile();
91
+    expect('if form->expose_graph is set to true, create the graph and set user->expose_graph to true', $this->assertTrue($ret->expose_graph));
92 92
 		
93 93
     $form->send_email = 'not_a_boolean';
94 94
     expect('saveProfile should return null if the form validation fails', $this->assertNull($form->saveProfile()));
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@
 block discarded – undo
52 52
     $form->loadUser();
53 53
 
54 54
     Yii::$container
55
-      ->set(\common\components\Graph::class, function () { return $this->graph; });
55
+      ->set(\common\components\Graph::class, function() { return $this->graph; });
56 56
     Yii::$container
57
-      ->set(\common\interfaces\UserBehaviorInterface::class, function () { return new FakeUserBehavior(); });
57
+      ->set(\common\interfaces\UserBehaviorInterface::class, function() { return new FakeUserBehavior(); });
58 58
 
59 59
     $form->attributes = $this->values;
60 60
     expect('saveProfile should return the user', $this->assertEquals($user, $form->saveProfile()));
Please login to merge, or discard this patch.