4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
- // @codingStandardsIgnoreFile
8
-
9
7
namespace Magento \Sales \Test \Unit \Model \Order \Invoice \Total ;
10
8
11
9
/**
@@ -37,11 +35,11 @@ protected function _getInvoiceCollection(array $invoicesData)
37
35
),
38
36
'calculatorFactory ' => $ this ->getMock (
39
37
\Magento \Framework \Math \CalculatorFactory::class,
40
- [],
41
- [],
42
- '' ,
43
- false
44
- ),
38
+ [],
39
+ [],
40
+ '' ,
41
+ false
42
+ ),
45
43
'invoiceItemCollectionFactory ' => $ this ->getMock (
46
44
\Magento \Sales \Model \ResourceModel \Order \Invoice \Item \CollectionFactory::class,
47
45
[],
@@ -78,31 +76,32 @@ protected function _getInvoiceCollection(array $invoicesData)
78
76
* @dataProvider collectDataProvider
79
77
* @param array $prevInvoicesData
80
78
* @param float $orderShipping
81
- * @param float $invoiceShipping
82
79
* @param float $expectedShipping
83
80
*/
84
- public function testCollect (array $ prevInvoicesData , $ orderShipping , $ invoiceShipping , $ expectedShipping )
81
+ public function testCollect (array $ prevInvoicesData , $ orderShipping , $ expectedShipping )
85
82
{
86
83
$ order = $ this ->getMockBuilder (\Magento \Sales \Model \Order::class)
87
84
->disableOriginalConstructor ()
88
85
->getMock ();
89
- $ order ->setData ('shipping_amount ' , $ orderShipping );
90
- $ order ->expects (
91
- $ this ->any ()
92
- )->method (
93
- 'getInvoiceCollection '
94
- )->will (
95
- $ this ->returnValue ($ this ->_getInvoiceCollection ($ prevInvoicesData ))
96
- );
97
- /** @var $invoice \Magento\Sales\Model\Order\Invoice|PHPUnit_Framework_MockObject_MockObject */
98
- $ invoice = $ this ->getMock (\Magento \Sales \Model \Order \Invoice::class, ['_init ' , '__wakeup ' ], [], '' , false );
99
- $ invoice ->setData ('shipping_amount ' , $ invoiceShipping );
100
- $ invoice ->setOrder ($ order );
86
+ $ order ->expects ($ this ->any ())
87
+ ->method ('getInvoiceCollection ' )
88
+ ->will ($ this ->returnValue ($ this ->_getInvoiceCollection ($ prevInvoicesData )));
89
+ $ order ->expects ($ this ->any ())
90
+ ->method ('getShippingAmount ' )
91
+ ->willReturn ($ orderShipping );
92
+ /** @var $invoice \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject */
93
+ $ invoice = $ this ->getMockBuilder (\Magento \Sales \Model \Order \Invoice::class)
94
+ ->disableOriginalConstructor ()
95
+ ->getMock ();
96
+ $ invoice ->expects ($ this ->any ())
97
+ ->method ('getOrder ' )
98
+ ->willReturn ($ order );
99
+ $ invoice ->expects ($ this ->any ())
100
+ ->method ('setShippingAmount ' )
101
+ ->withConsecutive ([0 ], [$ expectedShipping ]);
101
102
102
103
$ total = new \Magento \Sales \Model \Order \Invoice \Total \Shipping ();
103
104
$ total ->collect ($ invoice );
104
-
105
- $ this ->assertEquals ($ expectedShipping , $ invoice ->getShippingAmount ());
106
105
}
107
106
108
107
public static function collectDataProvider ()
@@ -111,19 +110,16 @@ public static function collectDataProvider()
111
110
'no previous invoices ' => [
112
111
'prevInvoicesData ' => [[]],
113
112
'orderShipping ' => 10.00 ,
114
- 'invoiceShipping ' => 5.00 ,
115
113
'expectedShipping ' => 10.00 ,
116
114
],
117
115
'zero shipping in previous invoices ' => [
118
116
'prevInvoicesData ' => [['shipping_amount ' => '0.0000 ' ]],
119
117
'orderShipping ' => 10.00 ,
120
- 'invoiceShipping ' => 5.00 ,
121
118
'expectedShipping ' => 10.00 ,
122
119
],
123
120
'non-zero shipping in previous invoices ' => [
124
121
'prevInvoicesData ' => [['shipping_amount ' => '10.000 ' ]],
125
122
'orderShipping ' => 10.00 ,
126
- 'invoiceShipping ' => 5.00 ,
127
123
'expectedShipping ' => 0 ,
128
124
]
129
125
];
0 commit comments