Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into PR_Branch
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeysee committed Oct 28, 2015
2 parents c9d4b5d + ccbfd27 commit 5518c89
Show file tree
Hide file tree
Showing 111 changed files with 2,344 additions and 1,165 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
39 changes: 39 additions & 0 deletions app/code/Magento/Catalog/Api/Data/ProductWebsiteLinkInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Api\Data;

/**
* @api
*/
interface ProductWebsiteLinkInterface
{
/**
* @return string
*/
public function getSku();

/**
* @param string $sku
* @return $this
*/
public function setSku($sku);

/**
* Get website ids
*
* @return int
*/
public function getWebsiteId();

/**
* Set website id
*
* @param int $websiteId
* @return $this
*/
public function setWebsiteId($websiteId);
}
Loading

0 comments on commit 5518c89

Please sign in to comment.