Skip to content

Commit e60afa2

Browse files
author
Bomko, Alex(abomko)
committed
Merge pull request #559 from magento-tango/MAGETWO-52212
[Tango] Bug fixes
2 parents 9581647 + ced7d08 commit e60afa2

File tree

8 files changed

+150
-21
lines changed

8 files changed

+150
-21
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeIsRequired.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,27 @@ class AssertProductAttributeIsRequired extends AbstractConstraint
2929
* @param CatalogProductEdit $catalogProductEdit
3030
* @param CatalogProductAttribute $attribute
3131
* @param InjectableFixture $product
32+
* @param string $sectionName
3233
* @return void
3334
*/
3435
public function processAssert(
3536
CatalogProductIndex $catalogProductIndex,
3637
CatalogProductEdit $catalogProductEdit,
3738
CatalogProductAttribute $attribute,
38-
InjectableFixture $product
39+
InjectableFixture $product,
40+
$sectionName
3941
) {
4042
$catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
4143
$productForm = $catalogProductEdit->getProductForm();
4244
if (!$productForm->checkAttributeLabel($attribute)) {
43-
$productForm->openSection('attributes');
45+
$productForm->openSection($sectionName);
4446
}
4547
$productForm->getAttributeElement($attribute)->setValue('');
4648
$catalogProductEdit->getFormPageActions()->save();
47-
$failedFields = $productForm->getRequireNoticeFields($product);
48-
$actualMessage = $failedFields['attributes'][$attribute->getFrontendLabel()];
49+
$validationErrors = $productForm->getSection($sectionName)->getValidationErrors();
50+
$actualMessage = isset($validationErrors[$attribute->getFrontendLabel()])
51+
? $validationErrors[$attribute->getFrontendLabel()]
52+
: '';
4953

5054
\PHPUnit_Framework_Assert::assertEquals(
5155
self::REQUIRE_MESSAGE,

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<data name="attribute/data/is_required" xsi:type="string">Yes</data>
5656
<data name="attribute/data/attribute_code" xsi:type="string">attr_text_%isolation%</data>
5757
<data name="attribute/data/default_value_text" xsi:type="string">default_value_text%isolation%</data>
58+
<data name="sectionName" xsi:type="string">attributes</data>
5859
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsRequired" />
5960
</variation>
6061
<variation name="CreateProductAttributeEntityFromProductPageTestVariation4">

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<data name="productAttribute/data/is_searchable" xsi:type="string">Yes</data>
3333
<data name="productAttribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data>
3434
<data name="productAttribute/data/is_comparable" xsi:type="string">Yes</data>
35+
<data name="sectionName" xsi:type="string">product-details</data>
3536
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeInGrid" />
3637
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeForm" />
3738
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />
@@ -130,6 +131,7 @@
130131
<data name="assertProduct/data/name" xsi:type="string">Product name</data>
131132
<data name="assertProduct/data/sku" xsi:type="string">product-sku</data>
132133
<data name="assertProduct/data/price" xsi:type="string">35</data>
134+
<data name="sectionName" xsi:type="string">product-details</data>
133135
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeInGrid" />
134136
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeForm" />
135137
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />

dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ChosenOption extends SimpleElement
3434
*
3535
* @var string
3636
*/
37-
protected $selectBlock = "//ancestor::body//div[contains(@style,'display: block')]//*[contains(@id,'responseCntoptions')]";
37+
protected $selectBlock = "//ancestor::body//aside[contains(@class,'_show')]//*[contains(@id,'responseCntoptions')]";
3838
// @codingStandardsIgnoreEnd
3939

4040
/**

lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ protected function isValidType(LocalInterface $asset)
238238
return false;
239239
}
240240

241-
if ($type == self::ASSET_TYPE_HTML) {
242-
return $asset->getModule() !== '';
243-
}
244-
245241
return true;
246242
}
247243

lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Minification.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
3838
$this->fallback = $fallback;
3939
$this->minification = $minification;
4040
}
41+
4142
/**
4243
* Get path of file after using fallback rules
4344
*
@@ -51,10 +52,68 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
5152
*/
5253
public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
5354
{
55+
$fileExtension = pathinfo($file, PATHINFO_EXTENSION);
56+
57+
if ($fileExtension === 'js') {
58+
return $this->resolveJsMinification($type, $file, $area, $theme, $locale, $module);
59+
}
60+
61+
// Leave BC way of resolving
5462
$path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
63+
5564
if (!$path && $file != ($newFile = $this->minification->removeMinifiedSign($file))) {
5665
$path = $this->fallback->resolve($type, $newFile, $area, $theme, $locale, $module);
5766
}
67+
5868
return $path;
5969
}
70+
71+
/**
72+
* Get path of file after using fallback rules
73+
*
74+
* @param string $type
75+
* @param string $file
76+
* @param string|null $area
77+
* @param ThemeInterface|null $theme
78+
* @param string|null $locale
79+
* @param string|null $module
80+
* @return string|false
81+
*/
82+
private function resolveJsMinification(
83+
$type,
84+
$file,
85+
$area = null,
86+
ThemeInterface $theme = null,
87+
$locale = null,
88+
$module = null
89+
) {
90+
$path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
91+
92+
/**
93+
* Minified version as priority one
94+
*/
95+
if ($path && $this->minification->isMinifiedFilename($path)) {
96+
return $path;
97+
}
98+
99+
/**
100+
* If minification is disabled - return already found path
101+
*/
102+
if (!$this->minification->isEnabled('js')) {
103+
return $path;
104+
}
105+
106+
/**
107+
* Try to find minified version of file,
108+
* or return already found path
109+
*/
110+
return $this->fallback->resolve(
111+
$type,
112+
$this->minification->addMinifiedSign($file),
113+
$area,
114+
$theme,
115+
$locale,
116+
$module
117+
) ?: $path;
118+
}
60119
}

lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ public function testAddAssetWithInvalidType()
7777
$this->assertFalse($this->manager->addAsset($this->asset));
7878
}
7979

80-
public function testAddAssetWithHtmlTypeAndWithoutModule()
81-
{
82-
$this->asset->expects($this->once())
83-
->method('getContentType')
84-
->willReturn('html');
85-
$this->asset->expects($this->once())
86-
->method('getModule')
87-
->willReturn('');
88-
89-
$this->assertFalse($this->manager->addAsset($this->asset));
90-
}
91-
9280
public function testAddAssetWithExcludedFile()
9381
{
9482
$dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')

lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MinificationTest extends \PHPUnit_Framework_TestCase
2828
* @var \Magento\Framework\View\Asset\Minification|\PHPUnit_Framework_MockObject_MockObject
2929
*/
3030
protected $assetMinificationMock;
31+
3132
/**
3233
* {@inheritDoc}
3334
*/
@@ -98,4 +99,82 @@ public function resolveDataProvider()
9899
[false, 'file.min.css', 'file.min.css', false, false, 'found.css']
99100
];
100101
}
102+
103+
public function testResolveJs()
104+
{
105+
$this->resolverMock
106+
->expects($this->once())
107+
->method('resolve')
108+
->willReturn('/var/test.min.js');
109+
$this->assetMinificationMock->expects($this->once())
110+
->method('isMinifiedFilename')
111+
->willReturn(true);
112+
113+
$this->assertEquals('/var/test.min.js', $this->minification->resolve('', 'test.min.js'));
114+
}
115+
116+
public function testResolveJsWithDisabledMinification()
117+
{
118+
$this->resolverMock
119+
->expects($this->once())
120+
->method('resolve')
121+
->willReturn('/var/test.js');
122+
$this->assetMinificationMock->expects($this->once())
123+
->method('isMinifiedFilename')
124+
->willReturn(false);
125+
126+
$this->assertEquals('/var/test.js', $this->minification->resolve('', 'test.js'));
127+
}
128+
129+
public function testResolveJsToFindMinifiedVersion()
130+
{
131+
$this->resolverMock
132+
->expects($this->exactly(2))
133+
->method('resolve')
134+
->willReturnMap(
135+
[
136+
['', 'test.js', null, null, null, null, '/var/test.js'],
137+
['', 'test.min.js', null, null, null, null, '/var/test.min.js']
138+
]
139+
);
140+
$this->assetMinificationMock->expects($this->once())
141+
->method('isMinifiedFilename')
142+
->willReturn(false);
143+
$this->assetMinificationMock->expects($this->once())
144+
->method('isEnabled')
145+
->with('js')
146+
->willReturn(true);
147+
$this->assetMinificationMock->expects($this->once())
148+
->method('addMinifiedSign')
149+
->with('test.js')
150+
->willReturn('test.min.js');
151+
152+
$this->assertEquals('/var/test.min.js', $this->minification->resolve('', 'test.js'));
153+
}
154+
155+
public function testResolveJsToNotFindMinifiedVersion()
156+
{
157+
$this->resolverMock
158+
->expects($this->exactly(2))
159+
->method('resolve')
160+
->willReturnMap(
161+
[
162+
['', 'test.js', null, null, null, null, '/var/test.js'],
163+
['', 'test.min.js', null, null, null, null, false]
164+
]
165+
);
166+
$this->assetMinificationMock->expects($this->once())
167+
->method('isMinifiedFilename')
168+
->willReturn(false);
169+
$this->assetMinificationMock->expects($this->once())
170+
->method('isEnabled')
171+
->with('js')
172+
->willReturn(true);
173+
$this->assetMinificationMock->expects($this->once())
174+
->method('addMinifiedSign')
175+
->with('test.js')
176+
->willReturn('test.min.js');
177+
178+
$this->assertEquals('/var/test.js', $this->minification->resolve('', 'test.js'));
179+
}
101180
}

0 commit comments

Comments
 (0)