77use App \Providers \AppServiceProvider ;
88use Tests \TestCase ;
99
10- class TestEloquentNoteService extends TestCase
10+ class EloquentNoteServiceTest extends TestCase
1111{
1212
1313 public function setUp ()
@@ -34,6 +34,18 @@ public function testParseTime(string $time, float $expectedHours)
3434 public function parseTimeDataProvider ()
3535 {
3636 return [
37+ [
38+ 'time ' => '0s ' ,
39+ 'hours ' => 0 ,
40+ ],
41+ [
42+ 'time ' => '36s ' ,
43+ 'hours ' => 0.01 ,
44+ ],
45+ [
46+ 'time ' => '360s ' ,
47+ 'hours ' => 0.1 ,
48+ ],
3749 [
3850 'time ' => '0m ' ,
3951 'hours ' => 0 ,
@@ -99,7 +111,7 @@ public function testParseSpentTimeItem(array $itemData, array $prevItemData = nu
99111 $ prev = $ prevItemData ? new Note ($ prevItemData ) : null ;
100112 $ row = $ method ->invokeArgs ($ service , [$ item , $ prev ]);
101113 $ this ->assertEquals ($ expectedRow ['hours ' ], $ row ['hours ' ]);
102- // $this->assertEquals($expectedRow['spent_at'], $row['spent_at']);
114+ $ this ->assertEquals ($ expectedRow ['spent_at ' ], $ row ['spent_at ' ]);
103115 $ this ->assertEquals ($ expectedRow ['gitlab_created_at ' ], $ row ['gitlab_created_at ' ]);
104116 $ this ->assertEquals ($ expectedRow ['description ' ], $ row ['description ' ]);
105117 }
@@ -125,7 +137,20 @@ public function parseSpentTimeItemDataProvider()
125137 'prevItemData ' => null ,
126138 'expectedRow ' => [
127139 'hours ' => 1.5 ,
128- 'spent_at ' => null ,
140+ 'spent_at ' => '2018-11-24 ' ,
141+ 'gitlab_created_at ' => '2018-01-01T12:12:13 ' ,
142+ 'description ' => null ,
143+ ],
144+ ],
145+ [
146+ 'itemData ' => [
147+ 'body ' => 'added 1h 30m 36s of time spent at 2018-11-14 just now ' ,
148+ 'gitlab_created_at ' => '2018-01-01T12:12:13 ' ,
149+ ],
150+ 'prevItemData ' => null ,
151+ 'expectedRow ' => [
152+ 'hours ' => 1.51 ,
153+ 'spent_at ' => '2018-11-14 ' ,
129154 'gitlab_created_at ' => '2018-01-01T12:12:13 ' ,
130155 'description ' => null ,
131156 ],
@@ -199,7 +224,7 @@ public function parseSpentTimeItemDataProvider()
199224
200225 [
201226 'itemData ' => [
202- 'body ' => 'added 2h of time spent at 2018-11-24 just now ' ,
227+ 'body ' => 'added 2h of time spent at 2018-11-21 just now ' ,
203228 'gitlab_created_at ' => '2018-01-01T12:12:12 ' ,
204229 ],
205230 'prevItemData ' => [
@@ -208,14 +233,14 @@ public function parseSpentTimeItemDataProvider()
208233 ],
209234 'expectedRow ' => [
210235 'hours ' => 2 ,
211- 'spent_at ' => null ,
236+ 'spent_at ' => ' 2018-11-21 ' ,
212237 'gitlab_created_at ' => '2018-01-01T12:12:12 ' ,
213238 'description ' => 'added 1h 30m of time spent at 2018-11-24 just now ' ,
214239 ],
215240 ],
216241 [
217242 'itemData ' => [
218- 'body ' => 'added 2h of time spent at 2018-11-24 just now ' ,
243+ 'body ' => 'added 2h of time spent at 2018-11-23 just now ' ,
219244 'gitlab_created_at ' => '2018-01-02T12:12:12 ' ,
220245 ],
221246 'prevItemData ' => [
@@ -224,7 +249,7 @@ public function parseSpentTimeItemDataProvider()
224249 ],
225250 'expectedRow ' => [
226251 'hours ' => 2 ,
227- 'spent_at ' => null ,
252+ 'spent_at ' => ' 2018-11-23 ' ,
228253 'gitlab_created_at ' => '2018-01-02T12:12:12 ' ,
229254 'description ' => null ,
230255 ],
@@ -241,7 +266,7 @@ public function parseSpentTimeItemDataProvider()
241266 ],
242267 'expectedRow ' => [
243268 'hours ' => 3.5 ,
244- 'spent_at ' => null ,
269+ 'spent_at ' => ' 2018-11-24 ' ,
245270 'gitlab_created_at ' => '2018-01-01T12:12:12 ' ,
246271 'description ' => 'test primary with hours ' ,
247272 ],
@@ -257,7 +282,7 @@ public function parseSpentTimeItemDataProvider()
257282 ],
258283 'expectedRow ' => [
259284 'hours ' => 4.5 ,
260- 'spent_at ' => null ,
285+ 'spent_at ' => ' 2018-11-24 ' ,
261286 'gitlab_created_at ' => '2018-01-02T12:12:12 ' ,
262287 'description ' => null ,
263288 ],
0 commit comments