From 74411da11fd76c8f4964e90d1e0d6136bdeba5fa Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 22 Aug 2024 16:57:13 +1000 Subject: [PATCH] Fixes for tests --- tests/Unit/ClientSettingsTest.php | 54 +++++++++++-------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/tests/Unit/ClientSettingsTest.php b/tests/Unit/ClientSettingsTest.php index a98379e32397..74448f4c3bd9 100644 --- a/tests/Unit/ClientSettingsTest.php +++ b/tests/Unit/ClientSettingsTest.php @@ -258,17 +258,12 @@ class ClientSettingsTest extends TestCase $response = false; - try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - // nlog($message); - } - - $response->assertStatus(302); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); + + $response->assertStatus(422); } public function testClientIllegalPaymenTerms() @@ -288,17 +283,13 @@ class ClientSettingsTest extends TestCase $response = false; - try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - nlog($message); - } + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); - $response->assertStatus(302); + + $response->assertStatus(422); } public function testClientIllegalValidUntil() @@ -318,17 +309,14 @@ class ClientSettingsTest extends TestCase $response = false; - try { + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - nlog($message); - } + ])->postJson('/api/v1/clients/', $data); - $response->assertStatus(302); + + $response->assertStatus(422); } public function testClientIllegalDefaultTaskRate() @@ -381,17 +369,13 @@ class ClientSettingsTest extends TestCase $response = false; - try { $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - nlog($message); - } + ])->postJson('/api/v1/clients/', $data); - $response->assertStatus(302); + + $response->assertStatus(422); } public function testClientSettingBools()