Skip to content

Commit 1c43ad1

Browse files
merge magento/2.3-develop into magento-tsg/2.3-develop-com-pr8
2 parents dc5939c + 7abeb2e commit 1c43ad1

File tree

56 files changed

+1663
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1663
-216
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Captcha\Test\Unit\Model\Config;
10+
11+
use PHPUnit\Framework\TestCase;
12+
use Magento\Captcha\Helper\Data as HelperData;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
14+
use Magento\Captcha\Model\Config\Font;
15+
16+
class FontTest extends TestCase
17+
{
18+
/**
19+
* @var ObjectManagerHelper
20+
*/
21+
private $objectManagerHelper;
22+
23+
/**
24+
* @var Font
25+
*/
26+
private $model;
27+
28+
/**
29+
* @var HelperData|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $helperDataMock;
32+
33+
/**
34+
* Setup Environment For Testing
35+
*/
36+
protected function setUp()
37+
{
38+
$this->helperDataMock = $this->createMock(HelperData::class);
39+
40+
$this->objectManagerHelper = new ObjectManagerHelper($this);
41+
42+
$this->model = $this->objectManagerHelper->getObject(
43+
Font::class,
44+
[
45+
'captchaData' => $this->helperDataMock
46+
]
47+
);
48+
}
49+
50+
/**
51+
* Test toOptionArray() with data provider below
52+
*
53+
* @param array $fonts
54+
* @param array $expectedResult
55+
* @dataProvider toOptionArrayDataProvider
56+
*/
57+
public function testToOptionArray($fonts, $expectedResult)
58+
{
59+
$this->helperDataMock->expects($this->any())->method('getFonts')
60+
->willReturn($fonts);
61+
62+
$this->assertEquals($expectedResult, $this->model->toOptionArray());
63+
}
64+
65+
/**
66+
* Data Provider for testing toOptionArray()
67+
*
68+
* @return array
69+
*/
70+
public function toOptionArrayDataProvider()
71+
{
72+
return [
73+
'Empty get font' => [
74+
[],
75+
[]
76+
],
77+
'Get font result' => [
78+
[
79+
'arial' => [
80+
'label' => 'Arial',
81+
'path' => '/www/magento/fonts/arial.ttf'
82+
],
83+
'verdana' => [
84+
'label' => 'Verdana',
85+
'path' => '/www/magento/fonts/verdana.ttf'
86+
]
87+
],
88+
[
89+
[
90+
'label' => 'Arial',
91+
'value' => 'arial'
92+
],
93+
[
94+
'label' => 'Verdana',
95+
'value' => 'verdana'
96+
]
97+
]
98+
]
99+
];
100+
}
101+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Captcha\Test\Unit\Model\Config\Form;
10+
11+
use Magento\Captcha\Model\Config\Form\Backend;
12+
use PHPUnit\Framework\TestCase;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
15+
16+
class BackendTest extends TestCase
17+
{
18+
/**
19+
* @var ObjectManagerHelper
20+
*/
21+
private $objectManagerHelper;
22+
23+
/**
24+
* @var Backend
25+
*/
26+
private $model;
27+
28+
/**
29+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $configMock;
32+
33+
/**
34+
* Setup Environment For Testing
35+
*/
36+
protected function setUp()
37+
{
38+
$this->configMock = $this->createMock(ScopeConfigInterface::class);
39+
40+
$this->objectManagerHelper = new ObjectManagerHelper($this);
41+
42+
$this->model = $this->objectManagerHelper->getObject(
43+
Backend::class,
44+
[
45+
'config' => $this->configMock
46+
]
47+
);
48+
}
49+
50+
/**
51+
* Test toOptionArray() with data provider below
52+
*
53+
* @param string|array $config
54+
* @param array $expectedResult
55+
* @dataProvider toOptionArrayDataProvider
56+
*/
57+
public function testToOptionArray($config, $expectedResult)
58+
{
59+
$this->configMock->expects($this->any())->method('getValue')
60+
->with('captcha/backend/areas', 'default')
61+
->willReturn($config);
62+
63+
$this->assertEquals($expectedResult, $this->model->toOptionArray());
64+
}
65+
66+
/**
67+
* Data Provider for testing toOptionArray()
68+
*
69+
* @return array
70+
*/
71+
public function toOptionArrayDataProvider()
72+
{
73+
return [
74+
'Empty captcha backend areas' => [
75+
'',
76+
[]
77+
],
78+
'With two captcha backend area' => [
79+
[
80+
'backend_login' => [
81+
'label' => 'Admin Login'
82+
],
83+
'backend_forgotpassword' => [
84+
'label' => 'Admin Forgot Password'
85+
]
86+
],
87+
[
88+
[
89+
'label' => 'Admin Login',
90+
'value' => 'backend_login'
91+
],
92+
[
93+
'label' => 'Admin Forgot Password',
94+
'value' => 'backend_forgotpassword'
95+
]
96+
]
97+
]
98+
];
99+
}
100+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Captcha\Test\Unit\Model\Config\Form;
10+
11+
use Magento\Captcha\Model\Config\Form\Frontend;
12+
use PHPUnit\Framework\TestCase;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
15+
16+
class FrontendTest extends TestCase
17+
{
18+
/**
19+
* @var ObjectManagerHelper
20+
*/
21+
private $objectManagerHelper;
22+
23+
/**
24+
* @var Frontend
25+
*/
26+
private $model;
27+
28+
/**
29+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $configMock;
32+
33+
/**
34+
* Setup Environment For Testing
35+
*/
36+
protected function setUp()
37+
{
38+
$this->configMock = $this->createMock(ScopeConfigInterface::class);
39+
40+
$this->objectManagerHelper = new ObjectManagerHelper($this);
41+
42+
$this->model = $this->objectManagerHelper->getObject(
43+
Frontend::class,
44+
[
45+
'config' => $this->configMock
46+
]
47+
);
48+
}
49+
50+
/**
51+
* Test toOptionArray() with data provider below
52+
*
53+
* @param string|array $config
54+
* @param array $expectedResult
55+
* @dataProvider toOptionArrayDataProvider
56+
*/
57+
public function testToOptionArray($config, $expectedResult)
58+
{
59+
$this->configMock->expects($this->any())->method('getValue')
60+
->with('captcha/frontend/areas', 'default')
61+
->willReturn($config);
62+
63+
$this->assertEquals($expectedResult, $this->model->toOptionArray());
64+
}
65+
66+
/**
67+
* Data Provider for testing toOptionArray()
68+
*
69+
* @return array
70+
*/
71+
public function toOptionArrayDataProvider()
72+
{
73+
return [
74+
'Empty captcha frontend areas' => [
75+
'',
76+
[]
77+
],
78+
'With two captcha frontend area' => [
79+
[
80+
'product_sendtofriend_form' => [
81+
'label' => 'Send To Friend Form'
82+
],
83+
'sales_rule_coupon_request' => [
84+
'label' => 'Applying coupon code'
85+
]
86+
],
87+
[
88+
[
89+
'label' => 'Send To Friend Form',
90+
'value' => 'product_sendtofriend_form'
91+
],
92+
[
93+
'label' => 'Applying coupon code',
94+
'value' => 'sales_rule_coupon_request'
95+
]
96+
]
97+
]
98+
];
99+
}
100+
}

app/code/Magento/CatalogUrlRewriteGraphQl/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@
2222
</argument>
2323
</arguments>
2424
</type>
25+
26+
<type name="Magento\UrlRewriteGraphQl\Model\Resolver\UrlRewrite">
27+
<arguments>
28+
<argument name="entityTypeMapping" xsi:type="array">
29+
<item name="catalog_product" xsi:type="const">Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::ENTITY_TYPE</item>
30+
</argument>
31+
</arguments>
32+
</type>
2533
</config>

app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/Save.php

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,68 @@
55
*/
66
namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol;
77

8-
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
8+
use Magento\Backend\App\Action;
9+
use Magento\Backend\Model\View\Result\Redirect;
10+
use Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol as CurrencysymbolController;
11+
use Magento\CurrencySymbol\Model\System\CurrencysymbolFactory;
12+
use Magento\Framework\App\Action\HttpPostActionInterface;
13+
use Magento\Framework\Controller\ResultInterface;
14+
use Magento\Framework\Filter\FilterManager;
915

1016
/**
11-
* Class Save
17+
* Controller to save currency symbol
1218
*/
13-
class Save extends \Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol implements HttpPostActionInterface
19+
class Save extends CurrencysymbolController implements HttpPostActionInterface
1420
{
21+
/**
22+
* @var FilterManager
23+
*/
24+
private $filterManager;
25+
26+
/**
27+
* @var CurrencysymbolFactory
28+
*/
29+
private $currencySymbolFactory;
30+
31+
/**
32+
* @param Action\Context $context
33+
* @param FilterManager $filterManager
34+
* @param CurrencysymbolFactory $currencySymbolFactory
35+
*/
36+
public function __construct(
37+
Action\Context $context,
38+
FilterManager $filterManager,
39+
CurrencysymbolFactory $currencySymbolFactory
40+
) {
41+
parent::__construct($context);
42+
$this->filterManager = $filterManager;
43+
$this->currencySymbolFactory = $currencySymbolFactory;
44+
}
45+
1546
/**
1647
* Save custom Currency symbol
1748
*
18-
* @return void
49+
* @return ResultInterface
1950
*/
2051
public function execute()
2152
{
53+
/** @var Redirect $resultRedirect */
54+
$resultRedirect = $this->resultRedirectFactory->create();
2255
$symbolsDataArray = $this->getRequest()->getParam('custom_currency_symbol', null);
2356
if (is_array($symbolsDataArray)) {
2457
foreach ($symbolsDataArray as &$symbolsData) {
25-
/** @var $filterManager \Magento\Framework\Filter\FilterManager */
26-
$filterManager = $this->_objectManager->get(\Magento\Framework\Filter\FilterManager::class);
27-
$symbolsData = $filterManager->stripTags($symbolsData);
58+
$symbolsData = $this->filterManager->stripTags($symbolsData);
2859
}
2960
}
3061

3162
try {
32-
$this->_objectManager->create(\Magento\CurrencySymbol\Model\System\Currencysymbol::class)
33-
->setCurrencySymbolsData($symbolsDataArray);
63+
$currencySymbol = $this->currencySymbolFactory->create();
64+
$currencySymbol->setCurrencySymbolsData($symbolsDataArray);
3465
$this->messageManager->addSuccessMessage(__('You applied the custom currency symbols.'));
3566
} catch (\Exception $e) {
3667
$this->messageManager->addErrorMessage($e->getMessage());
3768
}
3869

39-
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
70+
return $resultRedirect->setPath('*');
4071
}
4172
}

0 commit comments

Comments
 (0)