Skip to content

Commit def5066

Browse files
authored
Merge pull request #6128 from magento-tsg/2.3-develop-pr146
[TSG] Fixes for 2.3 (pr146) (2.3-develop)
2 parents 304da81 + 862fae6 commit def5066

File tree

8 files changed

+135
-32
lines changed

8 files changed

+135
-32
lines changed

app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ require([
122122
content: "<?= $block->escapeJs($block->escapeHtml(__('Are you sure you want to strip tags?'))) ?>",
123123
actions: {
124124
confirm: function () {
125-
this.unconvertedText = $('template_text').value;
125+
self.unconvertedText = $('template_text').value;
126126
$('convert_button').hide();
127127
$('template_text').value = $('template_text').value.stripScripts().replace(
128128
new RegExp('<style[^>]*>[\\S\\s]*?</style>', 'img'), ''

app/code/Magento/Paypal/Test/Mftf/ActionGroup/StorefrontPayOrderOnPayPalCheckoutActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<click selector="{{PayPalPaymentSection.cartIcon}}" stepKey="openCart"/>
1919
<waitForElementVisible selector="{{PayPalPaymentSection.itemName(productName)}}" stepKey="waitForCartLoad"/>
2020
<seeElement selector="{{PayPalPaymentSection.itemName(productName)}}" stepKey="seeProductName"/>
21-
<scrollTo selector="{{PayPalPaymentSection.PayPalSubmitBtn}}" stepKey="scrollToPayPalSubmitBtn"/>
21+
<conditionalClick selector="{{PayPalPaymentSection.acceptCookies}}" dependentSelector="{{PayPalPaymentSection.acceptCookies}}" visible="true" stepKey="acceptCookiesIfAppeared"/>
2222
<click selector="{{PayPalPaymentSection.PayPalSubmitBtn}}" stepKey="clickPayPalSubmitBtn"/>
2323
<switchToPreviousTab stepKey="switchToPreviousTab"/>
2424
<waitForPageLoad stepKey="waitForPageLoad"/>

app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@
6464
<element name="PayPalSubmitBtn" type="text" selector="#payment-submit-btn"/>
6565
<element name="nextButton" type="button" selector="#btnNext"/>
6666
<element name="continueButton" type="button" selector=".continueButton"/>
67+
<element name="acceptCookies" type="button" selector=".ccpaCookieBanner_buttonGroup #acceptAllButton" timeout="10"/>
6768
</section>
6869
</sections>

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

lib/internal/Magento/Framework/View/Page/Builder.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Framework\View\Page;
78

89
use Magento\Framework\App;
10+
use Magento\Framework\App\ObjectManager;
911
use Magento\Framework\Event;
1012
use Magento\Framework\View;
13+
use Magento\Framework\View\Model\PageLayout\Config\BuilderInterface;
1114

1215
/**
13-
* Class Builder
16+
* Page Layout Builder
1417
*/
1518
class Builder extends View\Layout\Builder
1619
{
@@ -24,23 +27,31 @@ class Builder extends View\Layout\Builder
2427
*/
2528
protected $pageLayoutReader;
2629

30+
/**
31+
* @var BuilderInterface
32+
*/
33+
private $pageLayoutBuilder;
34+
2735
/**
2836
* @param View\LayoutInterface $layout
2937
* @param App\Request\Http $request
3038
* @param Event\ManagerInterface $eventManager
3139
* @param Config $pageConfig
3240
* @param Layout\Reader $pageLayoutReader
41+
* @param BuilderInterface|null $pageLayoutBuilder
3342
*/
3443
public function __construct(
3544
View\LayoutInterface $layout,
3645
App\Request\Http $request,
3746
Event\ManagerInterface $eventManager,
3847
Config $pageConfig,
39-
Layout\Reader $pageLayoutReader
48+
Layout\Reader $pageLayoutReader,
49+
?BuilderInterface $pageLayoutBuilder = null
4050
) {
4151
parent::__construct($layout, $request, $eventManager);
4252
$this->pageConfig = $pageConfig;
4353
$this->pageLayoutReader = $pageLayoutReader;
54+
$this->pageLayoutBuilder = $pageLayoutBuilder ?? ObjectManager::getInstance()->get(BuilderInterface::class);
4455
$this->pageConfig->setBuilder($this);
4556
}
4657

@@ -57,6 +68,7 @@ protected function generateLayoutBlocks()
5768

5869
/**
5970
* Read page layout and write structure to ReadContext
71+
*
6072
* @return void
6173
*/
6274
protected function readPageLayout()
@@ -69,10 +81,16 @@ protected function readPageLayout()
6981
}
7082

7183
/**
84+
* Get current page layout or fallback to default
85+
*
7286
* @return string
7387
*/
7488
protected function getPageLayout()
7589
{
76-
return $this->pageConfig->getPageLayout() ?: $this->layout->getUpdate()->getPageLayout();
90+
$pageLayout = $this->pageConfig->getPageLayout();
91+
92+
return ($pageLayout && $this->pageLayoutBuilder->getPageLayoutsConfig()->hasPageLayout($pageLayout))
93+
? $pageLayout
94+
: $this->layout->getUpdate()->getPageLayout();
7795
}
7896
}

lib/internal/Magento/Framework/View/Test/Unit/Page/BuilderTest.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,53 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Framework\View\Test\Unit\Page;
89

9-
use Magento\Framework;
10+
use Magento\Framework\View\Layout\Reader\Context;
11+
use Magento\Framework\View\Model\PageLayout\Config\BuilderInterface;
12+
use Magento\Framework\View\Page\Builder;
13+
use Magento\Framework\View\Page\Config;
14+
use Magento\Framework\View\Page\Layout\Reader;
15+
use Magento\Framework\View\PageLayout\Config as PageLayoutConfig;
16+
use PHPUnit\Framework\MockObject\MockObject;
1017

1118
/**
12-
* Class BuilderTest
1319
* @covers \Magento\Framework\View\Page\Builder
1420
*/
1521
class BuilderTest extends \Magento\Framework\View\Test\Unit\Layout\BuilderTest
1622
{
17-
const CLASS_NAME = \Magento\Framework\View\Page\Builder::class;
23+
const CLASS_NAME = Builder::class;
1824

1925
/**
2026
* @param array $arguments
21-
* @return \Magento\Framework\View\Page\Builder
27+
* @return \Magento\Framework\View\Layout\Builder
2228
*/
2329
protected function getBuilder($arguments)
2430
{
25-
$arguments['pageConfig'] = $this->createMock(\Magento\Framework\View\Page\Config::class);
31+
$arguments['pageConfig'] = $this->createMock(Config::class);
2632
$arguments['pageConfig']->expects($this->once())->method('setBuilder');
2733
$arguments['pageConfig']->expects($this->once())->method('getPageLayout')
28-
->will($this->returnValue('test_layout'));
34+
->willReturn('test_layout');
2935

30-
$readerContext = $this->createMock(\Magento\Framework\View\Layout\Reader\Context::class);
36+
$readerContext = $this->createMock(Context::class);
3137

32-
/** @var \PHPUnit_Framework_MockObject_MockObject $layout */
38+
/** @var MockObject $layout */
3339
$layout = & $arguments['layout'];
34-
$layout->expects($this->once())->method('getReaderContext')->will($this->returnValue($readerContext));
40+
$layout->expects($this->once())->method('getReaderContext')->willReturn($readerContext);
3541

36-
$arguments['pageLayoutReader'] = $this->createMock(\Magento\Framework\View\Page\Layout\Reader::class);
42+
$arguments['pageLayoutReader'] = $this->createMock(Reader::class);
3743
$arguments['pageLayoutReader']->expects($this->once())->method('read')->with($readerContext, 'test_layout');
44+
$pageLayoutConfig = $this->createMock(PageLayoutConfig::class);
45+
$arguments['pageLayoutBuilder'] = $this->getMockForAbstractClass(BuilderInterface::class);
46+
$arguments['pageLayoutBuilder']->expects($this->once())
47+
->method('getPageLayoutsConfig')
48+
->willReturn($pageLayoutConfig);
49+
$pageLayoutConfig->expects($this->once())
50+
->method('hasPageLayout')
51+
->with('test_layout')
52+
->willReturn(true);
3853

3954
return parent::getBuilder($arguments);
4055
}

0 commit comments

Comments
 (0)