Skip to content

Commit eb88d3f

Browse files
committed
ACP2E-2837: Product entity updated_at column values not updating while updating price through REST API
- Fixed the CR comments.
1 parent 8351394 commit eb88d3f

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

dev/tests/api-functional/testsuite/Magento/Catalog/Api/BasePriceStorageTest.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
use Magento\TestFramework\TestCase\WebapiAbstract;
1212
use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
1313
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;
1418

1519
/**
1620
* Base price storage test to test the update and update with invalid parameter.
@@ -31,13 +35,19 @@ class BasePriceStorageTest extends WebapiAbstract
3135
*/
3236
private $repositoryFactory;
3337

38+
/**
39+
* @var DataFixtureStorage
40+
*/
41+
private $fixtures;
42+
3443
/**
3544
* Set up.
3645
*/
3746
protected function setUp(): void
3847
{
3948
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
4049
$this->repositoryFactory = Bootstrap::getObjectManager()->get(ProductRepositoryFactory::class);
50+
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
4151
}
4252

4353
/**
@@ -170,16 +180,20 @@ public function testUpdateWithInvalidParameters()
170180
/**
171181
* Test update last updated at method.
172182
*
173-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
174183
*/
184+
#[
185+
DataFixture(ProductFixture::class, as: 'product'),
186+
]
175187
public function testUpdateLastUpdatedAt()
176188
{
189+
$product = $this->fixtures->get('product');
190+
$productSku = $product->getSku();
177191
/** @var ProductRepository $beforeProductRepository */
178192
$beforeProductRepository = $this->repositoryFactory->create();
179-
$beforeProductUpdatedAt = $beforeProductRepository->get(self::SIMPLE_PRODUCT_SKU)->getUpdatedAt();
193+
$beforeProductUpdatedAt = $beforeProductRepository->get($productSku)->getUpdatedAt();
180194
$serviceInfo = [
181195
'rest' => [
182-
'resourcePath' => '/V1/products/base-prices?XDEBUG_SESSION_START=PHPSTORM',
196+
'resourcePath' => '/V1/products/base-prices',
183197
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST
184198
],
185199
'soap' => [
@@ -197,7 +211,7 @@ public function testUpdateLastUpdatedAt()
197211
[
198212
'price' => $newPrice,
199213
'store_id' => $storeId,
200-
'sku' => self::SIMPLE_PRODUCT_SKU,
214+
'sku' => $productSku,
201215
]
202216
]
203217
]
@@ -206,7 +220,7 @@ public function testUpdateLastUpdatedAt()
206220

207221
/** @var ProductRepository $afterProductRepository */
208222
$afterProductRepository = $this->repositoryFactory->create();
209-
$afterProductUpdatedAt = $afterProductRepository->get(self::SIMPLE_PRODUCT_SKU)->getUpdatedAt();
223+
$afterProductUpdatedAt = $afterProductRepository->get($productSku)->getUpdatedAt();
210224
$this->assertTrue(strtotime($afterProductUpdatedAt) >= strtotime($beforeProductUpdatedAt));
211225
}
212226
}

0 commit comments

Comments
 (0)