mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:14:36 -04:00
Tests for starting and stopping tasks
This commit is contained in:
parent
b267353ced
commit
fa92dd76e4
@ -51,7 +51,6 @@ class TaskRepository extends BaseRepository
|
|||||||
$task->fill($data);
|
$task->fill($data);
|
||||||
$task->save();
|
$task->save();
|
||||||
|
|
||||||
$task->start_time = $task->start_time ?: $task->calcStartTime();
|
|
||||||
$task->number = empty($task->number) ? $this->getNextTaskNumber($task) : $task->number;
|
$task->number = empty($task->number) ? $this->getNextTaskNumber($task) : $task->number;
|
||||||
|
|
||||||
if (isset($data['description'])) {
|
if (isset($data['description'])) {
|
||||||
@ -90,6 +89,7 @@ class TaskRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$task->time_log = json_encode($time_log);
|
$task->time_log = json_encode($time_log);
|
||||||
|
$task->start_time = $task->start_time ?: $task->calcStartTime();
|
||||||
$task->duration = $task->calcDuration();
|
$task->duration = $task->calcDuration();
|
||||||
|
|
||||||
$task->save();
|
$task->save();
|
||||||
|
@ -62,7 +62,29 @@ class TaskApiTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/tasks', $data);
|
])->post('/api/v1/tasks', $data);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
$response->assertStatus(200);
|
$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()
|
public function testTaskPut()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user