Skip to content

Commit

Permalink
Merge pull request #525 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[SOUTH] Bugfixes + TD
  • Loading branch information
Momotenko,Natalia(nmomotenko) committed Apr 8, 2016
2 parents d349299 + d851e75 commit ec436ce
Show file tree
Hide file tree
Showing 26 changed files with 657 additions and 465 deletions.
18 changes: 15 additions & 3 deletions app/code/Magento/Config/Model/Config/Backend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ protected function _addWhetherScopeInfo()
protected function _getUploadDir()
{
$fieldConfig = $this->getFieldConfig();
/* @var $fieldConfig \Magento\Framework\Simplexml\Element */

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

if (is_array($fieldConfig['upload_dir'])) {
$uploadDir = $fieldConfig['upload_dir']['value'];
if (array_key_exists('scope_info', $fieldConfig['upload_dir']) && $fieldConfig['upload_dir']['scope_info']
if (
array_key_exists('scope_info', $fieldConfig['upload_dir'])
&& $fieldConfig['upload_dir']['scope_info']
) {
$uploadDir = $this->_appendScopeInfo($uploadDir);
}

if (array_key_exists('config', $fieldConfig['upload_dir'])) {
$uploadDir = $this->_mediaDirectory->getAbsolutePath($uploadDir);
$uploadDir = $this->getUploadDirPath($uploadDir);
}
} else {
$uploadDir = (string)$fieldConfig['upload_dir'];
Expand All @@ -204,6 +205,17 @@ protected function _getUploadDir()
return $uploadDir;
}

/**
* Retrieve upload directory path
*
* @param string $uploadDir
* @return string
*/
protected function getUploadDirPath($uploadDir)
{
return $this->_mediaDirectory->getAbsolutePath($uploadDir);
}

/**
* Prepend path with scope info
*
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Sales/Model/AdminOrder/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -1560,11 +1560,13 @@ public function setAccountData($accountData)
{
$customer = $this->getQuote()->getCustomer();
$form = $this->_createCustomerForm($customer);
$customerData = $this->customerMapper->toFlatArray($customer);

// emulate request
$request = $form->prepareRequest($accountData);
$data = $form->extractData($request);
$data = $form->restoreData($data);
$data = array_merge($customerData, array_filter($data));
$customer = $this->customerFactory->create();
$this->dataObjectHelper->populateWithArray(
$customer,
Expand All @@ -1574,7 +1576,6 @@ public function setAccountData($accountData)
$this->getQuote()->updateCustomerData($customer);
$data = [];

$customerData = $this->customerMapper->toFlatArray($customer);
foreach ($form->getAttributes() as $attribute) {
$code = sprintf('customer_%s', $attribute->getAttributeCode());
$data[$code] = isset($customerData[$attribute->getAttributeCode()])
Expand Down
24 changes: 22 additions & 2 deletions app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
class CreateTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -76,6 +77,11 @@ class CreateTest extends \PHPUnit_Framework_TestCase
*/
protected $accountManagementMock;

/**
* @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
*/
protected $dataObjectHelper;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
Expand Down Expand Up @@ -171,6 +177,9 @@ protected function setUp()
'',
false
);
$this->dataObjectHelper = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper')
->disableOriginalConstructor()
->getMock();

$objectManagerHelper = new ObjectManagerHelper($this);
$this->adminOrderCreate = $objectManagerHelper->getObject(
Expand All @@ -195,6 +204,7 @@ protected function setUp()
'customerMapper' => $this->customerMapper,
'objectFactory' => $this->objectFactory,
'accountManagement' => $this->accountManagementMock,
'dataObjectHelper' => $this->dataObjectHelper,
]
);
}
Expand Down Expand Up @@ -242,8 +252,11 @@ public function testSetAccountData()
->will($this->returnValue($this->getMock('Magento\Framework\App\RequestInterface')));

$customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false);
$this->customerMapper->expects($this->any())->method('toFlatArray')
->will($this->returnValue(['email' => 'user@example.com', 'group_id' => 1]));
$this->customerMapper->expects($this->atLeastOnce())
->method('toFlatArray')
->willReturn(['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1]);


$quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
$quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
$quoteMock->expects($this->once())
Expand All @@ -255,6 +268,13 @@ public function testSetAccountData()
'customer_tax_class_id' => $taxClassId
]
);
$this->dataObjectHelper->expects($this->once())
->method('populateWithArray')
->with(
$customerMock,
['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1],
'\Magento\Customer\Api\Data\CustomerInterface'
);

$this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
$this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Theme\Model\Design\Config\FileUploader\ImageProcessor;
use Magento\Theme\Model\Design\Config\FileUploader\FileProcessor;

class Save extends Action
{
/**
* @var ImageProcessor
* @var FileProcessor
*/
protected $imageProcessor;
protected $fileProcessor;

/**
* @param Context $context
* @param ImageProcessor $imageProcessor
* @param FileProcessor $fileProcessor
*/
public function __construct(
Context $context,
ImageProcessor $imageProcessor
FileProcessor $fileProcessor
) {
parent::__construct($context);
$this->imageProcessor = $imageProcessor;
$this->fileProcessor = $fileProcessor;
}

/**
* @inheritDoc
*/
public function execute()
{
$result = $this->imageProcessor->saveToTmp(key($_FILES));
$result = $this->fileProcessor->saveToTmp(key($_FILES));
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
}
}
28 changes: 26 additions & 2 deletions app/code/Magento/Theme/Model/Design/Backend/Favicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,36 @@
*/
namespace Magento\Theme\Model\Design\Backend;

use Magento\Framework\Filesystem;

class Favicon extends Image
{
/**
* @var string
* The tail part of directory path for uploading
*
*/
const UPLOAD_DIR = 'favicon';

/**
* Return path to directory for upload file
*
* @return string
* @throw \Magento\Framework\Exception\LocalizedException
*/
protected function _getUploadDir()
{
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(self::UPLOAD_DIR));
}

/**
* Makes a decision about whether to add info about the scope.
*
* @return boolean
*/
protected $uploadDir = 'favicon';
protected function _addWhetherScopeInfo()
{
return true;
}

/**
* Getter for allowed extensions of uploaded files.
Expand Down
Loading

0 comments on commit ec436ce

Please sign in to comment.