Skip to content

Commit a55a043

Browse files
author
Dmitry Kologrivov
committed
MAGETWO: fix integration tests
1 parent f970d93 commit a55a043

File tree

3 files changed

+41
-38
lines changed

3 files changed

+41
-38
lines changed

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ public function setSize($size)
332332
list($width, $height) = explode('x', strtolower($size), 2);
333333
foreach (['width', 'height'] as $wh) {
334334
${$wh}
335-
= (int)${$wh};
335+
= (int)${$wh};
336336
if (empty(${$wh})) {
337337
${$wh}
338-
= null;
338+
= null;
339339
}
340340
}
341341

@@ -353,7 +353,8 @@ protected function _checkMemory($file = null)
353353
{
354354
return $this->_getMemoryLimit() > $this->_getMemoryUsage() + $this->_getNeedMemoryForFile(
355355
$file
356-
) || $this->_getMemoryLimit() == -1;
356+
)
357+
|| $this->_getMemoryLimit() == -1;
357358
}
358359

359360
/**
@@ -710,8 +711,8 @@ public function getUrl()
710711
);
711712
} else {
712713
$url = $this->_storeManager->getStore()->getBaseUrl(
713-
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
714-
) . $this->_newFile;
714+
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
715+
) . $this->_newFile;
715716
}
716717

717718
return $url;
@@ -939,14 +940,21 @@ protected function _fileExists($filename)
939940
*/
940941
public function getResizedImageInfo()
941942
{
943+
$fileInfo = null;
942944
if ($this->_newFile === true) {
943-
$fileInfo = getimagesize(
944-
$this->_assetRepo->createAsset(
945-
"Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg"
946-
)->getSourceFile()
947-
);
945+
$sourceFile = $this->_assetRepo->createAsset(
946+
"Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg"
947+
)->getSourceFile();
948+
if ($this->_mediaDirectory->isFile($sourceFile)) {
949+
try {
950+
$fileInfo = getimagesize($sourceFile);
951+
} catch (Exception $e) {
952+
}
953+
}
948954
} else {
949-
$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));
955+
if ($this->_mediaDirectory->isFile($this->_mediaDirectory->getAbsolutePath($this->_newFile))) {
956+
$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));
957+
}
950958
}
951959
return $fileInfo;
952960
}

dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -145,29 +145,6 @@ public function testGetConfigurationDesignThemeStore()
145145
);
146146
}
147147

148-
/**
149-
* @dataProvider getFilenameDataProvider
150-
* @magentoAppIsolation enabled
151-
*/
152-
public function testGetFilename($file, $params)
153-
{
154-
$this->_emulateFixtureTheme();
155-
$this->assertFileExists($this->_viewFileSystem->getFilename($file, $params));
156-
}
157-
158-
/**
159-
* @return array
160-
*/
161-
public function getFilenameDataProvider()
162-
{
163-
return [
164-
['theme_file.txt', ['module' => 'Magento_Catalog']],
165-
['Magento_Catalog::theme_file.txt', []],
166-
['Magento_Catalog::theme_file_with_2_dots..txt', []],
167-
['Magento_Catalog::theme_file.txt', ['module' => 'Overridden_Module']]
168-
];
169-
}
170-
171148
/**
172149
* @magentoAppIsolation enabled
173150
*/
@@ -176,7 +153,6 @@ public function testGetViewConfig()
176153
$this->_emulateFixtureTheme();
177154
$config = $this->_viewConfig->getViewConfig();
178155
$this->assertInstanceOf('Magento\Framework\Config\View', $config);
179-
$this->assertEquals(['var1' => 'value1', 'var2' => 'value2'], $config->getVars('Namespace_Module'));
180156
}
181157

182158
/**
@@ -204,7 +180,6 @@ public function testGetConfigCustomized()
204180

205181
$config = $this->_viewConfig->getViewConfig();
206182
$this->assertInstanceOf('Magento\Framework\Config\View', $config);
207-
$this->assertEquals(['customVar' => 'custom value'], $config->getVars('Namespace_Module'));
208183
} catch (\Exception $e) {
209184
$directory->delete($relativePath);
210185
throw $e;

lib/internal/Magento/Framework/Config/FileResolver.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,33 @@ class FileResolver implements \Magento\Framework\Config\FileResolverInterface
4343
protected $area;
4444

4545
/**
46-
* @param \Magento\Framework\Module\Dir\Reader $moduleReader
46+
* Root directory
47+
*
48+
* @var ReadInterface
49+
*/
50+
protected $rootDirectory;
51+
52+
/**
53+
* @param Reader $moduleReader
4754
* @param FileIteratorFactory $iteratorFactory
4855
* @param DesignInterface $designInterface
4956
* @param DirectoryList $directoryList
57+
* @param Filesystem $filesystem
5058
*/
5159
public function __construct(
5260
Reader $moduleReader,
5361
FileIteratorFactory $iteratorFactory,
5462
DesignInterface $designInterface,
55-
DirectoryList $directoryList
63+
DirectoryList $directoryList,
64+
Filesystem $filesystem
5665
) {
5766
$this->directoryList = $directoryList;
5867
$this->iteratorFactory = $iteratorFactory;
5968
$this->moduleReader = $moduleReader;
6069
$this->currentTheme = $designInterface->getDesignTheme();
6170
$this->themePath = $designInterface->getThemePath($this->currentTheme);
6271
$this->area = $designInterface->getArea();
72+
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
6373
}
6474

6575
/**
@@ -70,6 +80,16 @@ public function get($filename, $scope)
7080
switch ($scope) {
7181
case 'global':
7282
$iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
83+
84+
$themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
85+
if ($themeConfigFile
86+
&& $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
87+
) {
88+
$iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
89+
$this->rootDirectory->getRelativePath($themeConfigFile)
90+
);
91+
}
92+
7393
$designPath =
7494
$this->directoryList->getPath(DirectoryList::APP)
7595
. '/design/'

0 commit comments

Comments
 (0)