@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function getFilepath() { |
29 | 29 | $path = Yii::getAlias('@graphImgPath'); |
30 | 30 | $filename = $this->user->getIdHash() . ".png"; |
31 | - return $path. '/' . $filename; |
|
31 | + return $path . '/' . $filename; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | * @return string the encoded image |
62 | 62 | */ |
63 | 63 | public function create(array $checkins, bool $toDisk = false) { |
64 | - if($toDisk) { |
|
64 | + if ($toDisk) { |
|
65 | 65 | // wipe out the current image, if it exists |
66 | 66 | $this->destroy(); |
67 | 67 | } |
68 | 68 | |
69 | 69 | $accum = []; |
70 | - foreach($checkins as $checkin_sum) { |
|
71 | - for($i = 1; $i <= 7; $i ++) { |
|
70 | + foreach ($checkins as $checkin_sum) { |
|
71 | + for ($i = 1; $i <= 7; $i++) { |
|
72 | 72 | $accum[$i][] = array_key_exists($i, $checkin_sum) ? $checkin_sum[$i]['count'] : 0; |
73 | 73 | } |
74 | 74 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | |
88 | 88 | // Setup dates as labels on the X-axis |
89 | 89 | $graph->xaxis->SetTickLabels(array_keys($checkins)); |
90 | - $graph->xaxis->HideTicks(false,false); |
|
90 | + $graph->xaxis->HideTicks(false, false); |
|
91 | 91 | $graph->yaxis->scale->SetAutoMin(0); |
92 | 92 | $graph->yaxis->HideLine(false); |
93 | - $graph->yaxis->HideTicks(false,false); |
|
93 | + $graph->yaxis->HideTicks(false, false); |
|
94 | 94 | $graph->xaxis->SetLabelAngle(45); |
95 | 95 | $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 10); |
96 | 96 | $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 15); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | // Create the bar plots |
101 | 101 | $plots = []; |
102 | - foreach($accum as $category_key => $category_data) { |
|
102 | + foreach ($accum as $category_key => $category_data) { |
|
103 | 103 | $bplot = new BarPlot($category_data); |
104 | 104 | $color = $category::$colors[$category_key]['color']; |
105 | 105 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | // $graph->legend->SetFrameWeight(1); |
117 | 117 | $graph->legend->SetColumns(3); |
118 | - $graph->legend->SetColor('#4E4E4E','#00A78A'); |
|
118 | + $graph->legend->SetColor('#4E4E4E', '#00A78A'); |
|
119 | 119 | |
120 | 120 | $graph->title->SetFont(FF_ARIAL, FS_BOLD, 20); |
121 | 121 | $graph->title->Set("Behaviors broken down by Category"); |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | imagepng($img); |
146 | 146 | $img_data = ob_get_clean(); |
147 | 147 | |
148 | - if($toDisk) { |
|
148 | + if ($toDisk) { |
|
149 | 149 | $filepath = $this->getFilepath(); |
150 | - if(!is_dir(dirname($filepath))) { |
|
150 | + if (!is_dir(dirname($filepath))) { |
|
151 | 151 | mkdir(dirname($filepath), 0766, true); |
152 | 152 | } |
153 | 153 |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | use \Codeception\Specify; |
15 | 15 | |
16 | 16 | private $user; |
17 | - private $filepath = __DIR__.'/../../_output/test_graph.png'; |
|
18 | - private $filepath_extra = __DIR__.'/../../_output/charts/test_graph.png'; |
|
17 | + private $filepath = __DIR__ . '/../../_output/test_graph.png'; |
|
18 | + private $filepath_extra = __DIR__ . '/../../_output/charts/test_graph.png'; |
|
19 | 19 | |
20 | 20 | public function setUp() { |
21 | 21 | $this->user = $this->getMockBuilder('\site\tests\_support\MockUser') |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ->willReturn('random1DH4sh'); |
37 | 37 | $graph = new Graph($this->user); |
38 | 38 | |
39 | - expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))).'/site/web/charts/random1DH4sh.png', $graph->getFilepath())); |
|
39 | + expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))) . '/site/web/charts/random1DH4sh.png', $graph->getFilepath())); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function testGetUrl() { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | ->method('getFilepath') |
58 | 58 | ->willReturn($this->filepath); |
59 | 59 | |
60 | - if(!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) { |
|
60 | + if (!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) { |
|
61 | 61 | touch($this->filepath); |
62 | 62 | expect('just a check to be sure $filepath is sane', $this->assertStringEndsWith('/_output/test_graph.png', $this->filepath)); |
63 | 63 | expect('the generated file should exist', $this->assertFileExists($this->filepath)); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | expect('the generated file should be readable', $this->assertFileExists($this->filepath_extra)); |
90 | 90 | |
91 | 91 | // cleanup |
92 | - if(file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) { |
|
92 | + if (file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) { |
|
93 | 93 | // just in case something is weird, we don't want to straight rm this file |
94 | 94 | unlink($this->filepath_extra); |
95 | 95 | rmdir(dirname($this->filepath_extra)); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | -function checkinBreakdown () { |
|
100 | +function checkinBreakdown() { |
|
101 | 101 | return [ |
102 | 102 | '2019-01-31' => [], |
103 | 103 | '2019-02-01' => [], |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | '2019-02-27' => [], |
231 | 231 | '2019-02-28' => [], |
232 | 232 | '2019-03-01' => [ |
233 | - 2 => [ 'name' => 'Forgetting Priorities', |
|
233 | + 2 => ['name' => 'Forgetting Priorities', |
|
234 | 234 | 'count' => 6, |
235 | 235 | 'color' => '#4CA100', |
236 | 236 | 'highlight' => '#61B219', |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * @codeCoverageIgnore |
|
57 | - */ |
|
56 | + * @codeCoverageIgnore |
|
57 | + */ |
|
58 | 58 | public function attributeLabels() { |
59 | 59 | return [ |
60 | 60 | 'partner_email1' => "Partner Email #1", |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // generate scores graph image |
87 | 87 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
88 | 88 | $checkins_last_month = (Yii::$container->get(\common\interfaces\UserBehaviorInterface::class)) |
89 | - ->getCheckInBreakdown($time->getDateTimesInPeriod()); |
|
89 | + ->getCheckInBreakdown($time->getDateTimesInPeriod()); |
|
90 | 90 | |
91 | 91 | // if they haven't done a check-in in the last month this |
92 | 92 | // will explode because $checkinss_last_month is an empty |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | $graph = Yii::$container |
78 | 78 | ->get(\common\components\Graph::class, [$this->user]); |
79 | 79 | |
80 | - if($this->timezone) { |
|
80 | + if ($this->timezone) { |
|
81 | 81 | $user->timezone = $this->timezone; |
82 | 82 | } |
83 | - if($this->expose_graph) { |
|
83 | + if ($this->expose_graph) { |
|
84 | 84 | $user->expose_graph = true; |
85 | 85 | |
86 | 86 | // generate scores graph image |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // if they haven't done a check-in in the last month this |
92 | 92 | // will explode because $checkinss_last_month is an empty |
93 | 93 | // array |
94 | - if($checkins_last_month) { |
|
94 | + if ($checkins_last_month) { |
|
95 | 95 | $graph->create($checkins_last_month, true); |
96 | 96 | } |
97 | 97 | } else { |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | // remove scores graph image |
100 | 100 | $graph->destroy(); |
101 | 101 | } |
102 | - if($this->send_email) { |
|
102 | + if ($this->send_email) { |
|
103 | 103 | $user->send_email = true; |
104 | 104 | } else { |
105 | 105 | $user->send_email = false; |
106 | 106 | } |
107 | - if($this->send_email) { |
|
107 | + if ($this->send_email) { |
|
108 | 108 | $user->partner_email1 = $this->partner_email1; |
109 | 109 | $user->partner_email2 = $this->partner_email2; |
110 | 110 | $user->partner_email3 = $this->partner_email3; |
@@ -6,22 +6,22 @@ discard block |
||
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', |
|
9 | + public $graph; |
|
10 | + public $values = [ |
|
11 | + 'timezone' => 'America/Los_Angeles', |
|
12 | 12 | 'send_email' => true, |
13 | - 'partner_email1' => '[email protected]', |
|
14 | - 'partner_email2' => '[email protected]', |
|
15 | - 'partner_email3' => '[email protected]', |
|
16 | - 'expose_graph' => true, |
|
17 | - ]; |
|
13 | + 'partner_email1' => '[email protected]', |
|
14 | + 'partner_email2' => '[email protected]', |
|
15 | + 'partner_email3' => '[email protected]', |
|
16 | + 'expose_graph' => true, |
|
17 | + ]; |
|
18 | 18 | |
19 | - public function setUp() { |
|
20 | - $this->graph = $this->getMockBuilder(common\components\Graph::class) |
|
21 | - ->setMethods(['create', 'destroy']) |
|
22 | - ->getMock(); |
|
23 | - parent::setUp(); |
|
24 | - } |
|
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(); |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | $form->attributes = $this->values; |
52 | 52 | expect('saveProfile should return the user', $this->assertEquals($user, $form->saveProfile())); |
53 | 53 | return true; |
54 | - expect('saveProfile should set the user\'s attributes to be the form values', $this->assertEquals($this->values, $user->attributes)); |
|
54 | + expect('saveProfile should set the user\'s attributes to be the form values', $this->assertEquals($this->values, $user->attributes)); |
|
55 | 55 | |
56 | 56 | $form->send_email = 'not_a_boolean'; |
57 | 57 | expect('saveProfile should return the user with the partner-related settings equal to null', $this->assertNull($form->saveProfile())); |
58 | 58 | |
59 | - $null_vals = [ |
|
60 | - 'partner_email1' => null, |
|
61 | - 'partner_email2' => null, |
|
62 | - 'partner_email3' => null, |
|
59 | + $null_vals = [ |
|
60 | + 'partner_email1' => null, |
|
61 | + 'partner_email2' => null, |
|
62 | + 'partner_email3' => null, |
|
63 | 63 | 'send_email' => null, |
64 | - 'timezone' => 'America/Los_Angeles', |
|
65 | - ]; |
|
64 | + 'timezone' => 'America/Los_Angeles', |
|
65 | + ]; |
|
66 | 66 | $form->send_email = false; |
67 | - $ret = $form->saveProfile(); |
|
67 | + $ret = $form->saveProfile(); |
|
68 | 68 | expect('saveProfile should return the user with the partner-related settings equal to null', $this->assertEquals($null_vals, $user->attributes)); |
69 | 69 | |
70 | 70 | $form->send_email = 'not_a_boolean'; |
@@ -41,11 +41,11 @@ |
||
41 | 41 | |
42 | 42 | // Set up dependency injections |
43 | 43 | Yii::$container |
44 | - ->set(\common\interfaces\TimeInterface::class, function () { return new \common\components\Time('UTC'); }); |
|
44 | + ->set(\common\interfaces\TimeInterface::class, function() { return new \common\components\Time('UTC'); }); |
|
45 | 45 | Yii::$container |
46 | - ->set(\common\components\Graph::class, function () { return $this->graph; }); |
|
46 | + ->set(\common\components\Graph::class, function() { return $this->graph; }); |
|
47 | 47 | Yii::$container |
48 | - ->set(\common\interfaces\UserBehaviorInterface::class, function () { return new FakeUserBehavior(); }); |
|
48 | + ->set(\common\interfaces\UserBehaviorInterface::class, function() { return new FakeUserBehavior(); }); |
|
49 | 49 | |
50 | 50 | // Actually begin testing |
51 | 51 | $form->attributes = $this->values; |
@@ -70,11 +70,11 @@ |
||
70 | 70 | ]); ?> |
71 | 71 | <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?> |
72 | 72 | <?= $form->field($profile, 'expose_graph')->checkbox() ?> |
73 | - <?php if($profile->expose_graph): ?> |
|
73 | + <?php if ($profile->expose_graph): ?> |
|
74 | 74 | <div class='alert alert-success score-graph-info'>Your score graph can be found at:<br /> <a id="score-graph-link" target="_blank" href="<?=$graph_url?>"><?=$graph_url?></a></div> |
75 | 75 | <?php endif; ?> |
76 | 76 | <?= $form->field($profile, 'send_email')->checkbox() ?> |
77 | - <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
77 | + <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
78 | 78 | <?= $form->field($profile, 'partner_email1')->input('email'); ?> |
79 | 79 | <?= $form->field($profile, 'partner_email2')->input('email'); ?> |
80 | 80 | <?= $form->field($profile, 'partner_email3')->input('email'); ?> |