Skip to content

Commit

Permalink
Merge branch 'develop' into MAGETWO-41755
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii Lugovyi committed Sep 7, 2015
2 parents 4af5c05 + 91dc2d6 commit 744f317
Show file tree
Hide file tree
Showing 21 changed files with 932 additions and 38 deletions.
25 changes: 14 additions & 11 deletions app/code/Magento/Authorizenet/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,45 +44,48 @@
<field id="cgi_url" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Gateway URL</label>
</field>
<field id="currency" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="cgi_url_td" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Transaction Details Url</label>
</field>
<field id="currency" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Accepted Currency</label>
<source_model>Magento\Config\Model\Config\Source\Locale\Currency</source_model>
</field>
<field id="debug" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="debug" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Debug</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="email_customer" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="email_customer" translate="label" type="select" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Email Customer</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="merchant_email" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="merchant_email" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Merchant's Email</label>
<validate>validate-email</validate>
</field>
<field id="cctypes" translate="label" type="multiselect" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="cctypes" translate="label" type="multiselect" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Credit Card Types</label>
<source_model>Magento\Authorizenet\Model\Source\Cctype</source_model>
</field>
<field id="useccv" translate="label" type="select" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="useccv" translate="label" type="select" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Credit Card Verification</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="specificcountry" translate="label" type="multiselect" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
</field>
<field id="min_order_total" translate="label" type="text" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="min_order_total" translate="label" type="text" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Minimum Order Total</label>
</field>
<field id="max_order_total" translate="label" type="text" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="max_order_total" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Maximum Order Total</label>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="sort_order" translate="label" type="text" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
</field>
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Authorizenet/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<place_order_url>authorizenet/directpost_payment/place</place_order_url>
<cgi_url_test_mode>https://test.authorize.net/gateway/transact.dll</cgi_url_test_mode>
<cgi_url>https://secure.authorize.net/gateway/transact.dll</cgi_url>
<cgi_url_td_test_mode>https://apitest.authorize.net/xml/v1/request.api</cgi_url_td_test_mode>
<cgi_url_td>https://api2.authorize.net/xml/v1/request.api</cgi_url_td>
</authorizenet_directpost>
</payment>
</default>
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Backend/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,17 @@ public function getHintHtml()
}
return $html;
}

/**
* Get whether iframe is being used
*
* @return bool
*/
public function isUsingIframe()
{
if ($this->hasData('is_using_iframe')) {
return (bool)$this->getData('is_using_iframe');
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
class="admin__action-dropdown"
data-mage-init='{"dropdown":{}}'
data-toggle="dropdown"
aria-haspopup="true">
aria-haspopup="true"
id="store-change-button">
<?php echo $block->getCurrentSelectionName() ?>
</button>
<ul class="dropdown-menu" data-role="stores-list">
Expand Down Expand Up @@ -168,15 +169,35 @@ require(['jquery'], function(jQuery){
};
scopeSwitcherHandler(switcherParams);
} else {
var url = '<?php echo $block->getSwitchUrl() ?>' + scopeParams;

<?php if ($block->getUseConfirm()): ?>
if (confirm("<?php echo __('Please confirm scope switching. All data that hasn\'t been saved will be lost.') ?>")) {
setLocation(url);
reload();
} else {
obj.value = '<?php echo $block->getStoreId() ?>';
}
<?php else: ?>
reload();
<?php endif; ?>
}

function reload() {
<?php if (!$block->isUsingIframe()): ?>
var url = '<?php echo $block->getSwitchUrl() ?>' + scopeParams;
setLocation(url);
<?php else: ?>
jQuery('#preview_selected_store').val(scopeId);
jQuery('#preview_form').submit();

jQuery('.store-switcher .dropdown-menu li a').each(function() {
var $this = jQuery(this);

if ($this.data('role') === 'store-view-id' && $this.data('value') == scopeId) {
jQuery('#store-change-button').html($this.text());
}
});

jQuery('#store-change-button').click();
<?php endif; ?>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public function __construct(Context $context, Filter $filter, CollectionFactory
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();

foreach ($collection as $item) {
$item->delete();
foreach ($collection as $block) {
$block->delete();
}

$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize()));
$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize));

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/Cms/Controller/Adminhtml/Page/MassDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ public function __construct(Context $context, Filter $filter, CollectionFactory
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();

foreach ($collection as $item) {
$item->delete();
foreach ($collection as $page) {
$page->delete();
}

$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize()));
$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize));

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function execute()
$item->save();
}

$this->messageManager->addSuccess(__('A total of %1 record(s) have been updated.', $collection->getSize()));
$this->messageManager->addSuccess(__('A total of %1 record(s) have been disabled.', $collection->getSize()));

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function execute()
$item->save();
}

$this->messageManager->addSuccess(__('A total of %1 record(s) have been updated.', $collection->getSize()));
$this->messageManager->addSuccess(__('A total of %1 record(s) have been enabled.', $collection->getSize()));

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cms\Test\Unit\Controller\Adminhtml;

use Magento\Framework\Controller\ResultFactory;

abstract class AbstractMassActionTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
protected $objectManager;

/**
* @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
*/
protected $contextMock;

/**
* @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject
*/
protected $resultFactoryMock;

/**
* @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject
*/
protected $resultRedirectMock;

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

/**
* @var \Magento\Ui\Component\MassAction\Filter|\PHPUnit_Framework_MockObject_MockObject
*/
protected $filterMock;

protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

$this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface', [], [], '', false);

$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
->disableOriginalConstructor()
->getMock();
$this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
->disableOriginalConstructor()
->getMock();
$this->resultFactoryMock->expects($this->any())
->method('create')
->with(ResultFactory::TYPE_REDIRECT, [])
->willReturn($this->resultRedirectMock);

$this->contextMock = $this->getMock('\Magento\Backend\App\Action\Context', [], [], '', false);

$this->filterMock = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter')
->disableOriginalConstructor()
->getMock();

$this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
$this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cms\Test\Unit\Controller\Adminhtml\Block;

use Magento\Cms\Test\Unit\Controller\Adminhtml\AbstractMassActionTest;

class MassDeleteTest extends AbstractMassActionTest
{
/**
* @var \Magento\Cms\Controller\Adminhtml\Block\MassDelete
*/
protected $massDeleteController;

/**
* @var \Magento\Cms\Model\Resource\Block\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
*/
protected $collectionFactoryMock;

/**
* @var \Magento\Cms\Model\Resource\Block\Collection|\PHPUnit_Framework_MockObject_MockObject
*/
protected $blockCollectionMock;

protected function setUp()
{
parent::setUp();

$this->collectionFactoryMock = $this->getMock(
'Magento\Cms\Model\Resource\Block\CollectionFactory',
['create'],
[],
'',
false
);

$this->blockCollectionMock = $this->getMock('Magento\Cms\Model\Resource\Block\Collection', [], [], '', false);

$this->massDeleteController = $this->objectManager->getObject(
'Magento\Cms\Controller\Adminhtml\Block\MassDelete',
[
'context' => $this->contextMock,
'filter' => $this->filterMock,
'collectionFactory' => $this->collectionFactoryMock
]
);
}

public function testMassDeleteAction()
{
$deletedBlocksCount = 2;

$collection = [
$this->getBlockMock(),
$this->getBlockMock()
];

$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->blockCollectionMock);

$this->filterMock->expects($this->once())
->method('getCollection')
->with($this->blockCollectionMock)
->willReturn($this->blockCollectionMock);

$this->blockCollectionMock->expects($this->once())->method('getSize')->willReturn($deletedBlocksCount);
$this->blockCollectionMock->expects($this->once())
->method('getIterator')
->willReturn(new \ArrayIterator($collection));

$this->messageManagerMock->expects($this->once())
->method('addSuccess')
->with(__('A total of %1 record(s) have been deleted.', $deletedBlocksCount));
$this->messageManagerMock->expects($this->never())->method('addError');

$this->resultRedirectMock->expects($this->once())
->method('setPath')
->with('*/*/')
->willReturnSelf();

$this->assertSame($this->resultRedirectMock, $this->massDeleteController->execute());
}

/**
* Create Cms Block Collection Mock
*
* @return \Magento\Cms\Model\Resource\Block\Collection|\PHPUnit_Framework_MockObject_MockObject
*/
protected function getBlockMock()
{
$blockMock = $this->getMock('Magento\Cms\Model\Resource\Block\Collection', ['delete'], [], '', false);
$blockMock->expects($this->once())->method('delete')->willReturn(true);

return $blockMock;
}
}
Loading

0 comments on commit 744f317

Please sign in to comment.