From 0b1edab660453b65c68c3a1d9cb5b37ab5f53c27 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 20 Mar 2021 11:25:44 +1100 Subject: [PATCH] Task tests for numbers --- tests/Feature/TaskApiTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/Feature/TaskApiTest.php b/tests/Feature/TaskApiTest.php index e9d07ae477..e401ed05e4 100644 --- a/tests/Feature/TaskApiTest.php +++ b/tests/Feature/TaskApiTest.php @@ -14,6 +14,7 @@ use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Session; +use Illuminate\Validation\ValidationException; use Tests\MockAccountData; use Tests\TestCase; @@ -44,6 +45,7 @@ class TaskApiTest extends TestCase { $data = [ 'description' => $this->faker->firstName, + 'number' => 'taskynumber' ]; $response = $this->withHeaders([ @@ -54,6 +56,27 @@ class TaskApiTest extends TestCase $arr = $response->json(); $response->assertStatus(200); + $this->assertEquals('taskynumber', $arr['data']['number']); + + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->put('/api/v1/tasks/'.$arr['data']['id'], $data); + + $response->assertStatus(200); + + try{ + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/tasks', $data); + + $arr = $response->json(); + }catch(ValidationException $e){ + $response->assertStatus(302); + } + $this->assertNotEmpty($arr['data']['number']); }