Skip to content

Commit e99537f

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Accepted Community Pull Requests: - #25713: [Shipping] Cover Helper Data by Unit Test (by @edenduong) - #25869: Prevent RequireJS from adding .min.js suffix to external files (by @krzksz) - #25880: [Captcha] Cover Model Config by Unit Test (by @edenduong) - #25785: #20463 Fix order summary view details label misalign (by @mfickers) Fixed GitHub Issues: - #25690: RequireJs is not resolving CDN path for some js files (reported by @rafaelstz) has been fixed in #25869 by @krzksz in 2.3-develop branch Related commits: 1. 23f0ced - #20463: On order sumary view details label misalign on tablet (reported by @nainesh2jcommerce) has been fixed in #25785 by @mfickers in 2.3-develop branch Related commits: 1. 097228c 2. 686502a
2 parents 67fe58f + b4fb612 commit e99537f

File tree

8 files changed

+441
-18
lines changed

8 files changed

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

0 commit comments

Comments
 (0)