Skip to content

Commit 5c70170

Browse files
committed
MC-21685: View simple product on storefront
1 parent 5e6c296 commit 5c70170

File tree

1 file changed

+27
-3
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Product

1 file changed

+27
-3
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public function testDisabledProductInvisibility(): void
7575
*/
7676
public function testProductVisibility(int $visibility): void
7777
{
78-
$product = $this->productRepository->get('simple2');
79-
$product->setVisibility($visibility);
80-
$this->productRepository->save($product);
78+
$product = $this->updateProductVisibility('simple2', $visibility);
8179
$this->dispatch(sprintf('catalog/product/view/id/%s/', $product->getId()));
8280

8381
$this->assertProductIsVisible($product);
@@ -95,6 +93,17 @@ public function productVisibilityDataProvider(): array
9593
];
9694
}
9795

96+
/**
97+
* @magentoDataFixture Magento/Catalog/_files/simple_products_not_visible_individually.php
98+
*/
99+
public function testProductNotVisibleIndividually(): void
100+
{
101+
$product = $this->updateProductVisibility('simple_not_visible_1', Visibility::VISIBILITY_NOT_VISIBLE);
102+
$this->dispatch(sprintf('catalog/product/view/id/%s/', $product->getId()));
103+
104+
$this->assert404NotFound();
105+
}
106+
98107
/**
99108
* @inheritdoc
100109
*/
@@ -124,4 +133,19 @@ private function assertProductIsVisible(ProductInterface $product): void
124133
'Wrong product is registered'
125134
);
126135
}
136+
137+
/**
138+
* Update product visibility
139+
*
140+
* @param string $sku
141+
* @param int $visibility
142+
* @return ProductInterface
143+
*/
144+
private function updateProductVisibility(string $sku, int $visibility): ProductInterface
145+
{
146+
$product = $this->productRepository->get($sku);
147+
$product->setVisibility($visibility);
148+
149+
return $this->productRepository->save($product);
150+
}
127151
}

0 commit comments

Comments
 (0)