From 8ec20f4a7870a6733833b525c6c995b31807038c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 18 Jan 2023 07:46:34 +1100 Subject: [PATCH] Tests for company update --- tests/Feature/CompanyTest.php | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 255d51bdff76..418321dc16bc 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -47,6 +47,42 @@ class CompanyTest extends TestCase $this->makeTestData(); } + public function testUpdateCompanyPropertyInvoiceTaskHours() + { + + $company_update = [ + 'invoice_task_hours' => true + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $company_update) + ->assertStatus(200); + + + $arr = $response->json(); + + $this->assertTrue($arr['data']['invoice_task_hours']); + + + $company_update = [ + 'invoice_task_hours' => false + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $company_update) + ->assertStatus(200); + + + $arr = $response->json(); + + $this->assertFalse($arr['data']['invoice_task_hours']); + + } + public function testCompanyList() { $this->withoutMiddleware(PasswordProtection::class);