/** * Delete bill application product of another user. * * @group fail * @group deleteBillProduct */ public function testDeleteBillProductOfAnotherUser() { $firstData = $this->generateData(); $secondData = $this->generateData(); $this->actingAs($secondData['user'])->get(TestUrlBuilder::deleteBillProduct($firstData['bill']->id, $firstData['product']->id, $firstData['product']->code, $firstData['billProduct']->id))->seeJson(['success' => false, 'message' => trans('common.general_error')]); }
/** * Delete an application product from bill using the code of another. Fail response is expected. */ public function testDeleteBillApplicationProductWithCodeOfAnotherProduct() { // Generate user, client and bill $user = factory(App\User::class)->create(); $client = $user->clients()->save(factory(App\Client::class)->make()); $bill = $user->bills()->save(factory(App\Bill::class)->make(['client_id' => $client->id])); // Generate 2 application products $firstApplicationProduct = factory(App\ApplicationProduct::class)->create(); $secondApplicationProduct = factory(App\ApplicationProduct::class)->create(); // Add to bill application products table $bill->applicationProducts()->save(factory(App\BillApplicationProduct::class)->make(['product_id' => $firstApplicationProduct->id])); $bill->applicationProducts()->save(factory(App\BillApplicationProduct::class)->make(['product_id' => $secondApplicationProduct->id])); // Try to delete first application product from bill using code of the second $this->actingAs($user)->get(TestUrlBuilder::deleteBillProduct($bill->id, $firstApplicationProduct->id, $secondApplicationProduct->code))->seeJson(['success' => false, 'message' => trans('common.general_error')]); }