File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
app/code/Magento/Sales/Model
dev/tests/unit/testsuite/Magento/Sales/Model Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -801,6 +801,10 @@ public function canEdit()
801
801
return false ;
802
802
}
803
803
804
+ if ($ this ->hasInvoices ()) {
805
+ return false ;
806
+ }
807
+
804
808
if (!$ this ->getPayment ()->getMethodInstance ()->canEdit ()) {
805
809
return false ;
806
810
}
@@ -1820,6 +1824,18 @@ public function getInvoiceCollection()
1820
1824
return $ this ->_invoices ;
1821
1825
}
1822
1826
1827
+ /**
1828
+ * Set order invoices collection
1829
+ *
1830
+ * @param InvoiceCollection $invoices
1831
+ * @return $this
1832
+ */
1833
+ public function setInvoiceCollection (InvoiceCollection $ invoices )
1834
+ {
1835
+ $ this ->_invoices = $ invoices ;
1836
+ return $ this ;
1837
+ }
1838
+
1823
1839
/**
1824
1840
* Retrieve order shipments collection
1825
1841
*
Original file line number Diff line number Diff line change @@ -191,6 +191,23 @@ public function testCanCancelIsPaymentReview()
191
191
$ this ->assertFalse ($ this ->order ->canCancel ());
192
192
}
193
193
194
+ public function testCanEditIfHasInvoices ()
195
+ {
196
+ $ invoiceCollection = $ this ->getMockBuilder ('Magento\Sales\Model\Resource\Order\Invoice\Collection ' )
197
+ ->disableOriginalConstructor ()
198
+ ->setMethods (['count ' ])
199
+ ->getMock ();
200
+
201
+ $ invoiceCollection ->expects ($ this ->once ())
202
+ ->method ('count ' )
203
+ ->willReturn (2 );
204
+
205
+ $ this ->order ->setInvoiceCollection ($ invoiceCollection );
206
+ $ this ->order ->setState (\Magento \Sales \Model \Order::STATE_PROCESSING );
207
+
208
+ $ this ->assertFalse ($ this ->order ->canEdit ());
209
+ }
210
+
194
211
public function testCanCancelCanReviewPayment ()
195
212
{
196
213
$ paymentMock = $ this ->getMockBuilder ('Magento\Sales\Model\Resource\Order\Payment ' )
You can’t perform that action at this time.
0 commit comments