1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Tests for starting and stopping tasks

This commit is contained in:
David Bomba 2020-10-29 21:44:05 +11:00
parent b267353ced
commit fa92dd76e4
2 changed files with 23 additions and 1 deletions

View File

@ -51,7 +51,6 @@ class TaskRepository extends BaseRepository
$task->fill($data);
$task->save();
$task->start_time = $task->start_time ?: $task->calcStartTime();
$task->number = empty($task->number) ? $this->getNextTaskNumber($task) : $task->number;
if (isset($data['description'])) {
@ -90,6 +89,7 @@ class TaskRepository extends BaseRepository
}
$task->time_log = json_encode($time_log);
$task->start_time = $task->start_time ?: $task->calcStartTime();
$task->duration = $task->calcDuration();
$task->save();

View File

@ -62,7 +62,29 @@ class TaskApiTest extends TestCase
'X-API-TOKEN' => $this->token,
])->post('/api/v1/tasks', $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertNotEmpty($arr['data']['number']);
}
public function testTaskPostWithActionStart()
{
$data = [
'description' => $this->faker->firstName,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/tasks?action=start', $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertGreaterThan(0, $arr['data']['start_time']);
}
public function testTaskPut()