Skip to content

Commit 52828bd

Browse files
committed
Merge remote-tracking branch 'origin/MC-31807' into 2.3-develop-pr146
2 parents 321cdc9 + 45a57bc commit 52828bd

File tree

41 files changed

+3026
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3026
-467
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Checkout\Model\Type\Onepage;
10+
use Magento\Customer\Api\CustomerRepositoryInterface;
11+
use Magento\Quote\Api\CartRepositoryInterface;
12+
use Magento\Quote\Api\Data\CartInterface;
13+
use Magento\Quote\Api\Data\CartInterfaceFactory;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
16+
require __DIR__ . '/../../Customer/_files/customer.php';
17+
require __DIR__ . '/../../../Magento/Catalog/_files/taxable_simple_product.php';
18+
19+
$objectManager = Bootstrap::getObjectManager();
20+
/** @var ProductRepositoryInterface $productRepository */
21+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
22+
$productRepository->cleanCache();
23+
/** @var CartRepositoryInterface $quoteRepository */
24+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
25+
/** @var CustomerRepositoryInterface $customerRepository */
26+
$customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
27+
$customer = $customerRepository->get('customer@example.com');
28+
29+
/** @var CartInterface $quote */
30+
$quote = $objectManager->get(CartInterfaceFactory::class)->create();
31+
$quote->setStoreId(1)
32+
->setIsActive(false)
33+
->setIsMultiShipping(0)
34+
->setCustomer($customer)
35+
->setCheckoutMethod(Onepage::METHOD_CUSTOMER)
36+
->setReservedOrderId('test_order_with_customer_inactive_quote')
37+
->addProduct($productRepository->get('taxable_product'), 1);
38+
$quoteRepository->save($quote);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Quote\Api\CartRepositoryInterface;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
11+
12+
$objectManager = Bootstrap::getObjectManager();
13+
/** @var CartRepositoryInterface $quoteRepository */
14+
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
15+
/** @var GetQuoteByReservedOrderId $getQuoteByReservedOrderId */
16+
$getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class);
17+
$quote = $getQuoteByReservedOrderId->execute('test_order_with_customer_inactive_quote');
18+
if ($quote !== null) {
19+
$quoteRepository->delete($quote);
20+
}
21+
22+
require __DIR__ . '/../../../Magento/Catalog/_files/taxable_simple_product_rollback.php';
23+
require __DIR__ . '/../../Customer/_files/customer_rollback.php';

dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,38 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/**
8-
* Test class for \Magento\Cms\Controller\Page.
9-
*/
107
namespace Magento\Cms\Controller;
118

129
use Magento\Cms\Api\GetPageByIdentifierInterface;
10+
use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
1311
use Magento\Framework\View\LayoutInterface;
14-
use Magento\TestFramework\Helper\Bootstrap;
12+
use Magento\TestFramework\Cms\Model\CustomLayoutManager;
13+
use Magento\TestFramework\TestCase\AbstractController;
1514

16-
class PageTest extends \Magento\TestFramework\TestCase\AbstractController
15+
/**
16+
* Test for \Magento\Cms\Controller\Page\View class.
17+
*/
18+
class PageTest extends AbstractController
1719
{
20+
/**
21+
* @var GetPageByIdentifierInterface
22+
*/
23+
private $pageRetriever;
24+
25+
/**
26+
* @inheritDoc
27+
*/
28+
protected function setUp()
29+
{
30+
parent::setUp();
31+
$this->_objectManager->configure([
32+
'preferences' => [
33+
CustomLayoutManagerInterface::class => CustomLayoutManager::class,
34+
],
35+
]);
36+
$this->pageRetriever = $this->_objectManager->get(GetPageByIdentifierInterface::class);
37+
}
38+
1839
public function testViewAction()
1940
{
2041
$this->dispatch('/enable-cookies');
@@ -37,9 +58,7 @@ public function testViewRedirectWithTrailingSlash()
3758
public function testAddBreadcrumbs()
3859
{
3960
$this->dispatch('/enable-cookies');
40-
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
41-
\Magento\Framework\View\LayoutInterface::class
42-
);
61+
$layout = $this->_objectManager->get(LayoutInterface::class);
4362
$breadcrumbsBlock = $layout->getBlock('breadcrumbs');
4463
$this->assertContains($breadcrumbsBlock->toHtml(), $this->getResponse()->getBody());
4564
}
@@ -76,13 +95,40 @@ public static function cmsPageWithSystemRouteFixture()
7695
*/
7796
public function testCustomHandles(): void
7897
{
79-
/** @var GetPageByIdentifierInterface $pageFinder */
80-
$pageFinder = Bootstrap::getObjectManager()->get(GetPageByIdentifierInterface::class);
81-
$page = $pageFinder->execute('test_custom_layout_page_3', 0);
82-
$this->dispatch('/cms/page/view/page_id/' .$page->getId());
98+
$page = $this->pageRetriever->execute('test_custom_layout_page_3', 0);
99+
$this->dispatch('/cms/page/view/page_id/' . $page->getId());
83100
/** @var LayoutInterface $layout */
84-
$layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
101+
$layout = $this->_objectManager->get(LayoutInterface::class);
85102
$handles = $layout->getUpdate()->getHandles();
86103
$this->assertContains('cms_page_view_selectable_test_custom_layout_page_3_test_selected', $handles);
87104
}
105+
106+
/**
107+
* Tests page renders even with unavailable custom page layout.
108+
*
109+
* @magentoDataFixture Magento/Cms/Fixtures/page_list.php
110+
* @dataProvider pageLayoutDataProvider
111+
* @param string $pageIdentifier
112+
* @return void
113+
*/
114+
public function testPageWithCustomLayout(string $pageIdentifier): void
115+
{
116+
$page = $this->pageRetriever->execute($pageIdentifier, 0);
117+
$this->dispatch('/cms/page/view/page_id/' . $page->getId());
118+
$this->assertContains(
119+
'<main id="maincontent" class="page-main">',
120+
$this->getResponse()->getBody()
121+
);
122+
}
123+
124+
/**
125+
* @return array
126+
*/
127+
public function pageLayoutDataProvider(): array
128+
{
129+
return [
130+
'Page with 1column layout' => ['page-with-1column-layout'],
131+
'Page with unavailable layout' => ['page-with-unavailable-layout'],
132+
];
133+
}
88134
}

dev/tests/integration/testsuite/Magento/Cms/Fixtures/page_list.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,27 @@
1414
$data = [
1515
[
1616
'title' => 'simplePage',
17-
'is_active' => 1
17+
'is_active' => 1,
1818
],
1919
[
2020
'title' => 'simplePage01',
21-
'is_active' => 1
21+
'is_active' => 1,
2222
],
2323
[
2424
'title' => '01simplePage',
25-
'is_active' => 1
25+
'is_active' => 1,
26+
],
27+
[
28+
'title' => 'Page with 1column layout',
29+
'content' => '<h1>Test Page Content</h1>',
30+
'is_active' => 1,
31+
'page_layout' => '1column',
32+
],
33+
[
34+
'title' => 'Page with unavailable layout',
35+
'content' => '<h1>Test Page Content</h1>',
36+
'is_active' => 1,
37+
'page_layout' => 'unavailable-layout',
2638
],
2739
];
2840

dev/tests/integration/testsuite/Magento/Cms/Fixtures/page_list_rollback.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616

1717
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
1818
$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
19-
$searchCriteria = $searchCriteriaBuilder->addFilter('title', ['simplePage', 'simplePage01', '01simplePage'], 'in')
19+
$searchCriteria = $searchCriteriaBuilder
20+
->addFilter(
21+
'title',
22+
[
23+
'simplePage',
24+
'simplePage01',
25+
'01simplePage',
26+
'Page with 1column layout',
27+
'Page with unavailable layout',
28+
],
29+
'in'
30+
)
2031
->create();
2132
$result = $pageRepository->getList($searchCriteria);
2233

0 commit comments

Comments
 (0)