Skip to content

Commit ec436ce

Browse files
author
Momotenko,Natalia(nmomotenko)
committed
Merge pull request #525 from magento-south/BUGS
[SOUTH] Bugfixes + TD
2 parents d349299 + d851e75 commit ec436ce

File tree

26 files changed

+657
-465
lines changed

26 files changed

+657
-465
lines changed

app/code/Magento/Config/Model/Config/Backend/File.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ protected function _addWhetherScopeInfo()
179179
protected function _getUploadDir()
180180
{
181181
$fieldConfig = $this->getFieldConfig();
182-
/* @var $fieldConfig \Magento\Framework\Simplexml\Element */
183182

184183
if (!array_key_exists('upload_dir', $fieldConfig)) {
185184
throw new \Magento\Framework\Exception\LocalizedException(
@@ -189,13 +188,15 @@ protected function _getUploadDir()
189188

190189
if (is_array($fieldConfig['upload_dir'])) {
191190
$uploadDir = $fieldConfig['upload_dir']['value'];
192-
if (array_key_exists('scope_info', $fieldConfig['upload_dir']) && $fieldConfig['upload_dir']['scope_info']
191+
if (
192+
array_key_exists('scope_info', $fieldConfig['upload_dir'])
193+
&& $fieldConfig['upload_dir']['scope_info']
193194
) {
194195
$uploadDir = $this->_appendScopeInfo($uploadDir);
195196
}
196197

197198
if (array_key_exists('config', $fieldConfig['upload_dir'])) {
198-
$uploadDir = $this->_mediaDirectory->getAbsolutePath($uploadDir);
199+
$uploadDir = $this->getUploadDirPath($uploadDir);
199200
}
200201
} else {
201202
$uploadDir = (string)$fieldConfig['upload_dir'];
@@ -204,6 +205,17 @@ protected function _getUploadDir()
204205
return $uploadDir;
205206
}
206207

208+
/**
209+
* Retrieve upload directory path
210+
*
211+
* @param string $uploadDir
212+
* @return string
213+
*/
214+
protected function getUploadDirPath($uploadDir)
215+
{
216+
return $this->_mediaDirectory->getAbsolutePath($uploadDir);
217+
}
218+
207219
/**
208220
* Prepend path with scope info
209221
*

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,11 +1560,13 @@ public function setAccountData($accountData)
15601560
{
15611561
$customer = $this->getQuote()->getCustomer();
15621562
$form = $this->_createCustomerForm($customer);
1563+
$customerData = $this->customerMapper->toFlatArray($customer);
15631564

15641565
// emulate request
15651566
$request = $form->prepareRequest($accountData);
15661567
$data = $form->extractData($request);
15671568
$data = $form->restoreData($data);
1569+
$data = array_merge($customerData, array_filter($data));
15681570
$customer = $this->customerFactory->create();
15691571
$this->dataObjectHelper->populateWithArray(
15701572
$customer,
@@ -1574,7 +1576,6 @@ public function setAccountData($accountData)
15741576
$this->getQuote()->updateCustomerData($customer);
15751577
$data = [];
15761578

1577-
$customerData = $this->customerMapper->toFlatArray($customer);
15781579
foreach ($form->getAttributes() as $attribute) {
15791580
$code = sprintf('customer_%s', $attribute->getAttributeCode());
15801581
$data[$code] = isset($customerData[$attribute->getAttributeCode()])

app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16+
* @SuppressWarnings(PHPMD.TooManyFields)
1617
*/
1718
class CreateTest extends \PHPUnit_Framework_TestCase
1819
{
@@ -76,6 +77,11 @@ class CreateTest extends \PHPUnit_Framework_TestCase
7677
*/
7778
protected $accountManagementMock;
7879

80+
/**
81+
* @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
82+
*/
83+
protected $dataObjectHelper;
84+
7985
/**
8086
* @var \PHPUnit_Framework_MockObject_MockObject
8187
*/
@@ -171,6 +177,9 @@ protected function setUp()
171177
'',
172178
false
173179
);
180+
$this->dataObjectHelper = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper')
181+
->disableOriginalConstructor()
182+
->getMock();
174183

175184
$objectManagerHelper = new ObjectManagerHelper($this);
176185
$this->adminOrderCreate = $objectManagerHelper->getObject(
@@ -195,6 +204,7 @@ protected function setUp()
195204
'customerMapper' => $this->customerMapper,
196205
'objectFactory' => $this->objectFactory,
197206
'accountManagement' => $this->accountManagementMock,
207+
'dataObjectHelper' => $this->dataObjectHelper,
198208
]
199209
);
200210
}
@@ -242,8 +252,11 @@ public function testSetAccountData()
242252
->will($this->returnValue($this->getMock('Magento\Framework\App\RequestInterface')));
243253

244254
$customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false);
245-
$this->customerMapper->expects($this->any())->method('toFlatArray')
246-
->will($this->returnValue(['email' => 'user@example.com', 'group_id' => 1]));
255+
$this->customerMapper->expects($this->atLeastOnce())
256+
->method('toFlatArray')
257+
->willReturn(['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1]);
258+
259+
247260
$quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
248261
$quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
249262
$quoteMock->expects($this->once())
@@ -255,6 +268,13 @@ public function testSetAccountData()
255268
'customer_tax_class_id' => $taxClassId
256269
]
257270
);
271+
$this->dataObjectHelper->expects($this->once())
272+
->method('populateWithArray')
273+
->with(
274+
$customerMock,
275+
['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1],
276+
'\Magento\Customer\Api\Data\CustomerInterface'
277+
);
258278

259279
$this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
260280
$this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));

app/code/Magento/Theme/Controller/Adminhtml/Design/Config/FileUploader/Save.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@
88
use Magento\Backend\App\Action;
99
use Magento\Backend\App\Action\Context;
1010
use Magento\Framework\Controller\ResultFactory;
11-
use Magento\Theme\Model\Design\Config\FileUploader\ImageProcessor;
11+
use Magento\Theme\Model\Design\Config\FileUploader\FileProcessor;
1212

1313
class Save extends Action
1414
{
1515
/**
16-
* @var ImageProcessor
16+
* @var FileProcessor
1717
*/
18-
protected $imageProcessor;
18+
protected $fileProcessor;
1919

2020
/**
2121
* @param Context $context
22-
* @param ImageProcessor $imageProcessor
22+
* @param FileProcessor $fileProcessor
2323
*/
2424
public function __construct(
2525
Context $context,
26-
ImageProcessor $imageProcessor
26+
FileProcessor $fileProcessor
2727
) {
2828
parent::__construct($context);
29-
$this->imageProcessor = $imageProcessor;
29+
$this->fileProcessor = $fileProcessor;
3030
}
3131

3232
/**
3333
* @inheritDoc
3434
*/
3535
public function execute()
3636
{
37-
$result = $this->imageProcessor->saveToTmp(key($_FILES));
37+
$result = $this->fileProcessor->saveToTmp(key($_FILES));
3838
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
3939
}
4040
}

app/code/Magento/Theme/Model/Design/Backend/Favicon.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,36 @@
55
*/
66
namespace Magento\Theme\Model\Design\Backend;
77

8+
use Magento\Framework\Filesystem;
9+
810
class Favicon extends Image
911
{
1012
/**
11-
* @var string
13+
* The tail part of directory path for uploading
14+
*
15+
*/
16+
const UPLOAD_DIR = 'favicon';
17+
18+
/**
19+
* Return path to directory for upload file
20+
*
21+
* @return string
22+
* @throw \Magento\Framework\Exception\LocalizedException
23+
*/
24+
protected function _getUploadDir()
25+
{
26+
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(self::UPLOAD_DIR));
27+
}
28+
29+
/**
30+
* Makes a decision about whether to add info about the scope.
31+
*
32+
* @return boolean
1233
*/
13-
protected $uploadDir = 'favicon';
34+
protected function _addWhetherScopeInfo()
35+
{
36+
return true;
37+
}
1438

1539
/**
1640
* Getter for allowed extensions of uploaded files.

0 commit comments

Comments
 (0)