diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeIsRequired.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeIsRequired.php
index 4f80e101e73ae..f206bc5c97c0a 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeIsRequired.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeIsRequired.php
@@ -29,23 +29,27 @@ class AssertProductAttributeIsRequired extends AbstractConstraint
* @param CatalogProductEdit $catalogProductEdit
* @param CatalogProductAttribute $attribute
* @param InjectableFixture $product
+ * @param string $sectionName
* @return void
*/
public function processAssert(
CatalogProductIndex $catalogProductIndex,
CatalogProductEdit $catalogProductEdit,
CatalogProductAttribute $attribute,
- InjectableFixture $product
+ InjectableFixture $product,
+ $sectionName
) {
$catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
$productForm = $catalogProductEdit->getProductForm();
if (!$productForm->checkAttributeLabel($attribute)) {
- $productForm->openSection('attributes');
+ $productForm->openSection($sectionName);
}
$productForm->getAttributeElement($attribute)->setValue('');
$catalogProductEdit->getFormPageActions()->save();
- $failedFields = $productForm->getRequireNoticeFields($product);
- $actualMessage = $failedFields['attributes'][$attribute->getFrontendLabel()];
+ $validationErrors = $productForm->getSection($sectionName)->getValidationErrors();
+ $actualMessage = isset($validationErrors[$attribute->getFrontendLabel()])
+ ? $validationErrors[$attribute->getFrontendLabel()]
+ : '';
\PHPUnit_Framework_Assert::assertEquals(
self::REQUIRE_MESSAGE,
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.xml
index ad850405b54ef..8ac8fc29a2493 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.xml
@@ -55,6 +55,7 @@
Yes
attr_text_%isolation%
default_value_text%isolation%
+ attributes
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml
index 2884e23f535a3..d61ef9004b2f1 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml
@@ -32,6 +32,7 @@
Yes
Yes
Yes
+ product-details
@@ -130,6 +131,7 @@
Product name
product-sku
35
+ product-details
diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php
index 7866aa3432f9c..7a400056b93fa 100644
--- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php
+++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/ChosenOption.php
@@ -34,7 +34,7 @@ class ChosenOption extends SimpleElement
*
* @var string
*/
- protected $selectBlock = "//ancestor::body//div[contains(@style,'display: block')]//*[contains(@id,'responseCntoptions')]";
+ protected $selectBlock = "//ancestor::body//aside[contains(@class,'_show')]//*[contains(@id,'responseCntoptions')]";
// @codingStandardsIgnoreEnd
/**
diff --git a/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php b/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php
index 9ac43d3054f34..9320cef022881 100644
--- a/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php
+++ b/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php
@@ -238,10 +238,6 @@ protected function isValidType(LocalInterface $asset)
return false;
}
- if ($type == self::ASSET_TYPE_HTML) {
- return $asset->getModule() !== '';
- }
-
return true;
}
diff --git a/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Minification.php b/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Minification.php
index 03d51faea2c69..650a97061cda3 100644
--- a/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Minification.php
+++ b/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Minification.php
@@ -38,6 +38,7 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
$this->fallback = $fallback;
$this->minification = $minification;
}
+
/**
* Get path of file after using fallback rules
*
@@ -51,10 +52,68 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
*/
public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
{
+ $fileExtension = pathinfo($file, PATHINFO_EXTENSION);
+
+ if ($fileExtension === 'js') {
+ return $this->resolveJsMinification($type, $file, $area, $theme, $locale, $module);
+ }
+
+ // Leave BC way of resolving
$path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
+
if (!$path && $file != ($newFile = $this->minification->removeMinifiedSign($file))) {
$path = $this->fallback->resolve($type, $newFile, $area, $theme, $locale, $module);
}
+
return $path;
}
+
+ /**
+ * Get path of file after using fallback rules
+ *
+ * @param string $type
+ * @param string $file
+ * @param string|null $area
+ * @param ThemeInterface|null $theme
+ * @param string|null $locale
+ * @param string|null $module
+ * @return string|false
+ */
+ private function resolveJsMinification(
+ $type,
+ $file,
+ $area = null,
+ ThemeInterface $theme = null,
+ $locale = null,
+ $module = null
+ ) {
+ $path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
+
+ /**
+ * Minified version as priority one
+ */
+ if ($path && $this->minification->isMinifiedFilename($path)) {
+ return $path;
+ }
+
+ /**
+ * If minification is disabled - return already found path
+ */
+ if (!$this->minification->isEnabled('js')) {
+ return $path;
+ }
+
+ /**
+ * Try to find minified version of file,
+ * or return already found path
+ */
+ return $this->fallback->resolve(
+ $type,
+ $this->minification->addMinifiedSign($file),
+ $area,
+ $theme,
+ $locale,
+ $module
+ ) ?: $path;
+ }
}
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php
index 64d292d6cf258..b73fdec443f4b 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/Bundle/ManagerTest.php
@@ -77,18 +77,6 @@ public function testAddAssetWithInvalidType()
$this->assertFalse($this->manager->addAsset($this->asset));
}
- public function testAddAssetWithHtmlTypeAndWithoutModule()
- {
- $this->asset->expects($this->once())
- ->method('getContentType')
- ->willReturn('html');
- $this->asset->expects($this->once())
- ->method('getModule')
- ->willReturn('');
-
- $this->assertFalse($this->manager->addAsset($this->asset));
- }
-
public function testAddAssetWithExcludedFile()
{
$dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php
index 48646023685d2..b0d8357e372ed 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php
@@ -28,6 +28,7 @@ class MinificationTest extends \PHPUnit_Framework_TestCase
* @var \Magento\Framework\View\Asset\Minification|\PHPUnit_Framework_MockObject_MockObject
*/
protected $assetMinificationMock;
+
/**
* {@inheritDoc}
*/
@@ -98,4 +99,82 @@ public function resolveDataProvider()
[false, 'file.min.css', 'file.min.css', false, false, 'found.css']
];
}
+
+ public function testResolveJs()
+ {
+ $this->resolverMock
+ ->expects($this->once())
+ ->method('resolve')
+ ->willReturn('/var/test.min.js');
+ $this->assetMinificationMock->expects($this->once())
+ ->method('isMinifiedFilename')
+ ->willReturn(true);
+
+ $this->assertEquals('/var/test.min.js', $this->minification->resolve('', 'test.min.js'));
+ }
+
+ public function testResolveJsWithDisabledMinification()
+ {
+ $this->resolverMock
+ ->expects($this->once())
+ ->method('resolve')
+ ->willReturn('/var/test.js');
+ $this->assetMinificationMock->expects($this->once())
+ ->method('isMinifiedFilename')
+ ->willReturn(false);
+
+ $this->assertEquals('/var/test.js', $this->minification->resolve('', 'test.js'));
+ }
+
+ public function testResolveJsToFindMinifiedVersion()
+ {
+ $this->resolverMock
+ ->expects($this->exactly(2))
+ ->method('resolve')
+ ->willReturnMap(
+ [
+ ['', 'test.js', null, null, null, null, '/var/test.js'],
+ ['', 'test.min.js', null, null, null, null, '/var/test.min.js']
+ ]
+ );
+ $this->assetMinificationMock->expects($this->once())
+ ->method('isMinifiedFilename')
+ ->willReturn(false);
+ $this->assetMinificationMock->expects($this->once())
+ ->method('isEnabled')
+ ->with('js')
+ ->willReturn(true);
+ $this->assetMinificationMock->expects($this->once())
+ ->method('addMinifiedSign')
+ ->with('test.js')
+ ->willReturn('test.min.js');
+
+ $this->assertEquals('/var/test.min.js', $this->minification->resolve('', 'test.js'));
+ }
+
+ public function testResolveJsToNotFindMinifiedVersion()
+ {
+ $this->resolverMock
+ ->expects($this->exactly(2))
+ ->method('resolve')
+ ->willReturnMap(
+ [
+ ['', 'test.js', null, null, null, null, '/var/test.js'],
+ ['', 'test.min.js', null, null, null, null, false]
+ ]
+ );
+ $this->assetMinificationMock->expects($this->once())
+ ->method('isMinifiedFilename')
+ ->willReturn(false);
+ $this->assetMinificationMock->expects($this->once())
+ ->method('isEnabled')
+ ->with('js')
+ ->willReturn(true);
+ $this->assetMinificationMock->expects($this->once())
+ ->method('addMinifiedSign')
+ ->with('test.js')
+ ->willReturn('test.min.js');
+
+ $this->assertEquals('/var/test.js', $this->minification->resolve('', 'test.js'));
+ }
}