@@ -75,9 +75,7 @@ public function testDisabledProductInvisibility(): void
75
75
*/
76
76
public function testProductVisibility (int $ visibility ): void
77
77
{
78
- $ product = $ this ->productRepository ->get ('simple2 ' );
79
- $ product ->setVisibility ($ visibility );
80
- $ this ->productRepository ->save ($ product );
78
+ $ product = $ this ->updateProductVisibility ('simple2 ' , $ visibility );
81
79
$ this ->dispatch (sprintf ('catalog/product/view/id/%s/ ' , $ product ->getId ()));
82
80
83
81
$ this ->assertProductIsVisible ($ product );
@@ -95,6 +93,17 @@ public function productVisibilityDataProvider(): array
95
93
];
96
94
}
97
95
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
+
98
107
/**
99
108
* @inheritdoc
100
109
*/
@@ -124,4 +133,19 @@ private function assertProductIsVisible(ProductInterface $product): void
124
133
'Wrong product is registered '
125
134
);
126
135
}
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
+ }
127
151
}
0 commit comments