Skip to content

Commit b1ea000

Browse files
Merge branch '2.4-develop' into MC-23177
2 parents 2854292 + 57a2aad commit b1ea000

File tree

224 files changed

+7906
-1015
lines changed

Some content is hidden

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

224 files changed

+7906
-1015
lines changed

app/code/Magento/Analytics/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<label>Advanced Reporting</label>
1616
<comment><![CDATA[This service provides a dynamic suite of reports with rich insights about your business.
1717
Your reports can be accessed securely on a personalized dashboard outside of the admin panel by clicking on the
18-
"Go to Advanced Reporting" link. </br> For more information, see our <a href="https://magento.com/legal/terms/cloud-terms">
18+
"Go to Advanced Reporting" link. </br> For more information, see our <a target="_blank" href="https://magento.com/legal/terms/cloud-terms">
1919
terms and conditions</a>.]]></comment>
2020
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
2121
<label>Advanced Reporting Service</label>

app/code/Magento/Backend/Model/Menu/Item/Validator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
namespace Magento\Backend\Model\Menu\Item;
77

88
/**
9+
* Class Validator
10+
*
11+
* @package Magento\Backend\Model\Menu\Item
912
* @api
1013
* @since 100.0.2
1114
*/
@@ -49,7 +52,7 @@ public function __construct()
4952

5053
$attributeValidator = new \Zend_Validate();
5154
$attributeValidator->addValidator(new \Zend_Validate_StringLength(['min' => 3]));
52-
$attributeValidator->addValidator(new \Zend_Validate_Regex('/^[A-Za-z0-9\/_]+$/'));
55+
$attributeValidator->addValidator(new \Zend_Validate_Regex('/^[A-Za-z0-9\/_\-]+$/'));
5356

5457
$textValidator = new \Zend_Validate_StringLength(['min' => 3, 'max' => 50]);
5558

@@ -101,6 +104,7 @@ private function checkMenuItemIsRemoved($data)
101104

102105
/**
103106
* Check that menu item contains all required data
107+
*
104108
* @param array $data
105109
*
106110
* @throws \BadMethodCallException

app/code/Magento/Backend/Test/Unit/Model/Menu/Config/_files/invalidMenuXmlArray.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
' resource="Test_Value::value"/></menu></config>',
1111
[
1212
"Element 'add', attribute 'action': [facet 'pattern'] The value '' is not accepted by the " .
13-
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
13+
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
1414
"Element 'add', attribute 'action': '' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
1515
],
1616
],
@@ -20,7 +20,7 @@
2020
'resource="Test_Value::value"/></menu></config>',
2121
[
2222
"Element 'add', attribute 'action': [facet 'pattern'] The value 'ad' is not accepted by the " .
23-
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
23+
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
2424
"Element 'add', attribute 'action': 'ad' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
2525
],
2626
],
@@ -31,7 +31,7 @@
3131
'</menu></config>',
3232
[
3333
"Element 'add', attribute 'action': [facet 'pattern'] The value 'adm$#@inhtml/notification' is not " .
34-
"accepted by the pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
34+
"accepted by the pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
3535
"Element 'add', attribute 'action': 'adm$#@inhtml/notification' is not a valid value of the atomic " .
3636
"type 'typeAction'.\nLine: 1\n"
3737
],
@@ -452,7 +452,7 @@
452452
'<?xml version="1.0"?><config><menu><update action="" ' . 'id="Test_Value::some_value"/></menu></config>',
453453
[
454454
"Element 'update', attribute 'action': [facet 'pattern'] The value '' is not accepted by the " .
455-
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
455+
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
456456
"Element 'update', attribute 'action': '' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
457457
],
458458
],
@@ -462,7 +462,7 @@
462462
'resource="Test_Value::value"/></menu></config>',
463463
[
464464
"Element 'update', attribute 'action': [facet 'pattern'] The value 'v' is not accepted by the " .
465-
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
465+
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
466466
"Element 'update', attribute 'action': 'v' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
467467
],
468468
],
@@ -471,7 +471,7 @@
471471
'id="Test_Value::some_value"/></menu></config>',
472472
[
473473
"Element 'update', attribute 'action': [facet 'pattern'] The value '/@##gt;' is not " .
474-
"accepted by the pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
474+
"accepted by the pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
475475
"Element 'update', attribute 'action': '/@##gt;' is not a valid value of the atomic" .
476476
" type 'typeAction'.\nLine: 1\n"
477477
],

app/code/Magento/Backend/etc/menu.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
</xs:documentation>
101101
</xs:annotation>
102102
<xs:restriction base="xs:string">
103-
<xs:pattern value="[a-zA-Z0-9/_]{3,}" />
103+
<xs:pattern value="[a-zA-Z0-9/_\-]{3,}" />
104104
</xs:restriction>
105105
</xs:simpleType>
106106

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+
}

0 commit comments

Comments
 (0)