Skip to content

Commit 9e21556

Browse files
committed
AC-15049 : [CE] PHPUnit 12: Upgrade Security & Authentication related test cases
1 parent d18d94b commit 9e21556

File tree

22 files changed

+97
-27
lines changed

22 files changed

+97
-27
lines changed

app/code/Magento/Captcha/Test/Unit/Cron/DeleteExpiredImagesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Captcha\Test\Unit\Cron;
99

1010
use Magento\Captcha\Cron\DeleteExpiredImages;
11+
use Magento\Captcha\Helper\Adminhtml\Data as AdminhtmlData;
1112
use Magento\Captcha\Helper\Data;
1213
use Magento\Framework\Filesystem;
1314
use Magento\Framework\Filesystem\Directory\Write;
@@ -74,7 +75,7 @@ class DeleteExpiredImagesTest extends TestCase
7475
protected function setUp(): void
7576
{
7677
$this->_helper = $this->createMock(Data::class);
77-
$this->_adminHelper = $this->createMock(\Magento\Captcha\Helper\Adminhtml\Data::class);
78+
$this->_adminHelper = $this->createMock(AdminhtmlData::class);
7879
$this->_filesystem = $this->createMock(Filesystem::class);
7980
$this->_directory = $this->createMock(Write::class);
8081
$this->_storeManager = $this->createMock(StoreManager::class);

app/code/Magento/Captcha/Test/Unit/Model/Checkout/ConfigProviderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ protected function setUp(): void
6363
);
6464
}
6565

66+
/**
67+
* @param $isRequired
68+
* @param $captchaGenerations
69+
* @param $expectedConfig
70+
*/
6671
#[DataProvider('getConfigDataProvider')]
6772
public function testGetConfig($isRequired, $captchaGenerations, $expectedConfig)
6873
{

app/code/Magento/Captcha/Test/Unit/Model/Config/FontTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ protected function setUp(): void
4949
);
5050
}
5151

52+
/**
53+
* Test toOptionArray() with data provider below
54+
*
55+
* @param array $fonts
56+
* @param array $expectedResult
57+
*/
5258
#[DataProvider('toOptionArrayDataProvider')]
5359
public function testToOptionArray($fonts, $expectedResult)
5460
{

app/code/Magento/Captcha/Test/Unit/Model/Config/Form/BackendTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ protected function setUp(): void
4949
);
5050
}
5151

52+
/**
53+
* Test toOptionArray() with data provider below
54+
*
55+
* @param string|array $config
56+
* @param array $expectedResult
57+
*/
5258
#[DataProvider('toOptionArrayDataProvider')]
5359
public function testToOptionArray($config, $expectedResult)
5460
{

app/code/Magento/Captcha/Test/Unit/Model/Config/Form/FrontendTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ protected function setUp(): void
4949
);
5050
}
5151

52+
/**
53+
* Test toOptionArray() with data provider below
54+
*
55+
* @param string|array $config
56+
* @param array $expectedResult
57+
*/
5258
#[DataProvider('toOptionArrayDataProvider')]
5359
public function testToOptionArray($config, $expectedResult)
5460
{

app/code/Magento/Captcha/Test/Unit/Model/Customer/Plugin/AjaxLoginTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Checkout\Model\Session;
1414
use Magento\Customer\Controller\Ajax\Login;
1515
use Magento\Framework\App\Request\Http;
16+
use Magento\Framework\Controller\Result\Json as ResultJson;
1617
use Magento\Framework\Controller\Result\JsonFactory;
1718
use Magento\Framework\Serialize\Serializer\Json;
1819
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
@@ -86,7 +87,7 @@ protected function setUp(): void
8687
JsonFactory::class,
8788
['create']
8889
);
89-
$this->resultJsonMock = $this->createMock(\Magento\Framework\Controller\Result\Json::class);
90+
$this->resultJsonMock = $this->createMock(ResultJson::class);
9091
$this->requestMock = $this->createMock(Http::class);
9192
$this->loginControllerMock = $this->createMock(Login::class);
9293

@@ -180,6 +181,10 @@ public function testAroundExecuteIncorrectCaptcha()
180181
$this->assertEquals($this->resultJsonMock, $this->model->aroundExecute($this->loginControllerMock, $closure));
181182
}
182183

184+
/**
185+
* @param string $username
186+
* @param array $requestContent
187+
*/
183188
#[DataProvider('aroundExecuteCaptchaIsNotRequired')]
184189
public function testAroundExecuteCaptchaIsNotRequired($username, $requestContent)
185190
{

app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ protected function _getStoreStub()
393393
return $store;
394394
}
395395

396+
/**
397+
* @param boolean $expectedResult
398+
* @param string $formId
399+
*/
396400
#[DataProvider('isShownToLoggedInUserDataProvider')]
397401
public function testIsShownToLoggedInUser($expectedResult, $formId)
398402
{
@@ -417,6 +421,10 @@ public static function isShownToLoggedInUserDataProvider()
417421
];
418422
}
419423

424+
/**
425+
* @param string $string
426+
* @throws \ReflectionException
427+
*/
420428
#[DataProvider('generateWordProvider')]
421429
public function testGenerateWord($string)
422430
{

app/code/Magento/Captcha/Test/Unit/Observer/CheckContactUsFormObserverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\App\ActionFlag;
1616
use Magento\Framework\App\Request\DataPersistorInterface;
1717
use Magento\Framework\App\Request\Http;
18+
use Magento\Framework\App\Response\Http as ResponseHttp;
1819
use Magento\Framework\App\Response\RedirectInterface;
1920
use Magento\Framework\Event\Observer;
2021
use Magento\Framework\Message\ManagerInterface;
@@ -142,7 +143,7 @@ public function testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCap
142143
$postData = ['name' => 'Some Name'];
143144

144145
$request = $this->createMock(Http::class);
145-
$response = $this->createMock(\Magento\Framework\App\Response\Http::class);
146+
$response = $this->createMock(ResponseHttp::class);
146147
$request->method('getPost')
147148
->with(Data::INPUT_NAME_FIELD_VALUE, null)
148149
->willReturn([$formId => $captchaValue]);

app/code/Magento/Captcha/Test/Unit/Observer/CheckForgotpasswordObserverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\Action\Action;
1515
use Magento\Framework\App\ActionFlag;
1616
use Magento\Framework\App\Request\Http;
17+
use Magento\Framework\App\Response\Http as ResponseHttp;
1718
use Magento\Framework\App\Response\RedirectInterface;
1819
use Magento\Framework\Event\Observer;
1920
use Magento\Framework\Message\ManagerInterface;
@@ -96,7 +97,7 @@ public function testCheckForgotpasswordRedirects()
9697
$redirectUrl = 'http://magento.com/customer/account/forgotpassword/';
9798

9899
$request = $this->createMock(Http::class);
99-
$response = $this->createMock(\Magento\Framework\App\Response\Http::class);
100+
$response = $this->createMock(ResponseHttp::class);
100101
$request->expects(
101102
$this->any()
102103
)->method(

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserCreateObserverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\Action\Action;
1515
use Magento\Framework\App\ActionFlag;
1616
use Magento\Framework\App\Request\Http;
17+
use Magento\Framework\App\Response\Http as ResponseHttp;
1718
use Magento\Framework\App\Response\RedirectInterface;
1819
use Magento\Framework\Event\Observer;
1920
use Magento\Framework\Message\ManagerInterface;
@@ -123,7 +124,7 @@ public function testCheckUserCreateRedirectsError()
123124
$redirectUrl
124125
);
125126

126-
$response = $this->createMock(\Magento\Framework\App\Response\Http::class);
127+
$response = $this->createMock(ResponseHttp::class);
127128
$response->expects($this->once())->method('setRedirect')->with($redirectUrl);
128129

129130
$this->_urlManager->expects(

0 commit comments

Comments
 (0)