File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,43 @@ public function testCollectInvoiceWithZeroGrandTotal(array $invoiceData): void
9898 $ this ->model ->collect ($ this ->invoice );
9999 }
100100
101+ /**
102+ * Test for collect invoice with negative grand total
103+ *
104+ * @return void
105+ */
106+ public function testCollectInvoiceWithNegativeGrandTotal (): void
107+ {
108+ $ invoiceData = [
109+ 'order_item ' => [
110+ 'qty_ordered ' => 1 ,
111+ 'discount_amount ' => 25.34 ,
112+ 'base_discount_amount ' => 25.34 ,
113+ ],
114+ 'is_last ' => true ,
115+ 'qty ' => 1 ,
116+ ];
117+ $ invoiceItem [] = $ this ->getInvoiceItem ($ invoiceData );
118+ $ this ->invoice ->method ('getOrder ' )
119+ ->willReturn ($ this ->order );
120+ $ this ->order ->method ('getInvoiceCollection ' )
121+ ->willReturn ([]);
122+ $ this ->invoice ->method ('getAllItems ' )
123+ ->willReturn ($ invoiceItem );
124+ $ this ->invoice ->method ('getGrandTotal ' )
125+ ->willReturn (15.6801 );
126+ $ this ->invoice ->method ('getBaseGrandTotal ' )
127+ ->willReturn (15.6801 );
128+
129+ $ this ->invoice ->expects ($ this ->exactly (1 ))
130+ ->method ('setGrandTotal ' )
131+ ->with (-9.6599 );
132+ $ this ->invoice ->expects ($ this ->exactly (1 ))
133+ ->method ('setBaseGrandTotal ' )
134+ ->with (-9.6599 );
135+ $ this ->model ->collect ($ this ->invoice );
136+ }
137+
101138 /**
102139 * @return array
103140 */
You can’t perform that action at this time.
0 commit comments