5
5
*/
6
6
namespace Magento \Customer \Block \Adminhtml \Edit \Tab ;
7
7
8
+ use Magento \Backend \Block \Template \Context ;
9
+ use Magento \Backend \Model \Session \Quote as SessionQuote ;
8
10
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 ;
9
15
10
16
/**
11
17
* Magento\Customer\Block\Adminhtml\Edit\Tab\Cart
@@ -16,21 +22,34 @@ class CartTest extends \PHPUnit\Framework\TestCase
16
22
{
17
23
const CUSTOMER_ID_VALUE = 1234 ;
18
24
19
- /** @var \Magento\Backend\Block\Template\Context */
25
+ /**
26
+ * @var Context
27
+ */
20
28
private $ _context ;
21
29
22
- /** @var \Magento\Framework\Registry */
30
+ /**
31
+ * @var Registry
32
+ */
23
33
private $ _coreRegistry ;
24
34
25
- /** @var \Magento\Store\Model\StoreManagerInterface */
35
+ /**
36
+ * @var StoreManagerInterface
37
+ */
26
38
private $ _storeManager ;
27
39
28
- /** @var Cart */
40
+ /**
41
+ * @var Cart
42
+ */
29
43
private $ _block ;
30
44
31
- /** @var \Magento\Framework\ObjectManagerInterface */
45
+ /**
46
+ * @var ObjectManagerInterface
47
+ */
32
48
private $ _objectManager ;
33
49
50
+ /**
51
+ * @inheritdoc
52
+ */
34
53
public function setUp ()
35
54
{
36
55
$ this ->_objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
@@ -53,22 +72,65 @@ public function setUp()
53
72
);
54
73
}
55
74
75
+ /**
76
+ * @inheritdoc
77
+ */
56
78
public function tearDown ()
57
79
{
58
80
$ this ->_coreRegistry ->unregister (RegistryConstants::CURRENT_CUSTOMER_ID );
59
81
}
60
82
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
62
114
{
63
115
$ this ->assertEquals (self ::CUSTOMER_ID_VALUE , $ this ->_block ->getCustomerId ());
64
116
}
65
117
66
- public function testGetGridUrl ()
118
+ /**
119
+ * Verify get grid url
120
+ *
121
+ * @return void
122
+ */
123
+ public function testGetGridUrl (): void
67
124
{
68
125
$ this ->assertContains ('/backend/customer/index/cart ' , $ this ->_block ->getGridUrl ());
69
126
}
70
127
71
- public function testGetGridParentHtml ()
128
+ /**
129
+ * Verify grid parent html
130
+ *
131
+ * @return void
132
+ */
133
+ public function testGetGridParentHtml (): void
72
134
{
73
135
$ this ->_block = $ this ->_objectManager ->get (
74
136
\Magento \Framework \View \LayoutInterface::class
@@ -87,14 +149,24 @@ public function testGetGridParentHtml()
87
149
);
88
150
}
89
151
90
- public function testGetRowUrl ()
152
+ /**
153
+ * Verify row url
154
+ *
155
+ * @return void
156
+ */
157
+ public function testGetRowUrl (): void
91
158
{
92
159
$ row = new \Magento \Framework \DataObject ();
93
160
$ row ->setProductId (1 );
94
161
$ this ->assertContains ('/backend/catalog/product/edit/id/1 ' , $ this ->_block ->getRowUrl ($ row ));
95
162
}
96
163
97
- public function testGetHtml ()
164
+ /**
165
+ * Verify get html
166
+ *
167
+ * @return void
168
+ */
169
+ public function testGetHtml (): void
98
170
{
99
171
$ html = $ this ->_block ->toHtml ();
100
172
$ this ->assertContains ("<div id= \"customer_cart_grid \"" , $ html );
0 commit comments