6
6
7
7
namespace Magento \Catalog \Api ;
8
8
9
+ use Magento \Catalog \Model \ProductRepository ;
10
+ use Magento \TestFramework \Helper \Bootstrap ;
9
11
use Magento \TestFramework \TestCase \WebapiAbstract ;
10
12
use Magento \Framework \Webapi \Exception as HTTPExceptionCodes ;
13
+ use Magento \Catalog \Model \ProductRepositoryFactory ;
11
14
12
15
/**
13
16
* BasePriceStorage test.
@@ -23,12 +26,18 @@ class BasePriceStorageTest extends WebapiAbstract
23
26
*/
24
27
private $ objectManager ;
25
28
29
+ /**
30
+ * @var ProductRepositoryFactory
31
+ */
32
+ private $ repositoryFactory ;
33
+
26
34
/**
27
35
* Set up.
28
36
*/
29
37
protected function setUp (): void
30
38
{
31
39
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
40
+ $ this ->repositoryFactory = Bootstrap::getObjectManager ()->get (ProductRepositoryFactory::class);
32
41
}
33
42
34
43
/**
@@ -165,11 +174,9 @@ public function testUpdateWithInvalidParameters()
165
174
*/
166
175
public function testUpdateLastUpdatedAt ()
167
176
{
168
- $ productRepository = $ this ->objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
169
- /** @var \Magento\Catalog\Api\Data\ProductInterface $product */
170
- $ product = $ productRepository ->get (self ::SIMPLE_PRODUCT_SKU );
171
- $ productUpdatedAt = $ product ->getUpdatedAt ();
172
- $ newUpdateAt = $ this ->objectManager ->create (\Magento \Framework \Stdlib \DateTime \DateTime::class)->gmtDate ();
177
+ /** @var ProductRepository $beforeProductRepository */
178
+ $ beforeProductRepository = $ this ->repositoryFactory ->create ();
179
+ $ beforeProductUpdatedAt = $ beforeProductRepository ->get (self ::SIMPLE_PRODUCT_SKU )->getUpdatedAt ();
173
180
$ serviceInfo = [
174
181
'rest ' => [
175
182
'resourcePath ' => '/V1/products/base-prices?XDEBUG_SESSION_START=PHPSTORM ' ,
@@ -195,8 +202,11 @@ public function testUpdateLastUpdatedAt()
195
202
]
196
203
]
197
204
);
198
-
199
205
$ this ->assertEmpty ($ response );
200
- $ this ->assertGreaterThanOrEqual (strtotime ($ productUpdatedAt ), strtotime ($ newUpdateAt ));
206
+
207
+ /** @var ProductRepository $afterProductRepository */
208
+ $ afterProductRepository = $ this ->repositoryFactory ->create ();
209
+ $ afterProductUpdatedAt = $ afterProductRepository ->get (self ::SIMPLE_PRODUCT_SKU )->getUpdatedAt ();
210
+ $ this ->assertTrue (strtotime ($ afterProductUpdatedAt ) >= strtotime ($ beforeProductUpdatedAt ));
201
211
}
202
212
}
0 commit comments