Skip to content

Commit 3936c10

Browse files
committed
Merge branch 'MC-40076' into 2.4-develop-sidecar-pr13
2 parents 24c261e + 67daa25 commit 3936c10

File tree

1 file changed

+44
-1
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Product

1 file changed

+44
-1
lines changed

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@
1313
use Magento\Catalog\Model\Product;
1414
use Magento\Catalog\Model\Product\Visibility;
1515
use Magento\Eav\Model\Entity\Type;
16+
use Magento\Framework\App\ActionInterface;
1617
use Magento\Framework\App\Cache\Manager;
18+
use Magento\Framework\App\Config\ScopeConfigInterface;
1719
use Magento\Framework\App\Http;
20+
use Magento\Framework\App\Request\Http as HttpRequest;
1821
use Magento\Framework\Registry;
22+
use Magento\Framework\Url\EncoderInterface;
23+
use Magento\Store\Model\Store;
1924
use Magento\Store\Model\StoreManagerInterface;
2025
use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
2126
use Magento\TestFramework\Request;
2227
use PHPUnit\Framework\MockObject\MockObject;
2328
use Psr\Log\LoggerInterface;
2429
use Magento\Catalog\Api\Data\ProductAttributeInterface;
2530
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
26-
use Magento\Framework\Logger\Monolog as MagentoMonologLogger;
2731
use Magento\TestFramework\Response;
2832
use Magento\TestFramework\TestCase\AbstractController;
2933

@@ -66,6 +70,12 @@ class ViewTest extends AbstractController
6670
/** @var GetAttributeSetByName */
6771
private $getAttributeSetByName;
6872

73+
/** @var EncoderInterface */
74+
private $urlEncoder;
75+
76+
/** @var ScopeConfigInterface */
77+
private $config;
78+
6979
/**
7080
* @inheritdoc
7181
*/
@@ -81,6 +91,8 @@ protected function setUp(): void
8191
$this->registry = $this->_objectManager->get(Registry::class);
8292
$this->storeManager = $this->_objectManager->get(StoreManagerInterface::class);
8393
$this->getAttributeSetByName = $this->_objectManager->get(GetAttributeSetByName::class);
94+
$this->urlEncoder = $this->_objectManager->get(EncoderInterface::class);
95+
$this->config = $this->_objectManager->get(ScopeConfigInterface::class);
8496
}
8597

8698
/**
@@ -294,6 +306,37 @@ public function test404NotFoundPageCacheTags(): void
294306
);
295307
}
296308

309+
/**
310+
* @return void
311+
*/
312+
public function testViewUnexistedProduct(): void
313+
{
314+
$url = '/catalog/product/view/id/999/';
315+
$this->getRequest()->setParams([
316+
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($url),
317+
])->setMethod(HttpRequest::METHOD_POST);
318+
$this->dispatch($url);
319+
$this->assert404NotFound();
320+
}
321+
322+
/**
323+
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
324+
*
325+
* @return void
326+
*/
327+
public function testViewWithRedirect(): void
328+
{
329+
$product = $this->productRepository->get('simple2');
330+
$url = $this->config->getValue(Store::XML_PATH_UNSECURE_BASE_LINK_URL);
331+
$this->getRequest()
332+
->setParams([
333+
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($url),
334+
])
335+
->setMethod(HttpRequest::METHOD_POST);
336+
$this->dispatch(sprintf('catalog/product/view/id/%s/', $product->getId()));
337+
$this->assertRedirect($this->stringContains($url));
338+
}
339+
297340
/**
298341
* @param string|ProductInterface $product
299342
* @param array $data

0 commit comments

Comments
 (0)