diff --git a/tests/Feature/PurchaseOrderTest.php b/tests/Feature/PurchaseOrderTest.php index 69504545a804..63799022b7aa 100644 --- a/tests/Feature/PurchaseOrderTest.php +++ b/tests/Feature/PurchaseOrderTest.php @@ -37,6 +37,7 @@ class PurchaseOrderTest extends TestCase Model::reguard(); $this->makeTestData(); + } public function testPurchaseOrderRest() @@ -44,18 +45,18 @@ class PurchaseOrderTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->get('/api/v1/purchase_orders/'.$this->encodePrimaryKey($this->purchase_order->id)); + ])->get('/api/v1/purchase_orders/' . $this->encodePrimaryKey($this->purchase_order->id)); $response->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->get('/api/v1/purchase_orders/'.$this->encodePrimaryKey($this->purchase_order->id).'/edit'); + ])->get('/api/v1/purchase_orders/' . $this->encodePrimaryKey($this->purchase_order->id) . '/edit'); $response->assertStatus(200); - $credit_update = [ + $purchase_order_update = [ 'tax_name1' => 'dippy', ]; @@ -64,14 +65,14 @@ class PurchaseOrderTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/purchase_orders/'.$this->encodePrimaryKey($this->purchase_order->id), $credit_update) + ])->put('/api/v1/purchase_orders/' . $this->encodePrimaryKey($this->purchase_order->id), $purchase_order_update) ->assertStatus(200); } + public function testPostNewPurchaseOrder() { $purchase_order = [ 'status_id' => 1, - 'number' => 'dfdfd', 'discount' => 0, 'is_amount_discount' => 1, 'number' => '34343xx43', @@ -91,20 +92,21 @@ class PurchaseOrderTest extends TestCase ])->post('/api/v1/purchase_orders/', $purchase_order) ->assertStatus(200); } + public function testPurchaseOrderDelete() { $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->delete('/api/v1/purchase_orders/'.$this->encodePrimaryKey($this->purchase_order->id)); + ])->delete('/api/v1/purchase_orders/' . $this->encodePrimaryKey($this->purchase_order->id)); $response->assertStatus(200); } + public function testPurchaseOrderUpdate() { $data = [ 'status_id' => 1, - 'number' => 'dfdfd', 'discount' => 0, 'is_amount_discount' => 1, 'number' => '3434343', @@ -121,14 +123,14 @@ class PurchaseOrderTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/purchase_orders/'.$this->encodePrimaryKey($this->purchase_order->id), $data); + ])->put('/api/v1/purchase_orders/' . $this->encodePrimaryKey($this->purchase_order->id), $data); $response->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/purchase_orders/'.$this->encodePrimaryKey($this->purchase_order->id), $data); + ])->put('/api/v1/purchase_orders/' . $this->encodePrimaryKey($this->purchase_order->id), $data); $response->assertStatus(200); diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index 0dddbaa32df2..2bb170b9388b 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -36,6 +36,8 @@ use App\Models\GroupSetting; use App\Models\InvoiceInvitation; use App\Models\Product; use App\Models\Project; +use App\Models\PurchaseOrder; +use App\Models\PurchaseOrderInvitation; use App\Models\Quote; use App\Models\QuoteInvitation; use App\Models\RecurringExpense; @@ -476,6 +478,26 @@ trait MockAccountData $this->purchase_order->save(); + PurchaseOrderInvitation::factory()->create([ + 'user_id' => $user_id, + 'company_id' => $this->company->id, + 'vendor_contact_id' => $vendor_contact->id, + 'purchase_order_id' => $this->purchase_order->id, + ]); + + + + $purchase_order_invitations = PurchaseOrderInvitation::whereCompanyId($this->purchase_order->company_id) + ->wherePurchaseOrderId($this->purchase_order->id); + + $this->purchase_order->setRelation('invitations', $purchase_order_invitations); + + $this->purchase_order->service()->markSent(); + + $this->purchase_order->setRelation('client', $this->client); + $this->purchase_order->setRelation('company', $this->company); + + $this->purchase_order->save(); $this->credit = CreditFactory::create($this->company->id, $user_id);