예제 #1
0
 /**
  * User get data of bill with products.
  */
 public function test_get_bill_with_products()
 {
     $bill = factory(\App\Bill::class)->create(['user_id' => $this->user->id, 'client_id' => $this->client->id]);
     factory(\App\BillProduct::class, 3)->create(['bill_id' => $bill->id, 'product_id' => factory(\App\Product::class)->create(['user_id' => $this->user->id])->id]);
     factory(\App\BillApplicationProduct::class, 4)->create(['bill_id' => $bill->id, 'product_id' => factory(\App\ApplicationProduct::class)->create()->id]);
     $this->actingAs($this->user)->get('/bills/' . $bill->id . '/get')->seeJson(['to_pay' => BillData::getBillToPay($bill->id), 'saved_money' => BillData::getBillSavedMoney($bill->id), 'total' => BillData::getBillPrice($bill->id), 'number_of_products' => BillData::getNumberOfProducts($bill->id)]);
 }
예제 #2
0
 /**
  * Make sure getBillPriceFinalPriceToPaySavedMoneyAndNumberOfProducts method works.
  */
 public function test_it_return_valid_bill_price_final_price_saved_money_to_pay_and_number_of_products()
 {
     $customProduct = factory(\App\Product::class)->create(['user_id' => $this->user->id]);
     $applicationProduct = factory(\App\ApplicationProduct::class)->create();
     factory(\App\BillProduct::class)->create(['bill_id' => $this->bill->id, 'product_id' => $customProduct->id]);
     factory(\App\BillApplicationProduct::class)->create(['bill_id' => $this->bill->id, 'product_id' => $applicationProduct->id]);
     $billData = BillData::getBillPriceFinalPriceToPaySavedMoneyAndNumberOfProducts($this->bill->id);
     $this->assertEquals(BillData::getBillPrice($this->bill->id), $billData['price']);
     $this->assertEquals(BillData::getNumberOfProducts($this->bill->id), $billData['number_of_products']);
     $this->assertEquals(BillData::getBillToPay($this->bill->id), $billData['final_price']);
     $this->assertEquals(BillData::getBillSavedMoney($this->bill->id), $billData['saved_money']);
 }