Skip to content

Commit 2c8a5eb

Browse files
committed
ACP2E-2504: [TMNA] Slow Query Investigation
1 parent 3e42feb commit 2c8a5eb

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2023 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Catalog\Model\Attribute\Backend\WebsiteSpecific;
20+
21+
use Magento\Catalog\Api\ProductRepositoryInterface;
22+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
23+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
24+
use Magento\Framework\MessageQueue\ConsumerFactory;
25+
use Magento\Store\Model\Store;
26+
use Magento\Store\Model\StoreManagerInterface;
27+
use Magento\TestFramework\Fixture\AppArea;
28+
use Magento\TestFramework\Fixture\DataFixture;
29+
use Magento\TestFramework\Fixture\DbIsolation;
30+
use Magento\TestFramework\Helper\Bootstrap;
31+
use PHPUnit\Framework\TestCase;
32+
33+
#[
34+
AppArea('adminhtml'),
35+
]
36+
class ValueSynchronizerTest extends TestCase
37+
{
38+
/**
39+
* @var StoreManagerInterface
40+
*/
41+
private $storeManager;
42+
43+
/**
44+
* @var ProductRepositoryInterface
45+
*/
46+
private $productRepository;
47+
48+
protected function setUp(): void
49+
{
50+
$this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class);
51+
$this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
52+
}
53+
54+
protected function tearDown(): void
55+
{
56+
$store = Bootstrap::getObjectManager()->create(Store::class);
57+
$store->load('store2', 'code');
58+
if ($store->getId()) {
59+
$store->delete();
60+
}
61+
}
62+
63+
#[
64+
DbIsolation(false),
65+
DataFixture(ProductFixture::class, ['sku' => 'prod1']),
66+
]
67+
public function testProcess(): void
68+
{
69+
$defaultStore = $this->storeManager->getStore('default');
70+
$product = $this->productRepository->get('prod1', true, $defaultStore->getId());
71+
$product->setStatus(Status::STATUS_DISABLED);
72+
$this->productRepository->save($product);
73+
74+
$secondStore = Bootstrap::getObjectManager()->create(Store::class);
75+
$secondStore->setName('Second store')
76+
->setCode('store2')
77+
->setStoreGroupId($defaultStore->getStoreGroupId())
78+
->setWebsiteId($defaultStore->getWebsiteId())
79+
->setIsActive(1);
80+
$secondStore->save();
81+
$this->storeManager->reinitStores();
82+
83+
$consumerFactory = Bootstrap::getObjectManager()->get(ConsumerFactory::class);
84+
$consumer = $consumerFactory->get('catalog_website_attribute_value_sync');
85+
$consumer->process(1);
86+
87+
$product = $this->productRepository->get('prod1', false, $secondStore->getId(), true);
88+
self::assertEquals(Status::STATUS_DISABLED, $product->getStatus());
89+
}
90+
}

0 commit comments

Comments
 (0)