Skip to content

Commit fbd3fe1

Browse files
committed
MC-31583: Admin: invoice order for customer
1 parent 8df817e commit fbd3fe1

File tree

7 files changed

+26
-27
lines changed

7 files changed

+26
-27
lines changed

dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/ItemsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Framework\ObjectManagerInterface;
1111
use Magento\Framework\Registry;
1212
use Magento\Framework\View\LayoutInterface;
13-
use Magento\Sales\Model\OrderFactory;
13+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
1414
use Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory;
1515
use Magento\TestFramework\Helper\Bootstrap;
1616
use PHPUnit\Framework\TestCase;
@@ -31,7 +31,7 @@ class ItemsTest extends TestCase
3131
/** @var Items */
3232
private $block;
3333

34-
/** @var OrderFactory */
34+
/** @var OrderInterfaceFactory */
3535
private $orderFactory;
3636

3737
/** @var Registry */
@@ -49,7 +49,7 @@ protected function setUp()
4949

5050
$this->objectManager = Bootstrap::getObjectManager();
5151
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Items::class);
52-
$this->orderFactory = $this->objectManager->get(OrderFactory::class);
52+
$this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class);
5353
$this->registry = $this->objectManager->get(Registry::class);
5454
$this->invoiceCollectionFactory = $this->objectManager->get(CollectionFactory::class);
5555
}

dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/ViewTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
use Magento\Framework\ObjectManagerInterface;
1313
use Magento\Framework\Registry;
1414
use Magento\Framework\View\LayoutInterface;
15-
use Magento\Sales\Api\Data\OrderInterface;
16-
use Magento\Sales\Model\OrderFactory;
15+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
1716
use Magento\TestFramework\Helper\Bootstrap;
1817
use Magento\TestFramework\Helper\Xpath;
1918
use PHPUnit\Framework\TestCase;
@@ -37,7 +36,7 @@ class ViewTest extends TestCase
3736
/** @var Registry */
3837
private $registry;
3938

40-
/** @var OrderFactory */
39+
/** @var OrderInterfaceFactory */
4140
private $orderFactory;
4241

4342
/**
@@ -53,7 +52,7 @@ protected function setUp()
5352
Authorization::class
5453
);
5554
$this->registry = $this->objectManager->get(Registry::class);
56-
$this->orderFactory = $this->objectManager->get(OrderFactory::class);
55+
$this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class);
5756
$this->layout = $this->objectManager->get(LayoutInterface::class);
5857
}
5958

@@ -103,7 +102,7 @@ public function testInvoiceButtonIsNotVisible(): void
103102
/**
104103
* Register order
105104
*
106-
* @param OrderInterface $order
105+
* @param string $orderIncrementId
107106
* @return void
108107
*/
109108
private function registerOrder(string $orderIncrementId): void

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AbstractInvoiceControllerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Framework\App\Request\Http;
1212
use Magento\Sales\Api\Data\InvoiceInterface;
1313
use Magento\Sales\Api\Data\OrderInterface;
14-
use Magento\Sales\Model\OrderRepository;
14+
use Magento\Sales\Api\OrderRepositoryInterface;
1515
use Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory;
1616
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
1717
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -27,7 +27,7 @@ abstract class AbstractInvoiceControllerTest extends AbstractBackendController
2727
/** @var string */
2828
protected $resource = 'Magento_Sales::sales_invoice';
2929

30-
/** @var OrderRepository */
30+
/** @var OrderRepositoryInterface */
3131
private $orderRepository;
3232

3333
/** @var SearchCriteriaBuilder */
@@ -44,7 +44,7 @@ protected function setUp()
4444
parent::setUp();
4545

4646
$this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class);
47-
$this->orderRepository = $this->_objectManager->get(OrderRepository::class);
47+
$this->orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
4848
$this->searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
4949
$this->invoiceCollectionFactory = $this->_objectManager->get(CollectionFactory::class);
5050
}
@@ -65,12 +65,12 @@ protected function getOrder(string $incrementalId): ?OrderInterface
6565
}
6666

6767
/**
68-
* Get firs order invoice
68+
* Get first order invoice
6969
*
70-
* @param OrderInterface|int $order
70+
* @param OrderInterface $order
7171
* @return InvoiceInterface
7272
*/
73-
protected function getInvoiceByOrder($order): InvoiceInterface
73+
protected function getInvoiceByOrder(OrderInterface $order): InvoiceInterface
7474
{
7575
$invoiceCollection = $this->invoiceCollectionFactory->create();
7676

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testSendEmailOnAddInvoiceComment(): void
3636
['comment' => ['comment' => $comment, 'is_customer_notified' => true]],
3737
['id' => $invoice->getEntityId()]
3838
);
39-
$this->dispatch('backend/sales/order_invoice/addComment');
39+
$this->dispatch($this->uri);
4040

4141
$html = $this->getResponse()->getBody();
4242
$this->assertContains($comment, $html);

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Framework\App\Request\Http;
1111
use Magento\Framework\Escaper;
1212
use Magento\Framework\Message\MessageInterface;
13-
use Magento\Sales\Model\OrderFactory;
13+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
1414
use Magento\TestFramework\TestCase\AbstractBackendController;
1515

1616
/**
@@ -23,7 +23,7 @@
2323
*/
2424
class NewActionTest extends AbstractBackendController
2525
{
26-
/** @var OrderFactory */
26+
/** @var OrderInterfaceFactory */
2727
private $orderFactory;
2828

2929
/** @var Escaper */
@@ -36,7 +36,7 @@ protected function setUp()
3636
{
3737
parent::setUp();
3838

39-
$this->orderFactory = $this->_objectManager->get(OrderFactory::class);
39+
$this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class);
4040
$this->escaper = $this->_objectManager->get(Escaper::class);
4141
}
4242

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testSendEmailOnInvoiceSave(): void
4949
$itemId = $order->getItemsCollection()->getFirstItem()->getId();
5050
$post = $this->hydratePost([$itemId => 2]);
5151
$this->prepareRequest($post, ['order_id' => $order->getEntityId()]);
52-
$this->dispatch('backend/sales/order_invoice/save');
52+
$this->dispatch($this->uri);
5353
$invoice = $this->getInvoiceByOrder($order);
5454
$this->checkSuccess($invoice, 2);
5555
$message = $this->transportBuilder->getSentMessage();
@@ -81,7 +81,7 @@ public function testSendEmailOnInvoiceSaveWithDisabledConfig(): void
8181
$order = $this->getOrder('100000001');
8282
$post = $this->hydratePost([$order->getItemsCollection()->getFirstItem()->getId() => 2]);
8383
$this->prepareRequest($post, ['order_id' => $order->getEntityId()]);
84-
$this->dispatch('backend/sales/order_invoice/save');
84+
$this->dispatch($this->uri);
8585
$this->checkSuccess($this->getInvoiceByOrder($order), 2);
8686
$this->assertNull($this->transportBuilder->getSentMessage());
8787
}
@@ -108,7 +108,7 @@ public function testSuccessfulInvoice(
108108
$doShipment
109109
);
110110
$this->prepareRequest($post, ['order_id' => $order->getEntityId()]);
111-
$this->dispatch('backend/sales/order_invoice/save');
111+
$this->dispatch($this->uri);
112112
$this->checkSuccess($this->getInvoiceByOrder($order), $invoicedItemsQty, $commentMessage, $doShipment);
113113
}
114114

@@ -140,7 +140,7 @@ public function testWitNoExistingOrder(): void
140140
{
141141
$expectedMessage = (string)__('The order no longer exists.');
142142
$this->prepareRequest(['order_id' => 899989]);
143-
$this->dispatch('backend/sales/order_invoice/save');
143+
$this->dispatch($this->uri);
144144
$this->assertErrorResponse($expectedMessage);
145145
}
146146

@@ -154,7 +154,7 @@ public function testCanNotInvoiceOrder(): void
154154
$expectedMessage = (string)__('The order does not allow an invoice to be created.');
155155
$order = $this->getOrder('100000001');
156156
$this->prepareRequest([], ['order_id' => $order->getEntityId()]);
157-
$this->dispatch('backend/sales/order_invoice/save');
157+
$this->dispatch($this->uri);
158158
$this->assertErrorResponse($expectedMessage);
159159
}
160160

@@ -169,7 +169,7 @@ public function testInvoiceWithoutQty(): void
169169
$order = $this->getOrder('100000001');
170170
$post = $this->hydratePost([$order->getItemsCollection()->getFirstItem()->getId() => '0']);
171171
$this->prepareRequest($post, ['order_id' => $order->getEntityId()]);
172-
$this->dispatch('backend/sales/order_invoice/save');
172+
$this->dispatch($this->uri);
173173
$this->assertErrorResponse($this->escaper->escapeHtml($expectedMessage));
174174
}
175175

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/StartTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Magento\Backend\Model\Session;
1111
use Magento\Framework\App\Request\Http;
12-
use Magento\Sales\Model\OrderFactory;
12+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
1313
use Magento\TestFramework\TestCase\AbstractBackendController;
1414

1515
/**
@@ -22,7 +22,7 @@
2222
*/
2323
class StartTest extends AbstractBackendController
2424
{
25-
/** @var OrderFactory */
25+
/** @var OrderInterfaceFactory */
2626
private $orderFactory;
2727

2828
/** @var Session */
@@ -35,7 +35,7 @@ protected function setUp()
3535
{
3636
parent::setUp();
3737

38-
$this->orderFactory = $this->_objectManager->get(OrderFactory::class);
38+
$this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class);
3939
$this->session = $this->_objectManager->get(Session::class);
4040
}
4141

0 commit comments

Comments
 (0)