faker = \Faker\Factory::create(); Model::reguard(); $this->makeTestData(); } public function testPostNewPurchaseOrderPdf() { $purchase_order = [ 'status_id' => 1, 'discount' => 0, 'is_amount_discount' => 1, 'number' => Str::random(10), 'po_number' => Str::random(5), 'due_date' => '2022-01-01', 'date' => '2022-01-01', 'balance' => 100, 'amount' => 100, 'public_notes' => 'notes', 'is_deleted' => 0, 'custom_value1' => 0, 'custom_value2' => 0, 'custom_value3' => 0, 'custom_value4' => 0, 'status' => 1, 'vendor_id' => $this->encodePrimaryKey($this->vendor->id), ]; $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/purchase_orders/', $purchase_order) ->assertStatus(200); $arr = $response->json(); $purchase_order = PurchaseOrder::find($this->decodePrimaryKey($arr['data']['id'])); $this->assertNotNull($purchase_order); $x = $purchase_order->service()->markSent()->getPurchaseOrderPdf(); nlog($x); } public function testPurchaseOrderRest() { $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)); $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'); $response->assertStatus(200); $purchase_order_update = [ 'tax_name1' => 'dippy', ]; $this->assertNotNull($this->purchase_order); $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), $purchase_order_update) ->assertStatus(200); } public function testPostNewPurchaseOrder() { $purchase_order = [ 'status_id' => 1, 'discount' => 0, 'is_amount_discount' => 1, 'number' => '34343xx43', 'public_notes' => 'notes', 'is_deleted' => 0, 'custom_value1' => 0, 'custom_value2' => 0, 'custom_value3' => 0, 'custom_value4' => 0, 'status' => 1, 'vendor_id' => $this->encodePrimaryKey($this->vendor->id), ]; $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->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)); $response->assertStatus(200); } public function testPurchaseOrderUpdate() { $data = [ 'status_id' => 1, 'discount' => 0, 'is_amount_discount' => 1, 'number' => '3434343', 'public_notes' => 'notes', 'is_deleted' => 0, 'custom_value1' => 0, 'custom_value2' => 0, 'custom_value3' => 0, 'custom_value4' => 0, 'status' => 1, 'vendor_id' => $this->encodePrimaryKey($this->vendor->id), ]; $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); $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); $response->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->post('/api/v1/purchase_orders/', $data); $response->assertStatus(302); } }