66
77namespace Magento \Catalog \Api ;
88
9+ use Magento \Catalog \Model \ProductRepository ;
10+ use Magento \TestFramework \Helper \Bootstrap ;
911use Magento \TestFramework \TestCase \WebapiAbstract ;
1012use Magento \Framework \Webapi \Exception as HTTPExceptionCodes ;
13+ use Magento \Catalog \Model \ProductRepositoryFactory ;
1114
1215/**
1316 * BasePriceStorage test.
@@ -23,12 +26,18 @@ class BasePriceStorageTest extends WebapiAbstract
2326 */
2427 private $ objectManager ;
2528
29+ /**
30+ * @var ProductRepositoryFactory
31+ */
32+ private $ repositoryFactory ;
33+
2634 /**
2735 * Set up.
2836 */
2937 protected function setUp (): void
3038 {
3139 $ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
40+ $ this ->repositoryFactory = Bootstrap::getObjectManager ()->get (ProductRepositoryFactory::class);
3241 }
3342
3443 /**
@@ -165,11 +174,9 @@ public function testUpdateWithInvalidParameters()
165174 */
166175 public function testUpdateLastUpdatedAt ()
167176 {
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 ();
173180 $ serviceInfo = [
174181 'rest ' => [
175182 'resourcePath ' => '/V1/products/base-prices?XDEBUG_SESSION_START=PHPSTORM ' ,
@@ -195,8 +202,11 @@ public function testUpdateLastUpdatedAt()
195202 ]
196203 ]
197204 );
198-
199205 $ 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 ));
201211 }
202212}
0 commit comments