Skip to content

Commit

Permalink
magento#7720: fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Charlie committed Feb 10, 2020
1 parent 2c15517 commit 156b3c2
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Store\ExecuteInStoreContext;
use Magento\Store\Api\StoreRepositoryInterface;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -47,6 +48,9 @@ class MultiStoreConfigurableViewOnProductPageTest extends TestCase
/** @var ExecuteInStoreContext */
private $executeInStoreContext;

/** @var StoreRepositoryInterface */
private $storeRepository;

/**
* @inheritdoc
*/
Expand All @@ -62,6 +66,7 @@ protected function setUp()
$this->serializer = $this->objectManager->get(SerializerInterface::class);
$this->productResource = $this->objectManager->get(ProductResource::class);
$this->executeInStoreContext = $this->objectManager->get(ExecuteInStoreContext::class);
$this->storeRepository = $this->objectManager->get(StoreRepositoryInterface::class);
}

/**
Expand Down Expand Up @@ -182,9 +187,11 @@ public function assertProductConfig($expectedProducts): void
*/
private function prepareConfigurableProduct(string $sku, string $storeCode): void
{
$storeId = $this->storeRepository->get($storeCode)->getId();
$product = $this->productRepository->get($sku, false, null, true);
$productToUpdate = $product->getTypeInstance()->getUsedProductCollection($product)
->setPageSize(1)->getFirstItem();
->addStoreFilter($storeId)->setPageSize(1)->getFirstItem();

$this->assertNotEmpty($productToUpdate->getData(), 'Configurable product does not have a child');
$this->executeInStoreContext->execute($storeCode, [$this, 'setProductDisabled'], $productToUpdate);
}
Expand Down

0 comments on commit 156b3c2

Please sign in to comment.