diff --git a/app/code/Magento/Deploy/Model/DeployManager.php b/app/code/Magento/Deploy/Model/DeployManager.php index 6dbb4cf48ba3c..81c08d0ad2621 100644 --- a/app/code/Magento/Deploy/Model/DeployManager.php +++ b/app/code/Magento/Deploy/Model/DeployManager.php @@ -108,6 +108,9 @@ public function deploy() { if ($this->idDryRun) { $this->output->writeln('Dry run. Nothing will be recorded to the target directory.'); + } else { + $version = (new \DateTime())->getTimestamp(); + $this->versionStorage->save($version); } /** @var DeployStrategyProvider $strategyProvider */ @@ -133,7 +136,10 @@ public function deploy() } $this->minifyTemplates(); - $this->saveDeployedVersion(); + + if (!$this->idDryRun) { + $this->output->writeln("New version of deployed files: {$version}"); + } return $result; } @@ -197,17 +203,4 @@ private function getProcessesAmount() { return isset($this->options[Options::JOBS_AMOUNT]) ? (int)$this->options[Options::JOBS_AMOUNT] : 0; } - - /** - * Save version of deployed files - * @return void - */ - private function saveDeployedVersion() - { - if (!$this->idDryRun) { - $version = (new \DateTime())->getTimestamp(); - $this->output->writeln("New version of deployed files: {$version}"); - $this->versionStorage->save($version); - } - } } diff --git a/app/code/Magento/Theme/etc/config.xml b/app/code/Magento/Theme/etc/config.xml index bd0db014a781b..b55b2c1d2735b 100644 --- a/app/code/Magento/Theme/etc/config.xml +++ b/app/code/Magento/Theme/etc/config.xml @@ -62,5 +62,10 @@ Disallow: /*SID= + + + 1 + + diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ImageTest.php index 04dac68782f81..9f2196ac19ca1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ImageTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ImageTest.php @@ -46,7 +46,7 @@ public function testSaveFilePlaceholder($model) public function testGetUrlPlaceholder($model) { $this->assertStringMatchesFormat( - 'http://localhost/pub/static/frontend/%s/Magento_Catalog/images/product/placeholder/image.jpg', + 'http://localhost/pub/static/%s/frontend/%s/Magento_Catalog/images/product/placeholder/image.jpg', $model->getUrl() ); } diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php index 07b55f5e9aeaf..fdb63a875282e 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php @@ -42,7 +42,7 @@ public function testGetConfig() public function testGetConfigCssUrls() { $config = $this->_model->getConfig(); - $publicPathPattern = 'http://localhost/pub/static/adminhtml/Magento/backend/en_US/mage/%s'; + $publicPathPattern = 'http://localhost/pub/static/%s/adminhtml/Magento/backend/en_US/mage/%s'; $this->assertStringMatchesFormat($publicPathPattern, $config->getPopupCss()); $this->assertStringMatchesFormat($publicPathPattern, $config->getContentCss()); } diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php index a3baf43c54949..523058759fa87 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php @@ -57,7 +57,7 @@ public function testGetFilesCollection() $this->assertInstanceOf('Magento\Framework\DataObject', $item); $this->assertStringEndsWith('/1.swf', $item->getUrl()); $this->assertStringMatchesFormat( - 'http://%s/static/adminhtml/%s/%s/Magento_Cms/images/placeholder_thumbnail.jpg', + 'http://%s/static/%s/adminhtml/%s/%s/Magento_Cms/images/placeholder_thumbnail.jpg', $item->getThumbUrl() ); return; diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php index f330749fa6418..a4ee39948e118 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php @@ -283,6 +283,7 @@ public function cssDirectiveDataProvider() * @magentoComponentsDir Magento/Email/Model/_files/design * @magentoAppIsolation enabled * @magentoDbIsolation enabled + * @magentoConfigFixture default_store dev/static/sign 0 * @dataProvider inlinecssDirectiveDataProvider * * @param string $templateText diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index a47c1aa0d8d9a..dab0750661eec 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -122,7 +122,7 @@ public function testGetProcessedTemplate() ->getArea(Area::AREA_FRONTEND) ->load(); - $expectedViewUrl = 'static/frontend/Magento/blank/en_US/Magento_Theme/favicon.ico'; + $expectedViewUrl = '/frontend/Magento/blank/en_US/Magento_Theme/favicon.ico'; $this->model->setDesignConfig([ 'area' => 'frontend', 'store' => $this->objectManager->get('Magento\Store\Model\StoreManagerInterface') @@ -578,7 +578,6 @@ public function testGetProcessedTemplateSubject() ->getArea(Area::AREA_FRONTEND) ->load(); - $expectedViewUrl = 'static/frontend/Magento/blank/en_US/Magento_Theme/favicon.ico'; $this->model->setTemplateSubject('{{view url="Magento_Theme::favicon.ico"}}'); $this->model->setDesignConfig([ 'area' => 'frontend', @@ -588,10 +587,16 @@ public function testGetProcessedTemplateSubject() ]); $this->setNotDefaultThemeForFixtureStore(); - $this->assertStringEndsNotWith($expectedViewUrl, $this->model->getProcessedTemplateSubject([])); + $this->assertStringMatchesFormat( + '%s/frontend/Magento/luma/en_US/Magento_Theme/favicon.ico', + $this->model->getProcessedTemplateSubject([]) + ); $this->setDefaultThemeForFixtureStore(); - $this->assertStringEndsWith($expectedViewUrl, $this->model->getProcessedTemplateSubject([])); + $this->assertStringMatchesFormat( + '%s/frontend/Magento/blank/en_US/Magento_Theme/favicon.ico', + $this->model->getProcessedTemplateSubject([]) + ); } /** @@ -605,7 +610,7 @@ public function testGetDefaultEmailLogo() ->load(); $this->assertStringEndsWith( - 'static/frontend/Magento/luma/en_US/Magento_Email/logo_email.png', + '/frontend/Magento/luma/en_US/Magento_Email/logo_email.png', $this->model->getDefaultEmailLogo() ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php index de6031e9db0e3..260311b48b1ec 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php @@ -477,7 +477,10 @@ public function testGetUrl() public function testGetViewFileUrl() { $actualResult = $this->_block->getViewFileUrl('css/styles.css'); - $this->assertStringMatchesFormat('http://localhost/pub/static/frontend/%s/en_US/css/styles.css', $actualResult); + $this->assertStringMatchesFormat( + 'http://localhost/pub/static/%s/frontend/%s/en_US/css/styles.css', + $actualResult + ); } public function testGetModuleName() diff --git a/dev/tests/integration/testsuite/Magento/Review/Controller/ProductTest.php b/dev/tests/integration/testsuite/Magento/Review/Controller/ProductTest.php index 57cf616fd7c7a..967650a85271e 100644 --- a/dev/tests/integration/testsuite/Magento/Review/Controller/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Review/Controller/ProductTest.php @@ -16,7 +16,7 @@ public function testListActionDesign($productId, $expectedDesign) $this->getRequest()->setParam('id', $productId); $this->dispatch('review/product/listAction'); $result = $this->getResponse()->getBody(); - $this->assertContains("static/frontend/{$expectedDesign}/en_US/Magento_Theme/favicon.ico", $result); + $this->assertContains("/frontend/{$expectedDesign}/en_US/Magento_Theme/favicon.ico", $result); } /** diff --git a/dev/tests/integration/testsuite/Magento/Variable/Model/Variable/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Variable/Model/Variable/ConfigTest.php index 36cdd82450ec5..4828cb68190e1 100644 --- a/dev/tests/integration/testsuite/Magento/Variable/Model/Variable/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Variable/Model/Variable/ConfigTest.php @@ -21,15 +21,16 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Variable\Model\Variable\Config' + \Magento\Variable\Model\Variable\Config::class ); } public function testGetWysiwygJsPluginSrc() { $src = $this->_model->getWysiwygJsPluginSrc(); - $this->assertStringStartsWith('http://localhost/pub/static/adminhtml/Magento/backend/en_US/mage/adminhtml/', - $src); - $this->assertStringEndsWith('editor_plugin.js', $src); + $this->assertStringMatchesFormat( + 'http://localhost/pub/static/%s/adminhtml/Magento/backend/en_US/mage/adminhtml/%s/editor_plugin.js', + $src + ); } } diff --git a/dev/tests/integration/testsuite/Magento/Widget/Model/Widget/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Widget/Model/Widget/ConfigTest.php index 42143e8a4ce4d..3e13f8daf5a60 100644 --- a/dev/tests/integration/testsuite/Magento/Widget/Model/Widget/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Widget/Model/Widget/ConfigTest.php @@ -43,8 +43,10 @@ public function testGetPluginSettings() $this->assertArrayHasKey('widget_window_url', $settings); $jsFilename = $settings['widget_plugin_src']; - $this->assertStringStartsWith('http://localhost/pub/static/adminhtml/Magento/backend/en_US/', $jsFilename); - $this->assertStringEndsWith('editor_plugin.js', $jsFilename); + $this->assertStringMatchesFormat( + 'http://localhost/pub/static/%s/adminhtml/Magento/backend/en_US/%s/editor_plugin.js', + $jsFilename + ); $this->assertInternalType('array', $settings['widget_placeholders']); diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php new file mode 100644 index 0000000000000..7184c713bbd48 --- /dev/null +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ViewFactoryTest.php @@ -0,0 +1,94 @@ +objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->model = new \Magento\Framework\Config\ViewFactory($this->objectManager); + $this->theme = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class); + $this->view = $this->getMock(\Magento\Framework\Config\View::class, [], [], '', false); + } + + public function testCreate() + { + $this->objectManager->expects($this->once()) + ->method('create') + ->with(\Magento\Framework\Config\View::class, []) + ->willReturn($this->view); + $this->assertEquals($this->view, $this->model->create()); + } + + public function testCreateWithArguments() + { + /** @var \Magento\Theme\Model\View\Design|\PHPUnit_Framework_MockObject_MockObject $design */ + $design = $this->getMock(\Magento\Theme\Model\View\Design::class, [], [], '', false); + $design->expects($this->once()) + ->method('setDesignTheme') + ->with($this->theme, self::AREA); + + /** @var \Magento\Framework\Config\FileResolver|\PHPUnit_Framework_MockObject_MockObject $fileResolver */ + $fileResolver = $this->getMock(\Magento\Framework\Config\FileResolver::class, [], [], '', false); + + $valueMap = [ + [\Magento\Theme\Model\View\Design::class, [], $design], + [\Magento\Framework\Config\FileResolver::class, ['designInterface' => $design], $fileResolver], + [\Magento\Framework\Config\View::class, ['fileResolver' => $fileResolver], $this->view], + ]; + $this->objectManager->expects($this->exactly(3)) + ->method('create') + ->willReturnMap($valueMap); + + $this->assertEquals($this->view, $this->model->create($this->getArguments())); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage wrong theme doesn't implement ThemeInterface + */ + public function testCreateException() + { + $this->model->create([ + 'themeModel' => 'wrong theme', + 'area' => self::AREA + ]); + } + + /** + * @return array + */ + protected function getArguments() + { + return [ + 'themeModel' => $this->theme, + 'area' => self::AREA + ]; + } +} diff --git a/lib/internal/Magento/Framework/Config/ViewFactory.php b/lib/internal/Magento/Framework/Config/ViewFactory.php index 2df147b0fa626..7adff4f50cf59 100644 --- a/lib/internal/Magento/Framework/Config/ViewFactory.php +++ b/lib/internal/Magento/Framework/Config/ViewFactory.php @@ -26,12 +26,38 @@ public function __construct(ObjectManagerInterface $objectManager) } /** + * Create new view object + * + * @param array $arguments * @return \Magento\Framework\Config\View + * @throws \Magento\Framework\Exception\LocalizedException */ - public function create() + public function create(array $arguments = []) { + $viewConfigArguments = []; + + if (isset($arguments['themeModel']) && isset($arguments['area'])) { + if (!($arguments['themeModel'] instanceof \Magento\Framework\View\Design\ThemeInterface)) { + throw new \Magento\Framework\Exception\LocalizedException( + new \Magento\Framework\Phrase('%1 doesn\'t implement ThemeInterface', [$arguments['themeModel']]) + ); + } + /** @var \Magento\Theme\Model\View\Design $design */ + $design = $this->objectManager->create(\Magento\Theme\Model\View\Design::class); + $design->setDesignTheme($arguments['themeModel'], $arguments['area']); + /** @var \Magento\Framework\Config\FileResolver $fileResolver */ + $fileResolver = $this->objectManager->create( + \Magento\Framework\Config\FileResolver::class, + [ + 'designInterface' => $design, + ] + ); + $viewConfigArguments['fileResolver'] = $fileResolver; + } + return $this->objectManager->create( - 'Magento\Framework\Config\View' + \Magento\Framework\Config\View::class, + $viewConfigArguments ); } } diff --git a/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php b/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php index 4830cf2690097..0b072eddf08ce 100644 --- a/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php +++ b/lib/internal/Magento/Framework/View/Asset/Bundle/Manager.php @@ -43,6 +43,7 @@ class Manager /** @var array */ public static $availableTypes = [self::ASSET_TYPE_JS, self::ASSET_TYPE_HTML]; + /** * @var Asset\Minification */ @@ -129,7 +130,7 @@ protected function isExcludedFile($filePath, $asset) /** @var $asset LocalInterface */ $filePathInfo = $this->splitPath($filePath); if ($filePathInfo && $this->compareModules($filePathInfo, $asset)) { - return $asset->getSourceFile() == $filePathInfo['excludedPath']; + return $asset->getFilePath() == $filePathInfo['excludedPath']; } return false; } @@ -239,14 +240,9 @@ protected function isValidType(LocalInterface $asset) return false; } - if ($type == self::ASSET_TYPE_HTML) { - return $asset->getModule() !== ''; - } - return true; } - /** * Flush bundle * diff --git a/lib/internal/Magento/Framework/View/Config.php b/lib/internal/Magento/Framework/View/Config.php index c8960cb37845e..917f632323ea0 100644 --- a/lib/internal/Magento/Framework/View/Config.php +++ b/lib/internal/Magento/Framework/View/Config.php @@ -57,16 +57,25 @@ public function __construct( public function getViewConfig(array $params = []) { $this->assetRepo->updateDesignParams($params); - /** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */ - $currentTheme = $params['themeModel']; - $key = $currentTheme->getCode(); - if (isset($this->viewConfigs[$key])) { - return $this->viewConfigs[$key]; + $viewConfigParams = []; + + if (isset($params['themeModel'])) { + /** @var \Magento\Framework\View\Design\ThemeInterface $currentTheme */ + $currentTheme = $params['themeModel']; + $key = $currentTheme->getCode(); + if (isset($this->viewConfigs[$key])) { + return $this->viewConfigs[$key]; + } + $viewConfigParams['themeModel'] = $currentTheme; } + $viewConfigParams['area'] = (isset($params['area'])) ? $params['area'] : null; - $config = $this->viewConfigFactory->create(); + /** @var \Magento\Framework\Config\View $config */ + $config = $this->viewConfigFactory->create($viewConfigParams); - $this->viewConfigs[$key] = $config; + if (isset($key)) { + $this->viewConfigs[$key] = $config; + } return $config; } } 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..aef2270c0957f 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,8 +52,9 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini */ public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null) { + $file = $this->minification->addMinifiedSign($file); $path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module); - if (!$path && $file != ($newFile = $this->minification->removeMinifiedSign($file))) { + if (!$path && ($newFile = $this->minification->removeMinifiedSign($file))) { $path = $this->fallback->resolve($type, $newFile, $area, $theme, $locale, $module); } return $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 a9d06fb33309a..cb161a5c204df 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 @@ -30,23 +30,23 @@ class ManagerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\View\Asset\Minification|\PHPUnit_Framework_MockObject_MockObject */ private $minificationMock; - public function setUp() + protected function setUp() { - $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->bundle = $this->getMockBuilder('Magento\Framework\View\Asset\Bundle') + $this->bundle = $this->getMockBuilder(\Magento\Framework\View\Asset\Bundle::class) ->disableOriginalConstructor() ->getMock(); - $this->bundleConfig = $this->getMockBuilder('Magento\Framework\View\Asset\Bundle\ConfigInterface') + $this->bundleConfig = $this->getMockBuilder(\Magento\Framework\View\Asset\Bundle\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->assetConfig = $this->getMockBuilder('Magento\Framework\View\Asset\ConfigInterface') + $this->assetConfig = $this->getMockBuilder(\Magento\Framework\View\Asset\ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); $this->asset = $this->getMockForAbstractClass( - 'Magento\Framework\View\Asset\LocalInterface', + \Magento\Framework\View\Asset\LocalInterface::class, [], '', false, @@ -55,7 +55,7 @@ public function setUp() ['getContentType'] ); - $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->minificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); @@ -77,27 +77,15 @@ 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') + $dirRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); - $configView = $this->getMockBuilder('Magento\Framework\Config\View') + $configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->setMockClassName('configView') ->disableOriginalConstructor() ->getMock(); @@ -114,6 +102,9 @@ public function testAddAssetWithExcludedFile() $this->asset->expects($this->atLeastOnce()) ->method('getSourceFile') ->willReturn('source/file.min.js'); + $this->asset->expects($this->atLeastOnce()) + ->method('getFilePath') + ->willReturn('source/file.min.js'); $this->filesystem->expects($this->once()) ->method('getDirectoryRead') ->with(\Magento\Framework\App\Filesystem\DirectoryList::APP) @@ -131,13 +122,13 @@ public function testAddAssetWithExcludedFile() public function testAddAssetWithExcludedDirectory() { - $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $dirRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); - $configView = $this->getMockBuilder('Magento\Framework\Config\View') + $configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->disableOriginalConstructor() ->getMock(); @@ -183,13 +174,13 @@ public function testAddAssetWithExcludedDirectory() public function testAddAsset() { - $dirRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') + $dirRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + $context = $this->getMockBuilder(\Magento\Framework\View\Asset\File\FallbackContext::class) ->disableOriginalConstructor() ->getMock(); - $configView = $this->getMockBuilder('Magento\Framework\Config\View') + $configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) ->disableOriginalConstructor() ->getMock(); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php index 8247cd83bab4e..4295b5d3e24e7 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php @@ -6,7 +6,6 @@ namespace Magento\Framework\View\Test\Unit; -use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; class ConfigTest extends \PHPUnit_Framework_TestCase @@ -27,11 +26,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->repositoryMock = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->viewConfigFactoryMock = $this->getMock('Magento\Framework\Config\ViewFactory', [], [], '', false); + $this->repositoryMock = $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false); + $this->viewConfigFactoryMock = $this->getMock(\Magento\Framework\Config\ViewFactory::class, [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->config = $this->objectManagerHelper->getObject( - 'Magento\Framework\View\Config', + \Magento\Framework\View\Config::class, [ 'assetRepo' => $this->repositoryMock, 'viewConfigFactory' => $this->viewConfigFactoryMock @@ -41,8 +40,10 @@ protected function setUp() public function testGetViewConfig() { + $themeCode = 2; + $themeMock = $this->getMock( - 'Magento\Theme\Model\Theme', + \Magento\Theme\Model\Theme::class, ['getCode'], [], '', @@ -50,18 +51,21 @@ public function testGetViewConfig() ); $themeMock->expects($this->atLeastOnce()) ->method('getCode') - ->will($this->returnValue(2)); - $params = ['themeModel' => $themeMock]; + ->will($this->returnValue($themeCode)); + $params = [ + 'themeModel' => $themeMock, + 'area' => 'frontend' + ]; $this->repositoryMock->expects($this->atLeastOnce()) ->method('updateDesignParams') ->with($this->equalTo($params)) ->will($this->returnSelf()); - $configViewMock = $this->getMock('Magento\Framework\Config\View', [], [], '', false); + $configViewMock = $this->getMock(\Magento\Framework\Config\View::class, [], [], '', false); $this->viewConfigFactoryMock->expects($this->once()) ->method('create') ->willReturn($configViewMock); - $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params)); + $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params)); // lazy load test - $this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params)); + $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params)); } } 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..3f461f1602247 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,17 +28,18 @@ class MinificationTest extends \PHPUnit_Framework_TestCase * @var \Magento\Framework\View\Asset\Minification|\PHPUnit_Framework_MockObject_MockObject */ protected $assetMinificationMock; + /** * {@inheritDoc} */ protected function setUp() { $this->resolverMock = $this - ->getMockBuilder('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface') + ->getMockBuilder(\Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->assetMinificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') + $this->assetMinificationMock = $this->getMockBuilder(\Magento\Framework\View\Asset\Minification::class) ->disableOriginalConstructor() ->getMock(); @@ -69,21 +70,20 @@ public function testResolve( $this->assetMinificationMock ->expects($this->any()) ->method('isEnabled') - ->willReturnMap([['css', $isEnabled]]); + ->willReturn($isEnabled); $this->assetMinificationMock ->expects($this->any()) - ->method('removeMinifiedSign') + ->method('addMinifiedSign') ->with($requested) ->willReturn($alternative); $this->resolverMock ->expects($this->any()) ->method('resolve') - ->withConsecutive( - ['', $requested, null, null, null, null], - ['', $alternative, null, null, null, null] - ) - ->willReturnOnConsecutiveCalls($resolvedOriginal, $resolvedAlternative); + ->willReturnMap([ + ['', $requested, null, null, null, null, $resolvedOriginal], + ['', $alternative, null, null, null, null, $resolvedAlternative] + ]); $this->assertEquals($expected, $this->minification->resolve('', $requested)); } @@ -94,8 +94,10 @@ public function testResolve( public function resolveDataProvider() { return [ - [true, 'file.min.css', 'file.css', 'found.css', false, 'found.css'], - [false, 'file.min.css', 'file.min.css', false, false, 'found.css'] + [true, 'file.css', 'file.min.css', 'found.min.css', false, 'found.min.css'], + [false, 'file.min.css', 'file.min.css', false, false, 'found.css'], + [true, 'file.js', 'file.min.js', 'found.min.js', false, 'found.min.js'], + [false, 'file.min.js', 'file.min.js', false, false, 'found.js'], ]; } }