Skip to content

Commit dd344de

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #727 from magento-tango/bugs_pr
[Tango] Bug Fixes
2 parents 833766c + f9531cb commit dd344de

File tree

9 files changed

+209
-49
lines changed

9 files changed

+209
-49
lines changed

app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset/element.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
$element = $block->getElement();
1313
$note = $element->getNote() ? '<div class="note" id="' . $element->getId() . '-note">' . $element->getNote() . '</div>' : '';
1414
$elementBeforeLabel = $element->getExtType() == 'checkbox admin__control-checkbox' || $element->getExtType() == 'radio admin__control-radio';
15-
$addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml();
15+
$addOn = ($element->getBeforeElementHtml() || $element->getAfterElementHtml()) && !$element->getNoWrapAsAddon();
1616
$fieldId = ($element->getHtmlContainerId()) ? ' id="' . $element->getHtmlContainerId() . '"' : '';
1717
$fieldClass = "admin__field field field-{$element->getId()} {$element->getCssClass()}";
1818
$fieldClass .= ($elementBeforeLabel) ? ' choice' : '';

app/code/Magento/Customer/Block/CustomerData.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,14 @@
77

88
class CustomerData extends \Magento\Framework\View\Element\Template
99
{
10-
/**
11-
* Sections that can not be cached on frontend-side
12-
*
13-
* @var array
14-
*/
15-
protected $nonCachedSections = [];
16-
1710
/**
1811
* @param \Magento\Framework\View\Element\Template\Context $context
1912
* @param array $data
20-
* @param array $nonCachedSections
2113
*/
2214
public function __construct(
2315
\Magento\Framework\View\Element\Template\Context $context,
24-
array $data = [],
25-
array $nonCachedSections = []
16+
array $data = []
2617
) {
27-
$this->nonCachedSections = $nonCachedSections;
2818
parent::__construct($context, $data);
2919
}
3020

@@ -50,24 +40,4 @@ public function getCustomerDataUrl($route)
5040
{
5141
return $this->getUrl($route, ['_secure' => $this->getRequest()->isSecure()]);
5242
}
53-
54-
/**
55-
* Get sections that can not be cached on frontend-side
56-
*
57-
* @return array
58-
*/
59-
public function getNotCachedSections()
60-
{
61-
return $this->nonCachedSections;
62-
}
63-
64-
/**
65-
* Get keys of sections that can not be cached on frontend-side
66-
*
67-
* @return array
68-
*/
69-
public function getNonCachedSectionKeys()
70-
{
71-
return array_keys($this->nonCachedSections);
72-
}
7343
}

app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
'*' => ['Magento_Customer/js/customer-data' => [
1414
'sectionLoadUrl' => $block->getCustomerDataUrl('customer/section/load'),
1515
'cookieLifeTime' => $block->getCookieLifeTime(),
16-
'nonCachedSections' => $block->getNonCachedSectionKeys(),
1716
]],
1817
]);
1918
?>

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ define([
2323
storage.removeAll();
2424
var date = new Date(Date.now() + parseInt(options.cookieLifeTime, 10) * 1000);
2525
$.localStorage.set('mage-cache-timeout', date);
26-
} else {
27-
invalidateNonCachedSections(options);
2826
}
2927
};
3028

@@ -35,12 +33,6 @@ define([
3533
}
3634
};
3735

38-
var invalidateNonCachedSections = function(options) {
39-
_.each(options.nonCachedSections, function (sectionName) {
40-
storageInvalidation.set(sectionName, true);
41-
});
42-
}
43-
4436
var dataProvider = {
4537
getFromStorage: function (sectionNames) {
4638
var result = {};

app/code/Magento/Theme/Block/Html/Title.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ public function getPageTitle()
3737
return $this->pageConfig->getTitle()->getShort();
3838
}
3939

40+
/**
41+
* Provide own page content heading
42+
*
43+
* @return string
44+
*/
45+
public function getPageHeading()
46+
{
47+
if (!empty($this->pageTitle)) {
48+
return $this->pageTitle;
49+
}
50+
return $this->pageConfig->getTitle()->getShortHeading();
51+
}
52+
4053
/**
4154
* Set own page title
4255
*
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Theme\Test\Unit\Block\Html;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
10+
class TitleTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var ObjectManagerHelper
14+
*/
15+
protected $objectManagerHelper;
16+
17+
/**
18+
* @var \Magento\Framework\View\Page\Config|\PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
protected $pageConfigMock;
21+
22+
/**
23+
* @var \Magento\Framework\View\Page\Title|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
protected $pageTitleMock;
26+
27+
/**
28+
* @var \Magento\Theme\Block\Html\Title
29+
*/
30+
protected $htmlTitle;
31+
32+
/**
33+
* @return void
34+
*/
35+
protected function setUp()
36+
{
37+
$this->objectManagerHelper = new ObjectManagerHelper($this);
38+
$this->pageConfigMock = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false);
39+
$this->pageTitleMock = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false);
40+
41+
$context = $this->objectManagerHelper->getObject(
42+
'Magento\Framework\View\Element\Template\Context',
43+
['pageConfig' => $this->pageConfigMock]
44+
);
45+
46+
$this->htmlTitle = $this->objectManagerHelper->getObject(
47+
'Magento\Theme\Block\Html\Title',
48+
['context' => $context]
49+
);
50+
}
51+
52+
/**
53+
* @return void
54+
*/
55+
public function testGetPageTitleWithSetPageTitle()
56+
{
57+
$title = 'some title';
58+
59+
$this->htmlTitle->setPageTitle($title);
60+
$this->pageConfigMock->expects($this->never())
61+
->method('getTitle');
62+
63+
$this->assertEquals($title, $this->htmlTitle->getPageTitle());
64+
}
65+
66+
/**
67+
* @return void
68+
*/
69+
public function testGetPageTitle()
70+
{
71+
$title = 'some title';
72+
73+
$this->pageTitleMock->expects($this->once())
74+
->method('getShort')
75+
->willReturn($title);
76+
$this->pageConfigMock->expects($this->once())
77+
->method('getTitle')
78+
->willReturn($this->pageTitleMock);
79+
80+
$this->assertEquals($title, $this->htmlTitle->getPageTitle());
81+
}
82+
83+
/**
84+
* @return void
85+
*/
86+
public function testGetPageHeadingWithSetPageTitle()
87+
{
88+
$title = 'some title';
89+
90+
$this->htmlTitle->setPageTitle($title);
91+
$this->pageConfigMock->expects($this->never())
92+
->method('getTitle');
93+
94+
$this->assertEquals($title, $this->htmlTitle->getPageHeading());
95+
}
96+
97+
/**
98+
* @return void
99+
*/
100+
public function testGetPageHeading()
101+
{
102+
$title = 'some title';
103+
104+
$this->pageTitleMock->expects($this->once())
105+
->method('getShortHeading')
106+
->willReturn($title);
107+
$this->pageConfigMock->expects($this->once())
108+
->method('getTitle')
109+
->willReturn($this->pageTitleMock);
110+
111+
$this->assertEquals($title, $this->htmlTitle->getPageHeading());
112+
}
113+
}

app/code/Magento/Theme/view/frontend/templates/html/title.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
*/
1212
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
1313
$title = '';
14-
if (trim($block->getPageTitle())) {
14+
if (trim($block->getPageHeading())) {
1515
$title = '<span class="base" data-ui-id="page-title-wrapper" ' . $block->getAddBaseAttribute() . '>'
16-
. $block->escapeHtml($block->getPageTitle()) . '</span>';
16+
. $block->escapeHtml($block->getPageHeading()) . '</span>';
1717
}
1818
?>
1919
<?php if ($title): ?>

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,26 @@ public function getShort()
7777
}
7878

7979
/**
80+
* Same as getShort(), but return title without prefix and suffix
81+
* @return mixed
82+
*/
83+
public function getShortHeading()
84+
{
85+
$title = $this->build(false);
86+
return reset($title);
87+
}
88+
89+
/**
90+
* @param bool $withConfigValues
8091
* @return array
8192
*/
82-
protected function build()
93+
protected function build($withConfigValues = true)
8394
{
84-
return array_merge($this->prependedValues, [$this->addConfigValues($this->textValue)], $this->appendedValues);
95+
return array_merge(
96+
$this->prependedValues,
97+
[$withConfigValues ? $this->addConfigValues($this->textValue) : $this->textValue],
98+
$this->appendedValues
99+
);
85100
}
86101

87102
/**

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

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class TitleTest extends \PHPUnit_Framework_TestCase
2323
*/
2424
protected $scopeConfigMock;
2525

26+
/**
27+
* @return void
28+
*/
2629
public function setUp()
2730
{
2831
$this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
@@ -36,13 +39,19 @@ public function setUp()
3639
);
3740
}
3841

42+
/**
43+
* @return void
44+
*/
3945
public function testSet()
4046
{
4147
$value = 'test_value';
4248
$this->title->set($value);
4349
$this->assertEquals($value, $this->title->get());
4450
}
4551

52+
/**
53+
* @return void
54+
*/
4655
public function testUnset()
4756
{
4857
$value = 'test';
@@ -52,6 +61,9 @@ public function testUnset()
5261
$this->assertEmpty($this->title->get());
5362
}
5463

64+
/**
65+
* @return void
66+
*/
5567
public function testGet()
5668
{
5769
$value = 'test';
@@ -61,16 +73,19 @@ public function testGet()
6173

6274
$this->scopeConfigMock->expects($this->any())
6375
->method('getValue')
64-
->will($this->returnValueMap(
76+
->willReturnMap(
6577
[
6678
['design/head/title_prefix', ScopeInterface::SCOPE_STORE, null, $prefix],
6779
['design/head/title_suffix', ScopeInterface::SCOPE_STORE, null, $suffix],
6880
]
69-
));
81+
);
7082
$this->title->set($value);
7183
$this->assertEquals($expected, $this->title->get());
7284
}
7385

86+
/**
87+
* @return void
88+
*/
7489
public function testGetShort()
7590
{
7691
$value = 'some_title';
@@ -81,6 +96,46 @@ public function testGetShort()
8196
$this->assertEquals($value, $this->title->getShort());
8297
}
8398

99+
/**
100+
* @return void
101+
*/
102+
public function testGetShortWithSuffixAndPrefix()
103+
{
104+
$value = 'some_title';
105+
$prefix = 'prefix';
106+
$suffix = 'suffix';
107+
$expected = $prefix . ' ' . $value . ' ' . $suffix;
108+
$this->title->set($value);
109+
110+
$this->scopeConfigMock->expects($this->any())
111+
->method('getValue')
112+
->willReturnMap(
113+
[
114+
['design/head/title_prefix', ScopeInterface::SCOPE_STORE, null, $prefix],
115+
['design/head/title_suffix', ScopeInterface::SCOPE_STORE, null, $suffix],
116+
]
117+
);
118+
119+
$this->assertEquals($expected, $this->title->getShort());
120+
}
121+
122+
/**
123+
* @return void
124+
*/
125+
public function testGetShortHeading()
126+
{
127+
$value = 'some_title';
128+
$this->title->set($value);
129+
130+
$this->scopeConfigMock->expects($this->never())
131+
->method('getValue');
132+
133+
$this->assertEquals($value, $this->title->getShortHeading());
134+
}
135+
136+
/**
137+
* @return void
138+
*/
84139
public function testGetDefault()
85140
{
86141
$defaultTitle = 'default title';
@@ -90,16 +145,19 @@ public function testGetDefault()
90145

91146
$this->scopeConfigMock->expects($this->any())
92147
->method('getValue')
93-
->will($this->returnValueMap(
148+
->willReturnMap(
94149
[
95150
['design/head/title_prefix', ScopeInterface::SCOPE_STORE, null, $prefix],
96151
['design/head/title_suffix', ScopeInterface::SCOPE_STORE, null, $suffix],
97152
['design/head/default_title', ScopeInterface::SCOPE_STORE, null, $defaultTitle],
98153
]
99-
));
154+
);
100155
$this->assertEquals($expected, $this->title->getDefault());
101156
}
102157

158+
/**
159+
* @return void
160+
*/
103161
public function testAppendPrepend()
104162
{
105163
$value = 'title';

0 commit comments

Comments
 (0)