title: How to write a unit test for feature statistic the number of product sold
body: <p>I want to write a unit test for the below function. The function is the statistic of the number of products sold. I am looking forward to receiving your ideas for this problem.</p>
  <pre><code>public function index()
  {
      $totalByToday = $this-&gt;productRepo-&gt;getProductSold('day');
      $totalByWeek = $this-&gt;productRepo-&gt;getProductSold('week');
      $totalByMonth = $this-&gt;productRepo-&gt;getProductSold('month');
  
      foreach ($totalByToday as $product) {
          $brands_today[$product-&gt;brand-&gt;name] = 
              $this-&gt;productRepo-&gt;getSumQuantity($product);
      }
  
      foreach ($totalByWeek as $product) {
          $brands_week[$product-&gt;brand-&gt;name] = 
              $this-&gt;productRepo-&gt;getSumQuantity($product);
      }
  
      foreach ($totalByMonth as $product) {
          $brands_month[$product-&gt;brand-&gt;name] = 
              $this-&gt;productRepo-&gt;getSumQuantity($product);
      }
  
      return view('admins.dashboard')-&gt;with([
          'label' =&gt; array_keys($brands_today),
          'quantity1' =&gt; array_values($brands_today),
          'quantity2' =&gt; array_values($brands_week),
          'quantity3' =&gt; array_values($brands_month)
      ]);
  }
  </code></pre>