@@ -86,12 +86,15 @@ public function testGetOrderItems(): void
86
86
*
87
87
* @return void
88
88
*/
89
- public function testGetOrderItemsConfigurable (): void
89
+ public function testGetPagerCountConfigurable (): void
90
90
{
91
91
$ order = $ this ->orderFactory ->create ()->loadByIncrementId ('100000001 ' );
92
92
$ this ->registerOrder ($ order );
93
- $ this ->block = $ this ->layout ->createBlock (Items::class);
94
- $ this ->assertCount (1 , $ this ->block ->getItems ());
93
+ $ this ->prepareBlockWithPager ();
94
+
95
+ /** @var Pager $pagerBlock */
96
+ $ pagerBlock = $ this ->block ->getChildBlock ('sales_order_item_pager ' );
97
+ $ this ->assertCount (1 , $ pagerBlock ->getCollection ()->getItems ());
95
98
}
96
99
97
100
/**
@@ -104,13 +107,7 @@ public function testPagerIsDisplayed(): void
104
107
{
105
108
$ order = $ this ->orderFactory ->create ()->loadByIncrementId ('100000001 ' );
106
109
$ this ->registerOrder ($ order );
107
- $ this ->block = $ this ->layout ->createBlock (Items::class, 'items_block ' );
108
- $ this ->layout ->addBlock (
109
- $ this ->objectManager ->get (Pager::class),
110
- 'sales_order_item_pager ' ,
111
- 'items_block '
112
- );
113
- $ this ->block ->setLayout ($ this ->layout );
110
+ $ this ->prepareBlockWithPager ();
114
111
$ this ->assertTrue ($ this ->block ->isPagerDisplayed ());
115
112
}
116
113
@@ -123,13 +120,7 @@ public function testPagerIsNotDisplayed(): void
123
120
{
124
121
$ order = $ this ->orderFactory ->create ()->loadByIncrementId ('100000001 ' );
125
122
$ this ->registerOrder ($ order );
126
- $ this ->block = $ this ->layout ->createBlock (Items::class, 'items_block ' );
127
- $ this ->layout ->addBlock (
128
- $ this ->objectManager ->get (Pager::class),
129
- 'sales_order_item_pager ' ,
130
- 'items_block '
131
- );
132
- $ this ->block ->setLayout ($ this ->layout );
123
+ $ this ->prepareBlockWithPager ();
133
124
$ this ->assertFalse ($ this ->block ->isPagerDisplayed ());
134
125
$ this ->assertEmpty (preg_replace ('/\s+/ ' , '' , strip_tags ($ this ->block ->getPagerHtml ())));
135
126
}
@@ -144,13 +135,7 @@ public function testGetPagerHtml(): void
144
135
{
145
136
$ order = $ this ->orderFactory ->create ()->loadByIncrementId ('100000001 ' );
146
137
$ this ->registerOrder ($ order );
147
- $ this ->block = $ this ->layout ->createBlock (Items::class, 'items_block ' );
148
- $ this ->layout ->addBlock (
149
- $ this ->objectManager ->get (Pager::class),
150
- 'sales_order_item_pager ' ,
151
- 'items_block '
152
- );
153
- $ this ->block ->setLayout ($ this ->layout );
138
+ $ this ->prepareBlockWithPager ();
154
139
$ this ->assertNotEmpty (preg_replace ('/\s+/ ' , '' , strip_tags ($ this ->block ->getPagerHtml ())));
155
140
$ this ->assertTrue ($ this ->block ->isPagerDisplayed ());
156
141
}
@@ -240,4 +225,18 @@ private function registerOrder(OrderInterface $order): void
240
225
$ this ->registry ->unregister ('current_order ' );
241
226
$ this ->registry ->register ('current_order ' , $ order );
242
227
}
228
+
229
+ /**
230
+ * Create items block with pager
231
+ */
232
+ private function prepareBlockWithPager (): void
233
+ {
234
+ $ this ->block = $ this ->layout ->createBlock (Items::class, 'items_block ' );
235
+ $ this ->layout ->addBlock (
236
+ $ this ->objectManager ->get (Pager::class),
237
+ 'sales_order_item_pager ' ,
238
+ 'items_block '
239
+ );
240
+ $ this ->block ->setLayout ($ this ->layout );
241
+ }
243
242
}
0 commit comments