@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
25 | 25 | $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion'); |
26 | 26 | |
27 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
27 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
28 | 28 | return new \common\components\Time('America/Los_Angeles'); |
29 | 29 | }); |
30 | 30 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function testGetLocalTime() |
49 | 49 | { |
50 | - $this->specify('getLocalTime should function correctly', function () { |
|
50 | + $this->specify('getLocalTime should function correctly', function() { |
|
51 | 51 | expect("getLocalTime should work with user's set time", $this->assertEquals($this->time->getLocalTime(), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s"))); |
52 | 52 | expect('getLocalTime should work with a custom timezone', $this->assertEquals($this->time->getLocalTime("UTC"), (new DateTime("now"))->format("Y-m-d H:i:s"))); |
53 | 53 | }); |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | |
56 | 56 | public function testConvertLocalToUTC() |
57 | 57 | { |
58 | - $this->specify('convertLocalToUTC should function correctly', function () { |
|
58 | + $this->specify('convertLocalToUTC should function correctly', function() { |
|
59 | 59 | $la_tz = (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s"); |
60 | 60 | |
61 | 61 | expect('convertLocalToUTC should convert a Los Angeles tz to UTC with the included time', $this->assertEquals($this->time->convertLocalToUTC($la_tz), (new DateTime("now"))->format("Y-m-d H:i:s"))); |
62 | 62 | expect('convertLocalToUTC should convert a Los Angeles tz to UTC without the included time', $this->assertEquals($this->time->convertLocalToUTC($la_tz, false), (new DateTime("now"))->format("Y-m-d"))); |
63 | 63 | // with UTC |
64 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
64 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
65 | 65 | return new \common\components\Time('UTC'); |
66 | 66 | }); |
67 | 67 | $time = $this->container->get('common\interfaces\TimeInterface'); |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | |
75 | 75 | public function testConvertUTCToLocal() |
76 | 76 | { |
77 | - $this->specify('convertUTCToLocal should function correctly', function () { |
|
77 | + $this->specify('convertUTCToLocal should function correctly', function() { |
|
78 | 78 | $utc_tz = (new DateTime("now"))->format("Y-m-d H:i:s"); |
79 | 79 | |
80 | 80 | expect('convertUTCToLocal should convert a UTC tz to Los Angeles with the included timezone', $this->assertEquals((new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format(DateTime::ATOM), $this->time->convertUTCToLocal($utc_tz))); |
81 | 81 | expect('convertUTCToLocal should convert a UTC tz to Los Angeles without the included timezone', $this->assertEquals($this->time->convertUTCToLocal($utc_tz, false), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s"))); |
82 | 82 | |
83 | 83 | // with UTC |
84 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
84 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
85 | 85 | return new \common\components\Time('UTC'); |
86 | 86 | }); |
87 | 87 | $time = $this->container->get('common\interfaces\TimeInterface'); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | public function testGetLocalDate() |
96 | 96 | { |
97 | - $this->specify('getLocalDate should function correctly', function () { |
|
97 | + $this->specify('getLocalDate should function correctly', function() { |
|
98 | 98 | expect("getLocalDate should correctly get the user's local date", $this->assertEquals($this->time->getLocalDate(), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d"))); |
99 | 99 | expect("getLocalDate should correctly get the local date of a specified timezone", $this->assertEquals($this->time->getLocalDate("UTC"), (new DateTime("now", new DateTimeZone("UTC")))->format("Y-m-d"))); |
100 | 100 | }); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | public function testAlterLocalDate() |
104 | 104 | { |
105 | - $this->specify('alterLocalDate should function correctly', function () { |
|
105 | + $this->specify('alterLocalDate should function correctly', function() { |
|
106 | 106 | expect('alterLocalDate should add one day to the local time', $this->assertEquals($this->time->alterLocalDate('2016-05-01 00:00:00', '+1 day'), (new DateTime("2016-05-01 00:00:00 +1 day"))->format("Y-m-d"))); |
107 | 107 | expect('alterLocalDate should subtract one week to the local time and change the year correctly', $this->assertEquals($this->time->alterLocalDate('2016-01-01 04:03:00', '-1 week'), (new DateTime("2016-01-01 04:03:00 -1 week"))->format("Y-m-d"))); |
108 | 108 | }); |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | |
111 | 111 | public function testGetUTCBookends() |
112 | 112 | { |
113 | - $this->specify('getUTCBookends should function correctly', function () { |
|
113 | + $this->specify('getUTCBookends should function correctly', function() { |
|
114 | 114 | expect('getUTCBookends should return false if there is a space in the time string', $this->assertFalse($this->time->getUTCBookends('2016-05-30 00:00:00'))); |
115 | 115 | expect('getUTCBookends should return false if there is a space at the start of the time string', $this->assertFalse($this->time->getUTCBookends(' 2016-05-30 00:00:00'))); |
116 | 116 | expect('getUTCBookends should return false if there is a space at the end of the time string', $this->assertFalse($this->time->getUTCBookends('2016-05-30 00:00:00 '))); |
117 | 117 | expect('getUTCBookends should return UTC bookend times from the Los_Angeles tz', $this->assertEquals($this->time->getUTCBookends('2016-05-30'), ['2016-05-30 07:00:00', '2016-05-31 06:59:59'])); |
118 | 118 | // with UTC |
119 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
119 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
120 | 120 | return new \common\components\Time('UTC'); |
121 | 121 | }); |
122 | 122 | $time = $this->container->get('common\interfaces\TimeInterface'); |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | expect('parse should return the default value (false) if the date is not in bounds', $this->assertFalse($observer2->parse('2016-05-05'))); |
154 | 154 | expect('parse should return the default value if the date is not in bounds', $this->assertEquals($observer2->now()->format('Y-m-d'), $observer2->parse('2016-05-05', $observer2->now())->format('Y-m-d'))); |
155 | 155 | |
156 | - $this->specify('should all return false', function () { |
|
156 | + $this->specify('should all return false', function() { |
|
157 | 157 | expect('parse should return false if the date itself is empty', $this->assertFalse($this->time->parse(''))); |
158 | 158 | expect('parse should return false if the date itself is unacceptable or is in an unacceptable format', $this->assertFalse($this->time->parse('aaaa-aa-aa'))); |
159 | 159 | expect('parse should return false if the date is not in bounds', $this->assertFalse($this->time->parse('aaaa-aa-aa'))); |
160 | 160 | expect('parse should return false if the date itself is nonsensical', $this->assertFalse($this->time->parse('2018-22-44'))); |
161 | 161 | }); |
162 | 162 | |
163 | - $this->specify('should still work fine with other timezones', function () { |
|
163 | + $this->specify('should still work fine with other timezones', function() { |
|
164 | 164 | $this->time->timezone = 'UTC'; |
165 | 165 | $good = new DateTime('2016-05-05', new DateTimeZone('UTC')); |
166 | 166 | expect('parse should accept a String time and verify it is in YYYY-MM-DD format, then return it as a \DateTime', $this->assertEquals($this->time->parse('2016-05-05'), $good)); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | $tz = 'America/Los_Angeles'; |
206 | 206 | $this->time->timezone = 'America/Los_Angeles'; |
207 | 207 | |
208 | - $today = new \DateTime("now + 1 day", new \DateTimeZone($tz)); // we do an extra day to include today as the last day |
|
208 | + $today = new \DateTime("now + 1 day", new \DateTimeZone($tz)); // we do an extra day to include today as the last day |
|
209 | 209 | $should_be_today = $this->time->getDateTimesInPeriod()->getEndDate(); |
210 | 210 | expect('getDateTimesInPeriod should return a list of \DatePeriods, the last being for today', $this->assertEquals($today->format('Y-m-d H'), $should_be_today->format('Y-m-d H'))); |
211 | 211 | |
212 | - $start = new \DateTime("30 days ago", new \DateTimeZone($tz)); |
|
212 | + $start = new \DateTime("30 days ago", new \DateTimeZone($tz)); |
|
213 | 213 | $should_be_start = $this->time->getDateTimesInPeriod()->getStartDate(); |
214 | 214 | expect('getDateTimesInPeriod should return a list of \DatePeriods, the first being for 30 days ago (by default)', $this->assertEquals($start->format('Y-m-d H'), $should_be_start->format('Y-m-d H'))); |
215 | 215 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public function setUp(): void |
282 | 282 | { |
283 | 283 | // pull in test data |
284 | - $data = require(__DIR__.'/../data/checkinData.php'); |
|
284 | + $data = require(__DIR__ . '/../data/checkinData.php'); |
|
285 | 285 | $this->singleBhvr = $data['singleBhvr']; |
286 | 286 | $this->manyBhvrs = $data['manyBhvrs']; |
287 | 287 | $this->allBhvrs = $data['allBhvrs']; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
292 | 292 | $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion'); |
293 | 293 | $this->container->set('common\interfaces\BehaviorInterface', 'common\models\Behavior'); |
294 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
294 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
295 | 295 | return new \common\components\Time('America/Los_Angeles'); |
296 | 296 | }); |
297 | 297 | |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | ->setMethods(['getIsNewRecord', 'save', 'getBehaviorsWithCounts']) |
462 | 462 | ->getMock(); |
463 | 463 | |
464 | - $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php'); |
|
465 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); |
|
464 | + $bhvrs = require(__DIR__ . '/../data/behaviorsWithCounts.php'); |
|
465 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); |
|
466 | 466 | $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs); |
467 | 467 | expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown())); |
468 | 468 | } |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | public function testGetUser() |
113 | 113 | { |
114 | - $this->specify('getUser shougd function correctly', function () { |
|
114 | + $this->specify('getUser shougd function correctly', function() { |
|
115 | 115 | expect('getUser should return the user if the user attr on the form object is already set', $this->assertInstanceOf('\common\models\User', $this->form->getUser())); |
116 | 116 | }); |
117 | 117 | } |
118 | 118 | |
119 | 119 | public function testValidatePassword() |
120 | 120 | { |
121 | - $this->specify('validatePassword should function correctly', function () { |
|
121 | + $this->specify('validatePassword should function correctly', function() { |
|
122 | 122 | expect('validatePassword should always return null', $this->assertNull($this->form->validatePassword())); |
123 | 123 | expect('validatePassword should by default in this test class not set errors', $this->assertEmpty($this->form->getErrors())); |
124 | 124 | |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | } |
131 | 131 | public function testLogin() |
132 | 132 | { |
133 | - $this->specify('login should function correctly', function () { |
|
133 | + $this->specify('login should function correctly', function() { |
|
134 | 134 | $this->form->email = '[email protected]'; |
135 | 135 | $this->form->password = 'hunter2'; |
136 | 136 | expect('login should return true if able to log in user', $this->assertTrue($this->form->login())); |
137 | 137 | }); |
138 | 138 | |
139 | - $this->specify('login should fail if account is not verified', function () { |
|
139 | + $this->specify('login should fail if account is not verified', function() { |
|
140 | 140 | $this->user = $this->mockUser(['isVerified' => false]); |
141 | 141 | $this->form = $this->mockForm($this->user); |
142 | 142 | $this->form->email = '[email protected]'; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | expect('login should set a flash message if account is not verified', $this->assertNotEmpty(Yii::$app->session->getFlash('warning', null, true))); |
147 | 147 | }); |
148 | 148 | |
149 | - $this->specify('login should fail if credentials are not valid', function () { |
|
149 | + $this->specify('login should fail if credentials are not valid', function() { |
|
150 | 150 | $this->user = $this->mockUser(['validatePassword' => false]); |
151 | 151 | $this->form = $this->mockForm($this->user); |
152 | 152 | $this->form->email = '[email protected]'; |
@@ -159,16 +159,16 @@ |
||
159 | 159 | public function setUp(): void |
160 | 160 | { |
161 | 161 | $this->question = $this->getMockBuilder('\common\models\Question') |
162 | - ->setMethods(['save', 'attributes']) |
|
163 | - ->getMock(); |
|
162 | + ->setMethods(['save', 'attributes']) |
|
163 | + ->getMock(); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public function testParseQuestionData() |
167 | 167 | { |
168 | 168 | $questions = array_map(function ($d) { |
169 | 169 | $q = $this->getMockBuilder('\common\models\Question') |
170 | - ->setMethods(['save', 'attributes']) |
|
171 | - ->getMock(); |
|
170 | + ->setMethods(['save', 'attributes']) |
|
171 | + ->getMock(); |
|
172 | 172 | $q->method('save')->willReturn(true); |
173 | 173 | $q->method('attributes') |
174 | 174 | ->willReturn([ |
@@ -165,7 +165,7 @@ |
||
165 | 165 | |
166 | 166 | public function testParseQuestionData() |
167 | 167 | { |
168 | - $questions = array_map(function ($d) { |
|
168 | + $questions = array_map(function($d) { |
|
169 | 169 | $q = $this->getMockBuilder('\common\models\Question') |
170 | 170 | ->setMethods(['save', 'attributes']) |
171 | 171 | ->getMock(); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $this->container = new \yii\di\Container; |
91 | 91 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
92 | 92 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
93 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
93 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
94 | 94 | return new \common\components\Time('America/Los_Angeles'); |
95 | 95 | }); |
96 | 96 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | public function testIsTokenCurrent() |
140 | 140 | { |
141 | - $this->specify('isTokenCurrent should function correctly', function () { |
|
141 | + $this->specify('isTokenCurrent should function correctly', function() { |
|
142 | 142 | $good_token = \Yii::$app |
143 | 143 | ->getSecurity() |
144 | 144 | ->generateRandomString() . '_' . time(); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $this->user->verify_email_token = 'hello_world'; |
178 | 178 | $this->user->confirmVerifyEmailToken(); |
179 | - 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)); |
|
179 | + 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)); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | public function testIsVerified() |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | 'question2' => 'q2', |
255 | 255 | 'question3' => 'q3', |
256 | 256 | ] |
257 | - ], array_map(function ($row) { |
|
257 | + ], array_map(function($row) { |
|
258 | 258 | return $this->user->cleanExportRow($row); |
259 | 259 | }, $this->exportData))); |
260 | 260 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | ->disableOriginalConstructor() |
280 | 280 | ->setMethods(['save', 'attributes', 'getCheckinBreakdown']) |
281 | 281 | ->getMock(); |
282 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); |
|
282 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); |
|
283 | 283 | $user_behavior->method('getCheckinBreakdown')->willReturn($expected); |
284 | 284 | |
285 | 285 | $user = $this->getMockBuilder(User::class) |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | 'common\interfaces\BehaviorInterface' => \common\models\Behavior::class, |
12 | 12 | 'common\interfaces\CategoryInterface' => \common\models\Category::class, |
13 | 13 | 'common\interfaces\CustomBehaviorInterface' => \common\models\CustomBehavior::class, |
14 | - 'common\interfaces\TimeInterface' => function () { |
|
14 | + 'common\interfaces\TimeInterface' => function() { |
|
15 | 15 | if (Yii::$app->user->getIsGuest()) { |
16 | 16 | return new \common\components\Time('UTC'); |
17 | 17 | } else { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ], |
31 | 31 | 'components' => [ |
32 | 32 | // by default, sessions are stored in a local file |
33 | - 'cache' => [ // DummyCache never actually caches anything |
|
33 | + 'cache' => [// DummyCache never actually caches anything |
|
34 | 34 | 'class'=> yii\caching\DummyCache::class, |
35 | 35 | ], |
36 | 36 | 'mailer' => [ |