11
11
use Magento \TestFramework \TestCase \WebapiAbstract ;
12
12
use Magento \Framework \Webapi \Exception as HTTPExceptionCodes ;
13
13
use Magento \Catalog \Model \ProductRepositoryFactory ;
14
+ use Magento \TestFramework \Fixture \DataFixture ;
15
+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
16
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
17
+ use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
14
18
15
19
/**
16
20
* Base price storage test to test the update and update with invalid parameter.
@@ -31,13 +35,19 @@ class BasePriceStorageTest extends WebapiAbstract
31
35
*/
32
36
private $ repositoryFactory ;
33
37
38
+ /**
39
+ * @var DataFixtureStorage
40
+ */
41
+ private $ fixtures ;
42
+
34
43
/**
35
44
* Set up.
36
45
*/
37
46
protected function setUp (): void
38
47
{
39
48
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
40
49
$ this ->repositoryFactory = Bootstrap::getObjectManager ()->get (ProductRepositoryFactory::class);
50
+ $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
41
51
}
42
52
43
53
/**
@@ -170,16 +180,20 @@ public function testUpdateWithInvalidParameters()
170
180
/**
171
181
* Test update last updated at method.
172
182
*
173
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
174
183
*/
184
+ #[
185
+ DataFixture(ProductFixture::class, as: 'product ' ),
186
+ ]
175
187
public function testUpdateLastUpdatedAt ()
176
188
{
189
+ $ product = $ this ->fixtures ->get ('product ' );
190
+ $ productSku = $ product ->getSku ();
177
191
/** @var ProductRepository $beforeProductRepository */
178
192
$ beforeProductRepository = $ this ->repositoryFactory ->create ();
179
- $ beforeProductUpdatedAt = $ beforeProductRepository ->get (self :: SIMPLE_PRODUCT_SKU )->getUpdatedAt ();
193
+ $ beforeProductUpdatedAt = $ beforeProductRepository ->get ($ productSku )->getUpdatedAt ();
180
194
$ serviceInfo = [
181
195
'rest ' => [
182
- 'resourcePath ' => '/V1/products/base-prices?XDEBUG_SESSION_START=PHPSTORM ' ,
196
+ 'resourcePath ' => '/V1/products/base-prices ' ,
183
197
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_POST
184
198
],
185
199
'soap ' => [
@@ -197,7 +211,7 @@ public function testUpdateLastUpdatedAt()
197
211
[
198
212
'price ' => $ newPrice ,
199
213
'store_id ' => $ storeId ,
200
- 'sku ' => self :: SIMPLE_PRODUCT_SKU ,
214
+ 'sku ' => $ productSku ,
201
215
]
202
216
]
203
217
]
@@ -206,7 +220,7 @@ public function testUpdateLastUpdatedAt()
206
220
207
221
/** @var ProductRepository $afterProductRepository */
208
222
$ afterProductRepository = $ this ->repositoryFactory ->create ();
209
- $ afterProductUpdatedAt = $ afterProductRepository ->get (self :: SIMPLE_PRODUCT_SKU )->getUpdatedAt ();
223
+ $ afterProductUpdatedAt = $ afterProductRepository ->get ($ productSku )->getUpdatedAt ();
210
224
$ this ->assertTrue (strtotime ($ afterProductUpdatedAt ) >= strtotime ($ beforeProductUpdatedAt ));
211
225
}
212
226
}
0 commit comments