File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,9 @@ public function getTotal()
329329
330330        $ conditions$ this getConditions ();
331331
332+         // if no conditions were added, just return the sub total 
333+         if ( ! $ conditionscount () ) return  $ subTotal
334+ 
332335        $ conditionseach (function ($ conduse  ($ subTotal$ newTotal$ process
333336        {
334337            if ( $ condgetTarget () === 'total '  )
Original file line number Diff line number Diff line change @@ -37,6 +37,19 @@ public function tearDown()
3737        m::close ();
3838    }
3939
40+     public  function  test_total_without_condition ()
41+     {
42+         $ this fillCart ();
43+ 
44+         $ this assertEquals (187.49 , $ this cart ->getSubTotal (), 'Cart should have sub total of 187.49 ' );
45+ 
46+         // no changes in subtotal as the condition's target added was for total 
47+         $ this assertEquals (187.49 , $ this cart ->getSubTotal (), 'Cart should have sub total of 187.49 ' );
48+ 
49+         // total should be the same as subtotal 
50+         $ this assertEquals (187.49 , $ this cart ->getTotal (), 'Cart should have a total of 187.49 ' );
51+     }
52+ 
4053    public  function  test_total_with_condition ()
4154    {
4255        $ this fillCart ();
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments