From 3edb4de3e7b560afb9376270f60d0d52bf23cd4f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 10 Mar 2022 17:17:40 +1100 Subject: [PATCH] Start stop tasks via API --- app/Repositories/TaskRepository.php | 10 +++++++++ tests/Feature/TaskApiTest.php | 33 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php index 2717f11dc..3954c9515 100644 --- a/app/Repositories/TaskRepository.php +++ b/app/Repositories/TaskRepository.php @@ -182,4 +182,14 @@ class TaskRepository extends BaseRepository }); } + + public function start(Task $task) + { + + } + + public function stop(Task $task) + { + + } } diff --git a/tests/Feature/TaskApiTest.php b/tests/Feature/TaskApiTest.php index e401ed05e..a89eea1a3 100644 --- a/tests/Feature/TaskApiTest.php +++ b/tests/Feature/TaskApiTest.php @@ -41,6 +41,39 @@ class TaskApiTest extends TestCase Model::reguard(); } + public function testStartTask() + { + $log = [ + [2,1], + [10,20] + ]; + + $last = end($log); + + $this->assertEquals(10, $last[0]); + $this->assertEquals(20, $last[1]); + + $new = [time(), 0]; + + array_push($log, $new); + + $this->assertEquals(3, count($log)); + + + //test task is started + $last = end($log); + $this->assertTrue($last[1] === 0); + + //stop task + $last = end($log); + $last[1] = time(); + + $this->assertTrue($last[1] !== 0) + + + } + + public function testTaskPost() { $data = [