Skip to content

Commit

Permalink
Merge pull request #40 from magento-tango/new_pr_bugs
Browse files Browse the repository at this point in the history
[Tango] Bug Fixes
  • Loading branch information
Korshenko, Olexii(okorshenko) committed Oct 28, 2015
2 parents 46dc2c0 + f447af4 commit 4525716
Show file tree
Hide file tree
Showing 35 changed files with 955 additions and 381 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Block/Widget/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected function _setFieldset($attributes, $fieldset, $exclude = [])
$fieldType,
[
'name' => $attribute->getAttributeCode(),
'label' => $attribute->getFrontend()->getLabel(),
'label' => $attribute->getFrontend()->getLocalizedLabel(),
'class' => $attribute->getFrontend()->getClass(),
'required' => $attribute->getIsRequired(),
'note' => $attribute->getNote()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,88 +9,105 @@

class SaveTest extends \PHPUnit_Framework_TestCase
{
/** @var \Magento\Backend\Controller\Adminhtml\System\Account */
protected $_controller;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface */
protected $_requestMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\ResponseInterface */
protected $_responseMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\ObjectManager\ObjectManager */
protected $_objectManagerMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Message\ManagerInterface */
protected $_messagesMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Helper\Data */
protected $_helperMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Auth\Session */
protected $_authSessionMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\User\Model\User */
protected $_userMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Validator\locale */
protected $_validatorMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Locale\Manager */
protected $_managerMock;

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\TranslateInterface */
protected $_translatorMock;
/**
* @var \Magento\Backend\Controller\Adminhtml\System\Account\Save
*/
protected $controller;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface
*/
protected $requestMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\ResponseInterface
*/
protected $responseMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\ObjectManager\ObjectManager
*/
protected $objectManagerMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Message\ManagerInterface
*/
protected $messagesMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Helper\Data
*/
protected $helperMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Auth\Session
*/
protected $authSessionMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\User\Model\User
*/
protected $userMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Validator\locale
*/
protected $validatorMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Locale\Manager
*/
protected $managerMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\TranslateInterface
*/
protected $translatorMock;

protected function setUp()
{
$this->_requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')
$frontControllerMock = $this->getMockBuilder('Magento\Framework\App\FrontController')
->disableOriginalConstructor()
->getMock();

$this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')
->disableOriginalConstructor()->setMethods(['getOriginalPathInfo'])
->getMock();
$this->_responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http')
$this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http')
->disableOriginalConstructor()
->setMethods([])
->getMock();
$this->_objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')
$this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager\ObjectManager')
->disableOriginalConstructor()
->setMethods(['get', 'create'])
->getMock();
$frontControllerMock = $this->getMockBuilder('Magento\Framework\App\FrontController')
->disableOriginalConstructor()
->getMock();

$this->_helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data')
$this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data')
->disableOriginalConstructor()
->setMethods(['getUrl'])
->getMock();
$this->_messagesMock = $this->getMockBuilder('Magento\Framework\Message\Manager')
$this->messagesMock = $this->getMockBuilder('Magento\Framework\Message\Manager')
->disableOriginalConstructor()
->setMethods(['addSuccess'])
->getMockForAbstractClass();

$this->_authSessionMock = $this->getMockBuilder('Magento\Backend\Model\Auth\Session')
$this->authSessionMock = $this->getMockBuilder('Magento\Backend\Model\Auth\Session')
->disableOriginalConstructor()
->setMethods(['getUser'])
->getMock();

$this->_userMock = $this->getMockBuilder('Magento\User\Model\User')
$this->userMock = $this->getMockBuilder('Magento\User\Model\User')
->disableOriginalConstructor()
->setMethods(
['load', 'save', 'sendPasswordResetNotificationEmail', 'verifyIdentity', '__sleep', '__wakeup']
)
->getMock();

$this->_validatorMock = $this->getMockBuilder('Magento\Framework\Validator\Locale')
$this->validatorMock = $this->getMockBuilder('Magento\Framework\Validator\Locale')
->disableOriginalConstructor()
->setMethods(['isValid'])
->getMock();

$this->_managerMock = $this->getMockBuilder('Magento\Backend\Model\Locale\Manager')
$this->managerMock = $this->getMockBuilder('Magento\Backend\Model\Locale\Manager')
->disableOriginalConstructor()
->setMethods(['switchBackendInterfaceLocale'])
->getMock();

$this->_translatorMock = $this->getMockBuilder('Magento\Framework\TranslateInterface')
$this->translatorMock = $this->getMockBuilder('Magento\Framework\TranslateInterface')
->disableOriginalConstructor()
->getMock();

Expand All @@ -107,19 +124,19 @@ protected function setUp()
->willReturn($resultRedirect);

$contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false);
$contextMock->expects($this->any())->method('getRequest')->willReturn($this->_requestMock);
$contextMock->expects($this->any())->method('getResponse')->willReturn($this->_responseMock);
$contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->_objectManagerMock);
$contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
$contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock);
$contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
$contextMock->expects($this->any())->method('getFrontController')->willReturn($frontControllerMock);
$contextMock->expects($this->any())->method('getHelper')->willReturn($this->_helperMock);
$contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->_messagesMock);
$contextMock->expects($this->any())->method('getTranslator')->willReturn($this->_translatorMock);
$contextMock->expects($this->any())->method('getHelper')->willReturn($this->helperMock);
$contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messagesMock);
$contextMock->expects($this->any())->method('getTranslator')->willReturn($this->translatorMock);
$contextMock->expects($this->once())->method('getResultFactory')->willReturn($resultFactory);

$args = ['context' => $contextMock];

$testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->_controller = $testHelper->getObject('Magento\Backend\Controller\Adminhtml\System\Account\Save', $args);
$this->controller = $testHelper->getObject('Magento\Backend\Controller\Adminhtml\System\Account\Save', $args);
}

public function testSaveAction()
Expand All @@ -136,69 +153,50 @@ public function testSaveAction()
\Magento\Backend\Block\System\Account\Edit\Form::IDENTITY_VERIFICATION_PASSWORD_FIELD => 'current_password',
];

$testedMessage = 'You saved the account.';

$this->_authSessionMock->expects($this->any())->method('getUser')->will($this->returnValue($this->_userMock));

$this->_userMock->expects($this->any())->method('load')->will($this->returnSelf());
$this->_validatorMock->expects(
$this->once()
)->method(
'isValid'
)->with(
$this->equalTo($requestParams['interface_locale'])
)->will(
$this->returnValue(true)
);
$this->_managerMock->expects($this->any())->method('switchBackendInterfaceLocale');

$this->_objectManagerMock->expects(
$this->at(0)
)->method(
'get'
)->with(
$this->equalTo('Magento\Backend\Model\Auth\Session')
)->will(
$this->returnValue($this->_authSessionMock)
);
$this->_objectManagerMock->expects(
$this->at(1)
)->method(
'create'
)->with(
$this->equalTo('Magento\User\Model\User')
)->will(
$this->returnValue($this->_userMock)
);
$this->_objectManagerMock->expects(
$this->at(2)
)->method(
'get'
)->with(
$this->equalTo('Magento\Framework\Validator\Locale')
)->will(
$this->returnValue($this->_validatorMock)
);
$this->_objectManagerMock->expects(
$this->at(3)
)->method(
'get'
)->with(
$this->equalTo('Magento\Backend\Model\Locale\Manager')
)->will(
$this->returnValue($this->_managerMock)
);

$this->_userMock->setUserId($userId);

$this->_userMock->expects($this->once())->method('save');
$this->_userMock->expects($this->once())->method('verifyIdentity')->will($this->returnValue(true));
$this->_userMock->expects($this->once())->method('sendPasswordResetNotificationEmail');

$this->_requestMock->setParams($requestParams);

$this->_messagesMock->expects($this->once())->method('addSuccess')->with($this->equalTo($testedMessage));

$this->_controller->execute();
$testedMessage = __('You saved the account.');

$this->authSessionMock->expects($this->any())
->method('getUser')
->willReturn($this->userMock);
$this->userMock->expects($this->any())
->method('load')
->will($this->returnSelf());
$this->validatorMock->expects($this->once())
->method('isValid')
->with($this->equalTo($requestParams['interface_locale']))
->willReturn(true);
$this->managerMock->expects($this->any())
->method('switchBackendInterfaceLocale');
$this->objectManagerMock->expects($this->at(0))
->method('get')
->with($this->equalTo('Magento\Backend\Model\Auth\Session'))
->willReturn($this->authSessionMock);
$this->objectManagerMock->expects($this->at(1))
->method('create')
->with($this->equalTo('Magento\User\Model\User'))
->willReturn($this->userMock);
$this->objectManagerMock->expects($this->at(2))
->method('get')
->with($this->equalTo('Magento\Framework\Validator\Locale'))
->willReturn($this->validatorMock);
$this->objectManagerMock->expects($this->at(3))
->method('get')
->with($this->equalTo('Magento\Backend\Model\Locale\Manager'))
->willReturn($this->managerMock);
$this->userMock->expects($this->once())
->method('save');
$this->userMock->expects($this->once())
->method('verifyIdentity')
->willReturn(true);
$this->userMock->expects($this->once())
->method('sendPasswordResetNotificationEmail');
$this->messagesMock->expects($this->once())
->method('addSuccess')
->with($this->equalTo($testedMessage));

$this->userMock->setUserId($userId);
$this->requestMock->setParams($requestParams);

$this->controller->execute();
}
}
6 changes: 6 additions & 0 deletions app/code/Magento/Backend/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,12 @@ Tags,Tags
Options,Options
"Magento Admin","Magento Admin"
"Community Edition","Community Edition"
"Last Orders","Last Orders"
"Last Search Terms","Last Search Terms"
"Top Search Terms","Top Search Terms"
"Your Password","Your Password"
"You saved the account.","You saved the account."
"Current User Identity Verification","Current User Identity Verification"
Marketing,Marketing
Communications,Communications
"SEO & Search","SEO & Search"
Expand Down
21 changes: 21 additions & 0 deletions app/code/Magento/Catalog/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,24 @@ Set,Set
none,none
Overview,Overview
"Field ""%1"" was not found in DO ""%2"".","Field ""%1"" was not found in DO ""%2""."
"Is Active","Is Active"
"URL Key","URL Key"
"Description","Description"
"Image","Image"
"Page Title","Page Title"
"Meta Keywords","Meta Keywords"
"Meta Description","Meta Description"
"Include in Navigation Menu","Include in Navigation Menu"
"Display Mode","Display Mode"
"CMS Block","CMS Block"
"Is Anchor","Is Anchor"
"Available Product Listing Sort By","Available Product Listing Sort By"
"Default Product Listing Sort By","Default Product Listing Sort By"
"Layered Navigation Price Step","Layered Navigation Price Step"
"Use Parent Category Settings","Use Parent Category Settings"
"Apply To Products","Apply To Products"
"Active From","Active From"
"Active To","Active To"
"Page Layout","Page Layout"
"Custom Layout Update","Custom Layout Update"
"Name","Name"
4 changes: 4 additions & 0 deletions app/code/Magento/CatalogRule/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ protected function _getWebsitesMap()
$map = [];
$websites = $this->_storeManager->getWebsites(true);
foreach ($websites as $website) {
// Continue if website has no store to be able to create catalog rule for website without store
if ($website->getDefaultStore() === null) {
continue;
}
$map[$website->getId()] = $website->getDefaultStore()->getId();
}
return $map;
Expand Down
9 changes: 4 additions & 5 deletions app/code/Magento/Deploy/Model/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,11 @@ private function deployFile($filePath, $area, $themePath, $locale, $module)
}
}

$logMessage = "Processing file '$filePath' for area '$area', theme '$themePath', locale '$locale'";
if ($module) {
$logMessage .= ", module '$module'";
}

if ($this->output->isVeryVerbose()) {
$logMessage = "Processing file '$filePath' for area '$area', theme '$themePath', locale '$locale'";
if ($module) {
$logMessage .= ", module '$module'";
}
$this->output->writeln($logMessage);
}

Expand Down
Loading

0 comments on commit 4525716

Please sign in to comment.