Esempio n. 1
0
 /**
  * Test soldProductsDetails works as expected then are more products in compared campaign.
  */
 public function test_sold_products_with_more_products_in_compared_campaign()
 {
     $product = factory(\App\Product::class)->create(['user_id' => $this->user->id]);
     factory(\App\BillProduct::class)->create(['bill_id' => $this->billInFirstCampaign->id, 'product_id' => $product->id, 'quantity' => 18]);
     factory(\App\BillProduct::class)->create(['bill_id' => $this->billInComparedCampaign->id, 'product_id' => $product->id, 'quantity' => 20]);
     $expectedStatistics = ['message' => trans('statistics.sold_products_down_trend', ['campaign_number' => $this->firstCampaign['number'], 'campaign_year' => $this->firstCampaign['year'], 'minus' => 2, 'number' => 18, 'other_campaign_number' => $this->secondCampaign['number'], 'other_campaign_year' => $this->secondCampaign['year']]), 'title' => trans('statistics.sold_products_down_trend_title', ['percent' => '10.00']), 'products_sold_in_campaign' => '18', 'products_in_campaign_to_compare' => '20'];
     $expectedStatistics = array_merge($expectedStatistics, $this->baseExpected);
     $this->actingAs($this->user)->assertEquals($expectedStatistics, \App\Helpers\Statistics\CompareCampaignsStatistics::soldProductsDetails($this->firstCampaign, $this->secondCampaign));
 }