7
7
8
8
namespace Magento \GraphQl \Quote \Customer ;
9
9
10
+ use Magento \Framework \Exception \NoSuchEntityException ;
11
+ use Magento \Framework \Registry ;
10
12
use Magento \GraphQl \Quote \GetMaskedQuoteIdByReservedOrderId ;
11
13
use Magento \Integration \Api \CustomerTokenServiceInterface ;
14
+ use Magento \Sales \Api \OrderRepositoryInterface ;
15
+ use Magento \Sales \Model \ResourceModel \Order \CollectionFactory ;
12
16
use Magento \TestFramework \Helper \Bootstrap ;
13
17
use Magento \TestFramework \TestCase \GraphQlAbstract ;
14
18
@@ -27,6 +31,21 @@ class PlaceOrderTest extends GraphQlAbstract
27
31
*/
28
32
private $ getMaskedQuoteIdByReservedOrderId ;
29
33
34
+ /**
35
+ * @var CollectionFactory
36
+ */
37
+ private $ orderCollectionFactory ;
38
+
39
+ /**
40
+ * @var OrderRepositoryInterface
41
+ */
42
+ private $ orderRepository ;
43
+
44
+ /**
45
+ * @var Registry
46
+ */
47
+ private $ registry ;
48
+
30
49
/**
31
50
* @inheritdoc
32
51
*/
@@ -35,6 +54,9 @@ protected function setUp()
35
54
$ objectManager = Bootstrap::getObjectManager ();
36
55
$ this ->getMaskedQuoteIdByReservedOrderId = $ objectManager ->get (GetMaskedQuoteIdByReservedOrderId::class);
37
56
$ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
57
+ $ this ->orderCollectionFactory = $ objectManager ->get (CollectionFactory::class);
58
+ $ this ->orderRepository = $ objectManager ->get (OrderRepositoryInterface::class);
59
+ $ this ->registry = Bootstrap::getObjectManager ()->get (Registry::class);
38
60
}
39
61
40
62
/**
@@ -253,4 +275,22 @@ private function getHeaderMap(string $username = '
[email protected] ', string
253
275
$ headerMap = ['Authorization ' => 'Bearer ' . $ customerToken ];
254
276
return $ headerMap ;
255
277
}
278
+
279
+ /**
280
+ * @inheritdoc
281
+ */
282
+ public function tearDown ()
283
+ {
284
+ $ this ->registry ->unregister ('isSecureArea ' );
285
+ $ this ->registry ->register ('isSecureArea ' , true );
286
+
287
+ $ orderCollection = $ this ->orderCollectionFactory ->create ();
288
+ foreach ($ orderCollection as $ order ) {
289
+ $ this ->orderRepository ->delete ($ order );
290
+ }
291
+ $ this ->registry ->unregister ('isSecureArea ' );
292
+ $ this ->registry ->register ('isSecureArea ' , false );
293
+
294
+ parent ::tearDown ();
295
+ }
256
296
}
0 commit comments