7
7
8
8
namespace Magento \GraphQl \Quote \Guest ;
9
9
10
+ use Magento \Quote \Api \GuestCartRepositoryInterface ;
10
11
use Magento \Quote \Model \QuoteIdMaskFactory ;
11
12
use Magento \Quote \Model \ResourceModel \Quote \CollectionFactory as QuoteCollectionFactory ;
12
13
use Magento \Quote \Model \ResourceModel \Quote as QuoteResource ;
14
+ use Magento \Store \Test \Fixture \Store ;
15
+ use Magento \TestFramework \Fixture \DataFixture ;
16
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
13
17
use Magento \TestFramework \Helper \Bootstrap ;
14
18
use Magento \TestFramework \TestCase \GraphQlAbstract ;
15
- use Magento \Quote \Api \GuestCartRepositoryInterface ;
16
19
17
20
/**
18
21
* Test for guest cart creation mutation
@@ -68,13 +71,16 @@ public function testSuccessfulCreateGuestCart()
68
71
self ::assertEquals ('1 ' , $ guestCart ->getCustomerIsGuest ());
69
72
}
70
73
71
- /**
72
- * @magentoApiDataFixture Magento/ Store/_files/second_store.php
73
- */
74
+ #[
75
+ DataFixture( Store::class, as: ' store ' )
76
+ ]
74
77
public function testSuccessfulWithNotDefaultStore ()
75
78
{
79
+ $ store = DataFixtureStorageManager::getStorage ()->get ('store ' );
80
+ $ storeCode = $ store ->getCode ();
81
+
76
82
$ query = $ this ->getQuery ();
77
- $ headerMap = ['Store ' => ' fixture_second_store ' ];
83
+ $ headerMap = ['Store ' => $ storeCode ];
78
84
$ response = $ this ->graphQlMutation ($ query , [], '' , $ headerMap );
79
85
80
86
self ::assertArrayHasKey ('createGuestCart ' , $ response );
@@ -88,13 +94,10 @@ public function testSuccessfulWithNotDefaultStore()
88
94
89
95
self ::assertNotNull ($ guestCart ->getId ());
90
96
self ::assertNull ($ guestCart ->getCustomer ()->getId ());
91
- self ::assertSame (' fixture_second_store ' , $ guestCart ->getStore ()->getCode ());
97
+ self ::assertSame ($ storeCode , $ guestCart ->getStore ()->getCode ());
92
98
self ::assertEquals ('1 ' , $ guestCart ->getCustomerIsGuest ());
93
99
}
94
100
95
- /**
96
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
97
- */
98
101
public function testSuccessfulWithPredefinedCartId ()
99
102
{
100
103
$ predefinedCartId = '572cda51902b5b517c0e1a2b2fd004b4 ' ;
@@ -108,16 +111,9 @@ public function testSuccessfulWithPredefinedCartId()
108
111
self ::assertNotEmpty ($ response ['createGuestCart ' ]['cart ' ]);
109
112
self ::assertArrayHasKey ('id ' , $ response ['createGuestCart ' ]['cart ' ]);
110
113
self ::assertNotEmpty ($ response ['createGuestCart ' ]['cart ' ]['id ' ]);
111
-
112
- $ guestCart = $ this ->guestCartRepository ->get ($ response ['createGuestCart ' ]['cart ' ]['id ' ]);
113
- self ::assertNotNull ($ guestCart ->getId ());
114
- self ::assertNull ($ guestCart ->getCustomer ()->getId ());
114
+ self ::assertEquals ($ predefinedCartId , $ response ['createGuestCart ' ]['cart ' ]['id ' ]);
115
115
}
116
116
117
- /**
118
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
119
- *
120
- */
121
117
public function testFailIfPredefinedCartIdAlreadyExists ()
122
118
{
123
119
$ this ->expectException (\Exception::class);
@@ -130,10 +126,6 @@ public function testFailIfPredefinedCartIdAlreadyExists()
130
126
$ this ->graphQlMutation ($ query );
131
127
}
132
128
133
- /**
134
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
135
- *
136
- */
137
129
public function testFailWithWrongPredefinedCartId ()
138
130
{
139
131
$ this ->expectException (\Exception::class);
0 commit comments