File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
app/code/Magento/SendFriend/Controller
dev/tests/integration/testsuite/Magento/SendFriend/Controller Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ public function __construct(
6161
6262 /**
6363 * Check if module is enabled
64+ *
6465 * If allow only for customer - redirect to login page
6566 *
6667 * @param RequestInterface $request
@@ -102,7 +103,7 @@ protected function _initProduct()
102103 }
103104 try {
104105 $ product = $ this ->productRepository ->getById ($ productId );
105- if (!$ product ->isVisibleInCatalog ()) {
106+ if (!$ product ->isVisibleInSiteVisibility () || ! $ product -> isVisibleInCatalog ()) {
106107 return false ;
107108 }
108109 } catch (NoSuchEntityException $ noEntityException ) {
Original file line number Diff line number Diff line change @@ -85,6 +85,24 @@ public function testSendActionAsGuestWithInvalidData()
8585 );
8686 }
8787
88+ /**
89+ * Share the product invisible in catalog to friend as guest customer
90+ *
91+ * @magentoDbIsolation enabled
92+ * @magentoAppIsolation enabled
93+ * @magentoConfigFixture default_store sendfriend/email/enabled 1
94+ * @magentoConfigFixture default_store sendfriend/email/allow_guest 1
95+ * @magentoDataFixture Magento/Catalog/_files/simple_products_not_visible_individually.php
96+ */
97+ public function testSendInvisibleProduct ()
98+ {
99+ $ product = $ this ->getInvisibleProduct ();
100+ $ this ->prepareRequestData ();
101+
102+ $ this ->dispatch ('sendfriend/product/sendmail/id/ ' . $ product ->getId ());
103+ $ this ->assert404NotFound ();
104+ }
105+
88106 /**
89107 * @return ProductInterface
90108 */
@@ -93,6 +111,14 @@ private function getProduct()
93111 return $ this ->_objectManager ->get (ProductRepositoryInterface::class)->get ('custom-design-simple-product ' );
94112 }
95113
114+ /**
115+ * @return ProductInterface
116+ */
117+ private function getInvisibleProduct ()
118+ {
119+ return $ this ->_objectManager ->get (ProductRepositoryInterface::class)->get ('simple_not_visible_1 ' );
120+ }
121+
96122 /**
97123 * Login the user
98124 *
You can’t perform that action at this time.
0 commit comments