From 32d9c4109eebc4d12d1c9d7d4588a1a272ae5cff Mon Sep 17 00:00:00 2001 From: = Date: Sat, 20 Mar 2021 11:28:39 +1100 Subject: [PATCH] Vendor number tests --- tests/Feature/VendorApiTest.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/Feature/VendorApiTest.php b/tests/Feature/VendorApiTest.php index cd8983413200..d4288c8b5f3c 100644 --- a/tests/Feature/VendorApiTest.php +++ b/tests/Feature/VendorApiTest.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; @@ -59,6 +60,7 @@ class VendorApiTest extends TestCase $data = [ 'name' => $this->faker->firstName, 'id_number' => 'Coolio', + 'number' => 'wiggles' ]; $response = $this->withHeaders([ @@ -67,6 +69,33 @@ class VendorApiTest extends TestCase ])->put('/api/v1/vendors/'.$this->encodePrimaryKey($this->vendor->id), $data); $response->assertStatus(200); + + $arr = $response->json(); + + $this->assertEquals('Coolio', $arr['data']['id_number']); + $this->assertEquals('wiggles', $arr['data']['number']); + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->put('/api/v1/vendors/'.$this->encodePrimaryKey($this->vendor->id), $data); + + $response->assertStatus(200); + + + try{ + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/vendors/', $data); + + + }catch(ValidationException $e){ + + $response->assertStatus(302); + + } + } public function testVendorGet()