Skip to content

Commit e05ca4e

Browse files
committed
Merge branch 'MC-32170' into 2.3-develop-com-pr25
2 parents 7bc09eb + bc202af commit e05ca4e

File tree

5 files changed

+511
-0
lines changed

5 files changed

+511
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Checkout\Model\Type\Onepage;
10+
use Magento\Customer\Api\CustomerRepositoryInterface;
11+
use Magento\Quote\Api\CartRepositoryInterface;
12+
use Magento\Quote\Api\Data\CartInterface;
13+
use Magento\Quote\Api\Data\CartInterfaceFactory;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
16+
require __DIR__ . '/../../Customer/_files/customer.php';
17+
require __DIR__ . '/../../../Magento/Catalog/_files/taxable_simple_product.php';
18+
19+
$objectManager = Bootstrap::getObjectManager();
20+
/** @var ProductRepositoryInterface $productRepository */
21+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
22+
$productRepository->cleanCache();
23+
/** @var CartRepositoryInterface $quoteRepository */
24+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
25+
/** @var CustomerRepositoryInterface $customerRepository */
26+
$customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
27+
$customer = $customerRepository->get('customer@example.com');
28+
29+
/** @var CartInterface $quote */
30+
$quote = $objectManager->get(CartInterfaceFactory::class)->create();
31+
$quote->setStoreId(1)
32+
->setIsActive(false)
33+
->setIsMultiShipping(0)
34+
->setCustomer($customer)
35+
->setCheckoutMethod(Onepage::METHOD_CUSTOMER)
36+
->setReservedOrderId('test_order_with_customer_inactive_quote')
37+
->addProduct($productRepository->get('taxable_product'), 1);
38+
$quoteRepository->save($quote);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Quote\Api\CartRepositoryInterface;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
11+
12+
$objectManager = Bootstrap::getObjectManager();
13+
/** @var CartRepositoryInterface $quoteRepository */
14+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
15+
/** @var GetQuoteByReservedOrderId $getQuoteByReservedOrderId */
16+
$getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class);
17+
$quote = $getQuoteByReservedOrderId->execute('test_order_with_customer_inactive_quote');
18+
if ($quote !== null) {
19+
$quoteRepository->delete($quote);
20+
}
21+
22+
require __DIR__ . '/../../../Magento/Catalog/_files/taxable_simple_product_rollback.php';
23+
require __DIR__ . '/../../Customer/_files/customer_rollback.php';
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Block\Adminhtml\Order\Create\Items;
9+
10+
use Magento\Backend\Model\Session\Quote;
11+
use Magento\Framework\ObjectManagerInterface;
12+
use Magento\Framework\View\LayoutInterface;
13+
use Magento\Sales\Block\Adminhtml\Order\Create\Items;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* Checks order items grid
20+
*
21+
* @magentoAppArea adminhtml
22+
* @magentoDbIsolation enabled
23+
*/
24+
class GridTest extends TestCase
25+
{
26+
/** @var ObjectManagerInterface */
27+
private $objectManager;
28+
29+
/** @var LayoutInterface */
30+
private $layout;
31+
32+
/** @var Grid */
33+
private $block;
34+
35+
/** @var Quote */
36+
private $session;
37+
38+
/** @var GetQuoteByReservedOrderId */
39+
private $getQuoteByReservedOrderId;
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
protected function setUp()
45+
{
46+
parent::setUp();
47+
48+
$this->objectManager = Bootstrap::getObjectManager();
49+
$this->getQuoteByReservedOrderId = $this->objectManager->get(GetQuoteByReservedOrderId::class);
50+
$this->session = $this->objectManager->get(Quote::class);
51+
$this->layout = $this->objectManager->get(LayoutInterface::class);
52+
$this->block = $this->layout->createBlock(Grid::class);
53+
$this->layout->createBlock(Items::class)->setChild('items_grid', $this->block);
54+
}
55+
56+
/**
57+
* @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php
58+
*
59+
* @return void
60+
*/
61+
public function testGetItems(): void
62+
{
63+
$quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address');
64+
$this->session->setQuoteId($quote->getId());
65+
$items = $this->block->getItems();
66+
$this->assertCount(1, $items);
67+
$this->assertEquals('simple2', reset($items)->getSku());
68+
}
69+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
9+
10+
use Magento\Backend\Model\Session\Quote;
11+
use Magento\Framework\ObjectManagerInterface;
12+
use Magento\Framework\View\LayoutInterface;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Check sidebar shopping cart section block
18+
*
19+
* @see \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Cart
20+
*
21+
* @magentoAppArea adminhtml
22+
* @magentoDbIsolation enabled
23+
*/
24+
class CartTest extends TestCase
25+
{
26+
/** @var ObjectManagerInterface */
27+
private $objectManager;
28+
29+
/** @var Cart */
30+
private $block;
31+
32+
/** @var Quote */
33+
private $session;
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
protected function setUp()
39+
{
40+
parent::setUp();
41+
42+
$this->objectManager = Bootstrap::getObjectManager();
43+
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Cart::class);
44+
$this->session = $this->objectManager->get(Quote::class);
45+
}
46+
47+
/**
48+
* @inheritdoc
49+
*/
50+
protected function tearDown()
51+
{
52+
$this->session->clearStorage();
53+
54+
parent::tearDown();
55+
}
56+
57+
/**
58+
* @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php
59+
*
60+
* @return void
61+
*/
62+
public function testGetItemCollection(): void
63+
{
64+
$this->session->setCustomerId(1);
65+
$items = $this->block->getItemCollection();
66+
$this->assertCount(1, $items);
67+
$this->assertEquals('simple2', reset($items)->getSku());
68+
}
69+
70+
/**
71+
* @return void
72+
*/
73+
public function testClearShoppingCartButton(): void
74+
{
75+
$confirmation = __('Are you sure you want to delete all items from shopping cart?');
76+
$button = $this->block->getChildBlock('empty_customer_cart_button');
77+
$this->assertEquals(sprintf("order.clearShoppingCart('%s')", $confirmation), $button->getOnclick());
78+
$this->assertEquals(__('Clear Shopping Cart'), $button->getLabel());
79+
}
80+
}

0 commit comments

Comments
 (0)