Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into FearlessKiwis-MA…
Browse files Browse the repository at this point in the history
…GETWO-44491-Rename-Dispatch-Execute
  • Loading branch information
Yu Tang committed Oct 28, 2015
2 parents 447e70c + 9272b2f commit b12c316
Show file tree
Hide file tree
Showing 285 changed files with 8,953 additions and 2,943 deletions.
26 changes: 26 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@

</IfModule>

<IfModule mod_php7.c>

############################################
## adjust memory limit

php_value memory_limit 768M
php_value max_execution_time 18000

############################################
## disable automatic session start
## before autoload was initialized

php_flag session.auto_start off

############################################
## enable resulting html compression

#php_flag zlib.output_compression on

###########################################
## disable user agent verification to not break multiple image upload

php_flag suhosin.session.cryptua off

</IfModule>

<IfModule mod_security.c>
###########################################
## disable POST processing to not break multiple image upload
Expand Down
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
3 changes: 3 additions & 0 deletions app/code/Magento/Backend/Block/Widget/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public function addTabAfter($tabId, $tab, $afterTabId)
*/
public function addTab($tabId, $tab)
{
if (empty($tabId)) {
throw new \Exception(__('Please correct the tab configuration and try again. Tab Id should be not empry'));
}
if (is_array($tab)) {
$this->_tabs[$tabId] = new \Magento\Framework\DataObject($tab);
} elseif ($tab instanceof \Magento\Framework\DataObject) {
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->executeInternal();
$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->executeInternal();
}
}
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
Loading

0 comments on commit b12c316

Please sign in to comment.