/** * Make sure all method works as expected. */ public function test_all_client_statistics_method() { // Calculate expected earnings $expectedEarnings = $this->billProduct->final_price + $this->secondBillProduct->final_price; $expectedEarnings += $this->billApplicationProduct->final_price + $this->secondBillApplicationProduct->final_price; $expectedEarnings = number_format($expectedEarnings, 2); // Calculate earnings in current campaign $expectedEarningsInCurrentCampaign = 0; // Calculate money user has to receive $expectedMoneyUserHasToReceive = 0; // Calculate number of products ordered $expectedNumberOfProductsOrdered = $this->billProduct->quantity + $this->secondBillProduct->quantity; $expectedNumberOfProductsOrdered += $this->billApplicationProduct->quantity + $this->secondBillApplicationProduct->quantity; // Calculate total discount received $expectedDiscountReceived = ($this->billProduct->price - $this->billProduct->final_price) * $this->billProduct->quantity; $expectedDiscountReceived += ($this->secondBillProduct->price - $this->secondBillProduct->final_price) * $this->secondBillProduct->quantity; $expectedDiscountReceived += ($this->billApplicationProduct->price - $this->billApplicationProduct->final_price) * $this->billApplicationProduct->quantity; $expectedDiscountReceived += ($this->secondBillApplicationProduct->price - $this->secondBillApplicationProduct->final_price) * $this->secondBillApplicationProduct->quantity; $this->assertEquals($expectedEarnings, ClientStatistics::earnings($this->client->id)); $this->assertEquals(floor($expectedMoneyUserHasToReceive), floor(ClientStatistics::moneyUserHasToReceive($this->client->id))); $this->assertEquals($expectedNumberOfProductsOrdered, ClientStatistics::totalNumberOfProductsOrdered($this->client->id)); $this->assertEquals(floor($expectedDiscountReceived), floor(ClientStatistics::totalDiscountReceived($this->client->id))); }