Ejemplo n.º 1
0
 /**
  * @depends testUserCanStartTimetrackingOnATask
  */
 public function testOnlyOneTimetrackingIsPossiblePerUser()
 {
     $this->actingAs($this->user)->makeRequest('post', '/tracking/start', ['task_id' => $this->task1->id])->seeJson(['active' => true]);
     $this->actingAs($this->user)->makeRequest('post', '/tracking/start', ['task_id' => $this->task2->id])->seeJson(['active' => false])->seeJson(['active' => true]);
     $tracking1 = Tracking::personal()->where('task_id', $this->task1->id)->get()->first();
     $this->assertNotNull($tracking1->stopped_at);
     $this->assertEquals($tracking1->active, 0);
     $tracking2 = Tracking::personal()->where('task_id', $this->task2->id)->get()->first();
     $this->assertNull($tracking2->stopped_at);
     $this->assertEquals($tracking2->active, 1);
 }
Ejemplo n.º 2
0
 protected function stopActive()
 {
     $tracking = Tracking::personal()->active()->get()->first();
     if (!empty($tracking)) {
         $tracking->stopped_at = date('Y-m-d H:i:s');
         $tracking->active = 0;
         $tracking->save();
         return ['task_id' => $tracking->task_id, 'active' => false];
     }
     return [];
 }