Skip to content

Commit 0173e34

Browse files
committed
Cover changes with integration test
1 parent 1dd3d90 commit 0173e34

File tree

1 file changed

+82
-10
lines changed
  • dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab

1 file changed

+82
-10
lines changed

dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
*/
66
namespace Magento\Customer\Block\Adminhtml\Edit\Tab;
77

8+
use Magento\Backend\Block\Template\Context;
9+
use Magento\Backend\Model\Session\Quote as SessionQuote;
810
use Magento\Customer\Controller\RegistryConstants;
11+
use Magento\Framework\ObjectManagerInterface;
12+
use Magento\Framework\Registry;
13+
use Magento\Quote\Model\Quote;
14+
use Magento\Store\Model\StoreManagerInterface;
915

1016
/**
1117
* Magento\Customer\Block\Adminhtml\Edit\Tab\Cart
@@ -16,21 +22,34 @@ class CartTest extends \PHPUnit\Framework\TestCase
1622
{
1723
const CUSTOMER_ID_VALUE = 1234;
1824

19-
/** @var \Magento\Backend\Block\Template\Context */
25+
/**
26+
* @var Context
27+
*/
2028
private $_context;
2129

22-
/** @var \Magento\Framework\Registry */
30+
/**
31+
* @var Registry
32+
*/
2333
private $_coreRegistry;
2434

25-
/** @var \Magento\Store\Model\StoreManagerInterface */
35+
/**
36+
* @var StoreManagerInterface
37+
*/
2638
private $_storeManager;
2739

28-
/** @var Cart */
40+
/**
41+
* @var Cart
42+
*/
2943
private $_block;
3044

31-
/** @var \Magento\Framework\ObjectManagerInterface */
45+
/**
46+
* @var ObjectManagerInterface
47+
*/
3248
private $_objectManager;
3349

50+
/**
51+
* @inheritdoc
52+
*/
3453
public function setUp()
3554
{
3655
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -53,22 +72,65 @@ public function setUp()
5372
);
5473
}
5574

75+
/**
76+
* @inheritdoc
77+
*/
5678
public function tearDown()
5779
{
5880
$this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
5981
}
6082

61-
public function testGetCustomerId()
83+
/**
84+
* Verify Grid with quote items
85+
*
86+
* @magentoDataFixture Magento/Sales/_files/quote_with_two_products_and_customer.php
87+
* @magentoDataFixture Magento/Customer/_files/customer.php
88+
* @magentoAppIsolation enabled
89+
* @magentoDbIsolation disabled
90+
* @return void
91+
*/
92+
public function testVerifyCollectionWithQuote(): void
93+
{
94+
$session = $this->_objectManager->create(SessionQuote::class);
95+
$session->setCustomerId(self::CUSTOMER_ID_VALUE);
96+
$quoteFixture = $this->_objectManager->create(Quote::class);
97+
$quoteFixture->load('test01', 'reserved_order_id');
98+
$quoteFixture->setCustomerIsGuest(false)
99+
->setCustomerId(self::CUSTOMER_ID_VALUE)
100+
->save();
101+
$html = $this->_block->toHtml();
102+
$this->assertNotContains(
103+
"We couldn't find any records",
104+
$this->_block->getGridParentHtml()
105+
);
106+
}
107+
108+
/**
109+
* Verify Customer id
110+
*
111+
* @return void
112+
*/
113+
public function testGetCustomerId(): void
62114
{
63115
$this->assertEquals(self::CUSTOMER_ID_VALUE, $this->_block->getCustomerId());
64116
}
65117

66-
public function testGetGridUrl()
118+
/**
119+
* Verify get grid url
120+
*
121+
* @return void
122+
*/
123+
public function testGetGridUrl(): void
67124
{
68125
$this->assertContains('/backend/customer/index/cart', $this->_block->getGridUrl());
69126
}
70127

71-
public function testGetGridParentHtml()
128+
/**
129+
* Verify grid parent html
130+
*
131+
* @return void
132+
*/
133+
public function testGetGridParentHtml(): void
72134
{
73135
$this->_block = $this->_objectManager->get(
74136
\Magento\Framework\View\LayoutInterface::class
@@ -87,14 +149,24 @@ public function testGetGridParentHtml()
87149
);
88150
}
89151

90-
public function testGetRowUrl()
152+
/**
153+
* Verify row url
154+
*
155+
* @return void
156+
*/
157+
public function testGetRowUrl(): void
91158
{
92159
$row = new \Magento\Framework\DataObject();
93160
$row->setProductId(1);
94161
$this->assertContains('/backend/catalog/product/edit/id/1', $this->_block->getRowUrl($row));
95162
}
96163

97-
public function testGetHtml()
164+
/**
165+
* Verify get html
166+
*
167+
* @return void
168+
*/
169+
public function testGetHtml(): void
98170
{
99171
$html = $this->_block->toHtml();
100172
$this->assertContains("<div id=\"customer_cart_grid\"", $html);

0 commit comments

Comments
 (0)