@@ -158,15 +158,15 @@ |
||
| 158 | 158 | public function setUp(): void |
| 159 | 159 | { |
| 160 | 160 | $this->question = $this->getMockBuilder('\common\models\Question') |
| 161 | - ->setMethods(['save', 'attributes']) |
|
| 162 | - ->getMock(); |
|
| 161 | + ->setMethods(['save', 'attributes']) |
|
| 162 | + ->getMock(); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function testParseQuestionData() { |
| 166 | 166 | $questions = array_map(function ($d) { |
| 167 | 167 | $q = $this->getMockBuilder('\common\models\Question') |
| 168 | - ->setMethods(['save', 'attributes']) |
|
| 169 | - ->getMock(); |
|
| 168 | + ->setMethods(['save', 'attributes']) |
|
| 169 | + ->getMock(); |
|
| 170 | 170 | $q->method('save')->willReturn(true); |
| 171 | 171 | $q->method('attributes') |
| 172 | 172 | ->willReturn([ |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | public function setUp(): void |
| 281 | 281 | { |
| 282 | 282 | // pull in test data |
| 283 | - $data = require(__DIR__.'/../data/checkinData.php'); |
|
| 283 | + $data = require(__DIR__ . '/../data/checkinData.php'); |
|
| 284 | 284 | $this->singleBhvr = $data['singleBhvr']; |
| 285 | 285 | $this->manyBhvrs = $data['manyBhvrs']; |
| 286 | 286 | $this->allBhvrs = $data['allBhvrs']; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
| 291 | 291 | $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion'); |
| 292 | 292 | $this->container->set('common\interfaces\BehaviorInterface', 'common\models\Behavior'); |
| 293 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 293 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 294 | 294 | return new \common\components\Time('America/Los_Angeles'); |
| 295 | 295 | }); |
| 296 | 296 | |
@@ -447,8 +447,8 @@ discard block |
||
| 447 | 447 | ->setMethods(['getIsNewRecord', 'save', 'getBehaviorsWithCounts']) |
| 448 | 448 | ->getMock(); |
| 449 | 449 | |
| 450 | - $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php'); |
|
| 451 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); |
|
| 450 | + $bhvrs = require(__DIR__ . '/../data/behaviorsWithCounts.php'); |
|
| 451 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); |
|
| 452 | 452 | $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs); |
| 453 | 453 | expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown())); |
| 454 | 454 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | protected function tearDown(): void |
| 23 | 23 | { |
| 24 | 24 | // just in case we're forgetful :) |
| 25 | - if(file_exists(Utility::$REVISION_FILE)) $this->_deleteRevFile(); |
|
| 25 | + if (file_exists(Utility::$REVISION_FILE)) $this->_deleteRevFile(); |
|
| 26 | 26 | parent::tearDown(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function testGetRevHash() |
| 39 | 39 | { |
| 40 | - $this->specify('getRevHash should function correctly', function () { |
|
| 40 | + $this->specify('getRevHash should function correctly', function() { |
|
| 41 | 41 | expect('getRevHash should return false when the file does not exist', $this->assertFalse(Utility::getRevHash())); |
| 42 | 42 | |
| 43 | 43 | $this->_createRevFile(); |
@@ -22,7 +22,9 @@ |
||
| 22 | 22 | protected function tearDown(): void |
| 23 | 23 | { |
| 24 | 24 | // just in case we're forgetful :) |
| 25 | - if(file_exists(Utility::$REVISION_FILE)) $this->_deleteRevFile(); |
|
| 25 | + if(file_exists(Utility::$REVISION_FILE)) { |
|
| 26 | + $this->_deleteRevFile(); |
|
| 27 | + } |
|
| 26 | 28 | parent::tearDown(); |
| 27 | 29 | } |
| 28 | 30 | |
@@ -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(): void |
| 21 | 21 | { |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | ->willReturn('random1DH4sh'); |
| 39 | 39 | $graph = new Graph($this->user); |
| 40 | 40 | |
| 41 | - expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))).'/site/web/charts/random1DH4sh.png', $graph->getFilepath())); |
|
| 41 | + expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))) . '/site/web/charts/random1DH4sh.png', $graph->getFilepath())); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function testGetUrl() { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | ->method('getFilepath') |
| 60 | 60 | ->willReturn($this->filepath); |
| 61 | 61 | |
| 62 | - if(!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) { |
|
| 62 | + if (!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) { |
|
| 63 | 63 | touch($this->filepath); |
| 64 | 64 | expect('just a check to be sure $filepath is sane', $this->assertStringEndsWith('/_output/test_graph.png', $this->filepath)); |
| 65 | 65 | expect('the generated file should exist', $this->assertFileExists($this->filepath)); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | expect('the generated file should be readable', $this->assertFileExists($this->filepath_extra)); |
| 92 | 92 | |
| 93 | 93 | // cleanup |
| 94 | - if(file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) { |
|
| 94 | + if (file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) { |
|
| 95 | 95 | // just in case something is weird, we don't want to straight rm this file |
| 96 | 96 | unlink($this->filepath_extra); |
| 97 | 97 | rmdir(dirname($this->filepath_extra)); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | -function checkinBreakdown () { |
|
| 102 | +function checkinBreakdown() { |
|
| 103 | 103 | return [ |
| 104 | 104 | '2019-01-31' => [], |
| 105 | 105 | '2019-02-01' => [], |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | '2019-02-27' => [], |
| 233 | 233 | '2019-02-28' => [], |
| 234 | 234 | '2019-03-01' => [ |
| 235 | - 2 => [ 'name' => 'Forgetting Priorities', |
|
| 235 | + 2 => ['name' => 'Forgetting Priorities', |
|
| 236 | 236 | 'count' => 6, |
| 237 | 237 | 'color' => '#4CA100', |
| 238 | 238 | 'highlight' => '#61B219', |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $this->container = new \yii\di\Container; |
| 120 | 120 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
| 121 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 121 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 122 | 122 | return new \common\components\Time('America/Los_Angeles'); |
| 123 | 123 | }); |
| 124 | 124 | parent::setUp(); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | public function testAttributeLabels() |
| 128 | 128 | { |
| 129 | - $this->specify('attributeLabels should function properly', function () { |
|
| 129 | + $this->specify('attributeLabels should function properly', function() { |
|
| 130 | 130 | $model = $this->container->get('\site\models\CheckinForm'); |
| 131 | 131 | expect('attributeLabels should be correct', $this->assertEquals([ |
| 132 | 132 | 'behaviors1' => 'Restoration', |
@@ -142,32 +142,32 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | public function testSetBehaviors() |
| 144 | 144 | { |
| 145 | - $this->specify('setBehaviors should function properly', function () { |
|
| 145 | + $this->specify('setBehaviors should function properly', function() { |
|
| 146 | 146 | $model = $this->container->get('\site\models\CheckinForm'); |
| 147 | 147 | |
| 148 | 148 | $model->setBehaviors($this->behaviors); |
| 149 | - expect('behaviors1 should be correct', $this->assertEquals([ 0 => 7 ], $model->behaviors1)); |
|
| 150 | - expect('behaviors2 should be correct', $this->assertEquals([ 0 => 12, 1 => 13, 2 => 17, 3 => 18 ], $model->behaviors2)); |
|
| 151 | - expect('behaviors3 should be correct', $this->assertEquals([ 0 => 28, 1 => 38, 2 => 46 ], $model->behaviors3)); |
|
| 152 | - expect('behaviors4 should be correct', $this->assertEquals([ 0 => 47, 1 => 56, 2 => 62 ], $model->behaviors4)); |
|
| 153 | - expect('behaviors5 should be correct', $this->assertEquals([ 0 => 78, 1 => 79 ], $model->behaviors5)); |
|
| 154 | - expect('behaviors6 should be correct', $this->assertEquals([ 0 => 104 ], $model->behaviors6)); |
|
| 155 | - expect('behaviors7 should be correct', $this->assertEquals([ 0 => 128 ], $model->behaviors7)); |
|
| 149 | + expect('behaviors1 should be correct', $this->assertEquals([0 => 7], $model->behaviors1)); |
|
| 150 | + expect('behaviors2 should be correct', $this->assertEquals([0 => 12, 1 => 13, 2 => 17, 3 => 18], $model->behaviors2)); |
|
| 151 | + expect('behaviors3 should be correct', $this->assertEquals([0 => 28, 1 => 38, 2 => 46], $model->behaviors3)); |
|
| 152 | + expect('behaviors4 should be correct', $this->assertEquals([0 => 47, 1 => 56, 2 => 62], $model->behaviors4)); |
|
| 153 | + expect('behaviors5 should be correct', $this->assertEquals([0 => 78, 1 => 79], $model->behaviors5)); |
|
| 154 | + expect('behaviors6 should be correct', $this->assertEquals([0 => 104], $model->behaviors6)); |
|
| 155 | + expect('behaviors7 should be correct', $this->assertEquals([0 => 128], $model->behaviors7)); |
|
| 156 | 156 | |
| 157 | 157 | $model->setBehaviors($this->behaviors); |
| 158 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 7 ], $model->behaviors1)); |
|
| 159 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 12, 1 => 13, 2 => 17, 3 => 18 ], $model->behaviors2)); |
|
| 160 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 28, 1 => 38, 2 => 46 ], $model->behaviors3)); |
|
| 161 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 47, 1 => 56, 2 => 62 ], $model->behaviors4)); |
|
| 162 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 78, 1 => 79 ], $model->behaviors5)); |
|
| 163 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 104 ], $model->behaviors6)); |
|
| 164 | - expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([ 0 => 128 ], $model->behaviors7)); |
|
| 158 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 7], $model->behaviors1)); |
|
| 159 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 12, 1 => 13, 2 => 17, 3 => 18], $model->behaviors2)); |
|
| 160 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 28, 1 => 38, 2 => 46], $model->behaviors3)); |
|
| 161 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 47, 1 => 56, 2 => 62], $model->behaviors4)); |
|
| 162 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 78, 1 => 79], $model->behaviors5)); |
|
| 163 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 104], $model->behaviors6)); |
|
| 164 | + expect('setBehaviors should not append behaviors to existing ones', $this->assertEquals([0 => 128], $model->behaviors7)); |
|
| 165 | 165 | }); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | public function testValidateBehaviors() |
| 169 | 169 | { |
| 170 | - $this->specify('validateBehaviors should function properly', function () { |
|
| 170 | + $this->specify('validateBehaviors should function properly', function() { |
|
| 171 | 171 | $model = $this->container->get('\site\models\CheckinForm'); |
| 172 | 172 | $model->setBehaviors($this->behaviors); |
| 173 | 173 | expect('validation should be good', $this->assertTrue($model->validate())); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | $model = $this->container->get('\site\models\CheckinForm'); |
| 216 | 216 | $model->custom_behaviors = []; |
| 217 | - $model->compiled_behaviors = [ 1, 2, 3]; |
|
| 217 | + $model->compiled_behaviors = [1, 2, 3]; |
|
| 218 | 218 | expect('to return an empty array if no custom behaviors are set', $this->assertEquals([], $model->getCustomBehaviors())); |
| 219 | 219 | } |
| 220 | 220 | |