forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request magento#3868 from magento-arcticfoxes/2.3.1-qwerty-pr
[2.3.1-qwerty] sync with 2.3.1-release
- Loading branch information
Showing
6 changed files
with
159 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
dev/tests/integration/testsuite/Magento/Sales/Model/Service/InvoiceServiceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Sales\Model\Service; | ||
|
||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Magento\Sales\Model\Order; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** | ||
* Tests \Magento\Sales\Model\Service\InvoiceService | ||
*/ | ||
class InvoiceServiceTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var InvoiceService | ||
*/ | ||
private $invoiceService; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->invoiceService = Bootstrap::getObjectManager()->create(InvoiceService::class); | ||
} | ||
|
||
/** | ||
* @param int $invoiceQty | ||
* @magentoDataFixture Magento/Sales/_files/order_configurable_product.php | ||
* @return void | ||
* @dataProvider prepareInvoiceConfigurableProductDataProvider | ||
*/ | ||
public function testPrepareInvoiceConfigurableProduct(int $invoiceQty): void | ||
{ | ||
/** @var OrderInterface $order */ | ||
$order = Bootstrap::getObjectManager()->create(Order::class)->load('100000001', 'increment_id'); | ||
$orderItems = $order->getItems(); | ||
foreach ($orderItems as $orderItem) { | ||
if ($orderItem->getParentItemId()) { | ||
$parentItemId = $orderItem->getParentItemId(); | ||
} | ||
} | ||
$invoice = $this->invoiceService->prepareInvoice($order, [$parentItemId => $invoiceQty]); | ||
$invoiceItems = $invoice->getItems(); | ||
foreach ($invoiceItems as $invoiceItem) { | ||
$this->assertEquals($invoiceQty, $invoiceItem->getQty()); | ||
} | ||
} | ||
|
||
public function prepareInvoiceConfigurableProductDataProvider() | ||
{ | ||
return [ | ||
'full invoice' => [2], | ||
'partial invoice' => [1] | ||
]; | ||
} | ||
|
||
/** | ||
* @param int $invoiceQty | ||
* @magentoDataFixture Magento/Sales/_files/order.php | ||
* @return void | ||
* @dataProvider prepareInvoiceSimpleProductDataProvider | ||
*/ | ||
public function testPrepareInvoiceSimpleProduct(int $invoiceQty): void | ||
{ | ||
/** @var OrderInterface $order */ | ||
$order = Bootstrap::getObjectManager()->create(Order::class)->load('100000001', 'increment_id'); | ||
$orderItems = $order->getItems(); | ||
$invoiceQtys = []; | ||
foreach ($orderItems as $orderItem) { | ||
$invoiceQtys[$orderItem->getItemId()] = $invoiceQty; | ||
} | ||
$invoice = $this->invoiceService->prepareInvoice($order, $invoiceQtys); | ||
$invoiceItems = $invoice->getItems(); | ||
foreach ($invoiceItems as $invoiceItem) { | ||
$this->assertEquals($invoiceQty, $invoiceItem->getQty()); | ||
} | ||
} | ||
|
||
public function prepareInvoiceSimpleProductDataProvider() | ||
{ | ||
return [ | ||
'full invoice' => [2], | ||
'partial invoice' => [1] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters