Skip to content

Commit ef08e26

Browse files
author
Alex Paliarush
committed
MAGETWO-58335: [Backport] - Can't view uploaded image - for 2.1
1 parent b88a824 commit ef08e26

File tree

10 files changed

+35
-5
lines changed

10 files changed

+35
-5
lines changed

app/code/Magento/Customer/Controller/Adminhtml/File/Address/Upload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function execute()
114114
*/
115115
private function convertFilesArray()
116116
{
117-
foreach($_FILES['address'] as $itemKey => $item) {
117+
foreach ($_FILES['address'] as $itemKey => $item) {
118118
foreach ($item as $value) {
119119
if (is_array($value)) {
120120
$_FILES['address'][$itemKey] = [

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Magento\Customer\Model\Metadata\Form;
1414
use Magento\Framework\Exception\LocalizedException;
1515

16+
/**
17+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18+
*/
1619
class Save extends \Magento\Customer\Controller\Adminhtml\Index
1720
{
1821
/**

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
130130
* @param FileProcessorFactory $fileProcessorFactory
131131
* @param array $meta
132132
* @param array $data
133+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
133134
*/
134135
public function __construct(
135136
$name,
@@ -221,6 +222,7 @@ public function getData()
221222
*
222223
* @param Customer|Address $entity
223224
* @param array $entityData
225+
* @return void
224226
*/
225227
private function overrideFileUploaderData($entity, array &$entityData)
226228
{
@@ -244,6 +246,7 @@ private function overrideFileUploaderData($entity, array &$entityData)
244246
* @param Attribute $attribute
245247
* @param array $customerData
246248
* @return array
249+
* @SuppressWarnings(PHPMD.NPathComplexity)
247250
*/
248251
private function getFileUploaderData(
249252
Type $entityType,
@@ -343,6 +346,7 @@ protected function getAttributesMeta(Type $entityType)
343346
* @param Type $entityType
344347
* @param AbstractAttribute $attribute
345348
* @param array $config
349+
* @return void
346350
*/
347351
private function overrideFileUploaderMetadata(
348352
Type $entityType,
@@ -360,7 +364,12 @@ private function overrideFileUploaderMetadata(
360364

361365
if (isset($config['validation']['file_extensions'])) {
362366
$allowedExtensions = explode(',', $config['validation']['file_extensions']);
363-
array_walk($allowedExtensions, function(&$value) { $value = strtolower(trim($value)); });
367+
array_walk(
368+
$allowedExtensions,
369+
function (&$value) {
370+
$value = strtolower(trim($value));
371+
}
372+
);
364373
}
365374

366375
$allowedExtensions = implode(' ', $allowedExtensions);

app/code/Magento/Customer/Model/FileProcessor.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Magento\MediaStorage\Model\File\Uploader;
1717
use Magento\MediaStorage\Model\File\UploaderFactory;
1818

19+
/**
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
*/
1922
class FileProcessor
2023
{
2124
/**

app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ public function testNoPostValues()
208208
$this->assertSame($this->resultRedirect, $this->model->execute());
209209
}
210210

211+
/**
212+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
213+
*/
211214
public function testGeneralSave()
212215
{
213216
$customerId = 1;

app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ function ($origName) {
367367
return [$attributeMock, $attributeBooleanMock];
368368
}
369369

370+
/**
371+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
372+
*/
370373
public function testGetData()
371374
{
372375
$customer = $this->getMockBuilder('Magento\Customer\Model\Customer')
@@ -476,6 +479,9 @@ public function testGetData()
476479
);
477480
}
478481

482+
/**
483+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
484+
*/
479485
public function testGetDataWithCustomerFormData()
480486
{
481487
$customerId = 11;
@@ -589,6 +595,9 @@ public function testGetDataWithCustomerFormData()
589595
$this->assertEquals([$customerId => $customerFormData], $dataProvider->getData());
590596
}
591597

598+
/**
599+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
600+
*/
592601
public function testGetDataWithCustomAttributeImage()
593602
{
594603
$customerId = 1;
@@ -810,6 +819,9 @@ public function testGetDataWithCustomAttributeImageNoData()
810819
$this->assertEquals($expectedData, $dataProvider->getData());
811820
}
812821

822+
/**
823+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
824+
*/
813825
public function testGetAttributesMetaWithCustomAttributeImage()
814826
{
815827
$maxFileSize = 1000;

app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ private function getModel($entityTypeCode, array $allowedExtensions = [])
7575
return $model;
7676
}
7777

78-
7978
public function testGetStat()
8079
{
8180
$fileName = '/filename.ext1';

app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ public function testUpload()
179179
->method('getValidationRules')
180180
->willReturn([$validationRuleMock]);
181181

182-
183182
$model = $this->getModel(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 'customer');
184183
$this->assertEquals($expectedResult, $model->upload());
185184
}

app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class FileTest extends AbstractFormTestCase
1515
{
1616
const ENTITY_TYPE = 0;
17+
1718
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Url\EncoderInterface */
1819
protected $urlEncode;
1920

dev/tests/static/testsuite/Magento/Test/Legacy/ModuleDBChangeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ModuleDBChangeTest extends \PHPUnit_Framework_TestCase
1515
/**
1616
* @var string
1717
*/
18-
protected static $changedFilesPattern = __DIR__ . '/../_files/changed_files*';
18+
protected static $changedFilesPattern = '';
1919

2020
/**
2121
* @var string
@@ -27,6 +27,7 @@ class ModuleDBChangeTest extends \PHPUnit_Framework_TestCase
2727
*/
2828
public static function setUpBeforeClass()
2929
{
30+
self::$changedFilesPattern = __DIR__ . '/../_files/changed_files*';
3031
foreach (glob(self::$changedFilesPattern) as $changedFile) {
3132
self::$changedFileList .= file_get_contents($changedFile) . PHP_EOL;
3233
}

0 commit comments

Comments
 (0)