Esempio n. 1
0
 /**
  * Make sure detailsAboutSales works as expected when both campaigns have same sales.
  */
 public function test_details_about_sales_when_both_campaigns_have_the_same_sales()
 {
     $bill = factory(\App\Bill::class)->create(['user_id' => $this->user->id, 'client_id' => $this->client->id, 'campaign_id' => \App\Campaign::where('number', $this->firstCampaign['number'])->where('year', $this->firstCampaign['year'])->first()->id]);
     $secondBill = factory(\App\Bill::class)->create(['user_id' => $this->user->id, 'client_id' => $this->client->id, 'campaign_id' => \App\Campaign::where('number', $this->secondCampaign['number'])->where('year', $this->secondCampaign['year'])->first()->id]);
     $product = factory(\App\Product::class)->create(['user_id' => $this->user->id]);
     factory(\App\BillProduct::class)->create(['bill_id' => $bill->id, 'product_id' => $product->id, 'price' => 100, 'quantity' => 1, 'final_price' => 100, 'discount' => 0, 'calculated_discount' => 0]);
     factory(\App\BillProduct::class)->create(['bill_id' => $secondBill->id, 'product_id' => $product->id, 'price' => 100, 'quantity' => 1, 'final_price' => 100, 'discount' => 0, 'calculated_discount' => 0]);
     $this->translationData['sales'] = number_format(100, 2);
     $expected = ['message' => trans('statistics.details_about_sales_equal_trend', $this->translationData), 'title' => trans('statistics.details_about_sales_equal_trend_title'), 'sales' => $this->translationData['sales'], 'sales_in_campaign_to_compare' => number_format(100, 2)];
     $expected = array_merge($expected, $this->baseExpected);
     $this->actingAs($this->user)->assertEquals($expected, \App\Helpers\Statistics\CompareCampaignsStatistics::detailsAboutSales($this->firstCampaign, $this->secondCampaign));
 }