Skip to content

Commit b3fbe9c

Browse files
Merge remote-tracking branch 'origin/AC-15105-Payment-Shipping' into AC-15050
2 parents f80b19d + 96d28b3 commit b3fbe9c

File tree

175 files changed

+1666
-2269
lines changed

Some content is hidden

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

175 files changed

+1666
-2269
lines changed

app/code/Magento/CardinalCommerce/Test/Unit/Model/JwtManagementTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\CardinalCommerce\Model\JwtManagement;
1111
use Magento\Framework\Serialize\Serializer\Json;
1212
use PHPUnit\Framework\TestCase;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314

1415
/**
1516
* Tests JWT encode and decode.
@@ -64,11 +65,11 @@ public function testDecode()
6465

6566
/**
6667
* Tests JWT decode.
67-
*
68+
*
6869
* @param string $jwt
6970
* @param string $errorMessage
70-
* @dataProvider decodeWithExceptionDataProvider
7171
*/
72+
#[DataProvider('decodeWithExceptionDataProvider')]
7273
public function testDecodeWithException(string $jwt, string $errorMessage)
7374
{
7475
$this->expectException(\InvalidArgumentException::class);

app/code/Magento/CardinalCommerce/Test/Unit/Model/Response/JwtParserTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1616
use PHPUnit\Framework\MockObject\MockObject;
1717
use PHPUnit\Framework\TestCase;
18+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1819

1920
class JwtParserTest extends TestCase
2021
{
22+
use MockCreationTrait;
23+
2124
/**
2225
* @var ObjectManager
2326
*/
@@ -50,20 +53,17 @@ protected function setUp(): void
5053
{
5154
$this->objectManager = new ObjectManager($this);
5255

53-
$this->configMock = $this->getMockBuilder(Config::class)
54-
->onlyMethods(['getApiKey', 'isDebugModeEnabled'])
55-
->disableOriginalConstructor()
56-
->getMock();
56+
$this->configMock = $this->createPartialMock(
57+
Config::class,
58+
['getApiKey', 'isDebugModeEnabled']
59+
);
5760

58-
$this->jwtManagementMock = $this->getMockBuilder(JwtManagement::class)
59-
->onlyMethods(['decode'])
60-
->disableOriginalConstructor()
61-
->getMock();
61+
$this->jwtManagementMock = $this->createPartialMock(
62+
JwtManagement::class,
63+
['decode']
64+
);
6265

63-
$this->jwtPayloadValidatorMock = $this->getMockBuilder(JwtPayloadValidatorInterface::class)
64-
->onlyMethods(['validate'])
65-
->disableOriginalConstructor()
66-
->getMockForAbstractClass();
66+
$this->jwtPayloadValidatorMock = $this->createMock(JwtPayloadValidatorInterface::class);
6767

6868
$this->model = $this->objectManager->getObject(
6969
JwtParser::class,

app/code/Magento/CardinalCommerce/Test/Unit/Model/Response/JwtPayloadValidatorTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
namespace Magento\CardinalCommerce\Test\Unit\Model\Response;
99

10+
use DateTimeZone;
1011
use Magento\CardinalCommerce\Model\Response\JwtPayloadValidator;
1112
use Magento\Framework\Intl\DateTimeFactory;
1213
use PHPUnit\Framework\TestCase;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1315

1416
class JwtPayloadValidatorTest extends TestCase
1517
{
@@ -30,8 +32,8 @@ protected function setUp(): void
3032
* Tests successful cases.
3133
*
3234
* @param array $token
33-
* @dataProvider validateSuccessDataProvider
3435
*/
36+
#[DataProvider('validateSuccessDataProvider')]
3537
public function testValidateSuccess(array $token)
3638
{
3739
$this->assertTrue(
@@ -65,6 +67,7 @@ public static function validateSuccessDataProvider()
6567
* @param array $token
6668
* @dataProvider validationEciFailsDataProvider
6769
*/
70+
#[DataProvider('validationEciFailsDataProvider')]
6871
public function testValidationEciFails(array $token)
6972
{
7073
$this->assertFalse(
@@ -93,8 +96,8 @@ public static function validationEciFailsDataProvider(): array
9396
* Case when resulting state of the transaction is negative.
9497
*
9598
* @param array $token
96-
* @dataProvider validationActionCodeFailsDataProvider
9799
*/
100+
#[DataProvider('validationActionCodeFailsDataProvider')]
98101
public function testValidationActionCodeFails(array $token)
99102
{
100103
$this->assertFalse(
@@ -180,7 +183,7 @@ private static function createToken(string $eciFlag, string $errorNumber, string
180183
private static function getValidExpTimestamp()
181184
{
182185
$dateTimeFactory = new DateTimeFactory();
183-
$currentDate = $dateTimeFactory->create('now', new \DateTimeZone('UTC'));
186+
$currentDate = $dateTimeFactory->create('now', new DateTimeZone('UTC'));
184187

185188
return $currentDate->getTimestamp() + 3600;
186189
}
@@ -193,7 +196,7 @@ private static function getValidExpTimestamp()
193196
private function getOutdatedExpTimestamp()
194197
{
195198
$dateTimeFactory = new DateTimeFactory();
196-
$currentDate = $dateTimeFactory->create('now', new \DateTimeZone('UTC'));
199+
$currentDate = $dateTimeFactory->create('now', new DateTimeZone('UTC'));
197200

198201
return $currentDate->getTimestamp() - 3600;
199202
}

app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\OfflinePayments\Test\Unit\Block\Form;
99

10-
use Magento\Framework\View\Element\Template\Context;
1110
use Magento\OfflinePayments\Block\Form\AbstractInstruction;
1211
use Magento\Payment\Model\MethodInterface;
1312
use PHPUnit\Framework\TestCase;
@@ -21,17 +20,15 @@ class AbstractInstructionTest extends TestCase
2120

2221
protected function setUp(): void
2322
{
24-
$context = $this->createMock(Context::class);
25-
$this->model = $this->getMockForAbstractClass(
26-
AbstractInstruction::class,
27-
['context' => $context]
28-
);
23+
$this->model = $this->getMockBuilder(AbstractInstruction::class)
24+
->disableOriginalConstructor()
25+
->onlyMethods([])
26+
->getMock();
2927
}
3028

3129
public function testGetInstructions()
3230
{
33-
$method = $this->getMockBuilder(MethodInterface::class)
34-
->getMockForAbstractClass();
31+
$method = $this->createMock(MethodInterface::class);
3532

3633
$method->expects($this->once())
3734
->method('getConfigData')

app/code/Magento/OfflinePayments/Test/Unit/Block/Info/CheckmoTest.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\View\Element\Template\Context;
1111
use Magento\OfflinePayments\Block\Info\Checkmo;
1212
use Magento\Payment\Model\Info;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -33,15 +34,9 @@ class CheckmoTest extends TestCase
3334
*/
3435
protected function setUp(): void
3536
{
36-
$context = $this->getMockBuilder(Context::class)
37-
->disableOriginalConstructor()
38-
->addMethods([])
39-
->getMock();
37+
$context = $this->createMock(Context::class);
4038

41-
$this->infoMock = $this->getMockBuilder(Info::class)
42-
->disableOriginalConstructor()
43-
->onlyMethods(['getAdditionalInformation'])
44-
->getMock();
39+
$this->infoMock = $this->createPartialMock(Info::class, ['getAdditionalInformation']);
4540

4641
$this->block = new Checkmo($context);
4742
}
@@ -51,9 +46,9 @@ protected function setUp(): void
5146
* @param string|null $expected
5247
*
5348
* @return void
54-
* @dataProvider getPayableToDataProvider
5549
* @covers \Magento\OfflinePayments\Block\Info\Checkmo::getPayableTo
5650
*/
51+
#[DataProvider('getPayableToDataProvider')]
5752
public function testGetPayableTo($details, $expected): void
5853
{
5954
$this->infoMock
@@ -76,7 +71,7 @@ public function testGetPayableTo($details, $expected): void
7671
public static function getPayableToDataProvider(): array
7772
{
7873
return [
79-
['details' => 'payable', 'payable'],
74+
['payable', 'payable'],
8075
['', null]
8176
];
8277
}
@@ -86,9 +81,9 @@ public static function getPayableToDataProvider(): array
8681
* @param string|null $expected
8782
*
8883
* @return void
89-
* @dataProvider getMailingAddressDataProvider
9084
* @covers \Magento\OfflinePayments\Block\Info\Checkmo::getMailingAddress
9185
*/
86+
#[DataProvider('getMailingAddressDataProvider')]
9287
public function testGetMailingAddress($details, $expected): void
9388
{
9489
$this->infoMock
@@ -114,8 +109,8 @@ public function testGetMailingAddress($details, $expected): void
114109
public static function getMailingAddressDataProvider(): array
115110
{
116111
return [
117-
['details' => 'blah@blah.com', 'blah@blah.com'],
118-
['details' => '', null]
112+
['blah@blah.com', 'blah@blah.com'],
113+
['', null]
119114
];
120115
}
121116

app/code/Magento/OfflinePayments/Test/Unit/Model/BanktransferTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class BanktransferTest extends TestCase
3131
protected function setUp(): void
3232
{
3333
$objectManagerHelper = new ObjectManager($this);
34-
$eventManager = $this->getMockForAbstractClass(ManagerInterface::class);
34+
$eventManager = $this->createMock(ManagerInterface::class);
3535
$paymentDataMock = $this->createMock(Data::class);
36-
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
36+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
3737
$this->object = $objectManagerHelper->getObject(
3838
Banktransfer::class,
3939
[

app/code/Magento/OfflinePayments/Test/Unit/Model/CashondeliveryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ protected function setUp(): void
3232
{
3333
$helper = new ObjectManager($this);
3434

35-
$eventManager = $this->getMockForAbstractClass(ManagerInterface::class);
35+
$eventManager = $this->createMock(ManagerInterface::class);
3636
$paymentDataMock = $this->createMock(Data::class);
3737

38-
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
38+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
3939
$this->object = $helper->getObject(
4040
Cashondelivery::class,
4141
[

app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\OfflinePayments\Model\Checkmo;
1212
use Magento\OfflinePayments\Model\CheckmoConfigProvider;
1313
use Magento\Payment\Helper\Data as PaymentHelper;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617

@@ -58,8 +59,8 @@ protected function setUp(): void
5859
* @param string $mailingAddress
5960
* @param string $payableTo
6061
* @param array $result
61-
* @dataProvider dataProviderGetConfig
6262
*/
63+
#[DataProvider('dataProviderGetConfig')]
6364
public function testGetConfig($isAvailable, $mailingAddress, $payableTo, $result)
6465
{
6566
$this->methodMock->expects($this->once())

app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CheckmoTest extends TestCase
3030
protected function setUp(): void
3131
{
3232
$objectManagerHelper = new ObjectManager($this);
33-
$eventManager = $this->getMockForAbstractClass(ManagerInterface::class);
33+
$eventManager = $this->createMock(ManagerInterface::class);
3434
$paymentDataMock = $this->createMock(Data::class);
3535
$this->scopeConfigMock = $this->createPartialMock(ScopeConfigInterface::class, ['getValue', 'isSetFlag']);
3636
$this->object = $objectManagerHelper->getObject(

app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
namespace Magento\OfflinePayments\Test\Unit\Model;
99

1010
use Magento\Framework\Escaper;
11+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1112
use Magento\OfflinePayments\Model\Banktransfer;
1213
use Magento\OfflinePayments\Model\Cashondelivery;
1314
use Magento\OfflinePayments\Model\InstructionsConfigProvider;
1415
use Magento\Payment\Helper\Data as PaymentHelper;
1516
use Magento\Payment\Model\Method\AbstractMethod;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1618
use PHPUnit\Framework\MockObject\MockObject;
1719
use PHPUnit\Framework\TestCase;
1820

1921
class InstructionsConfigProviderTest extends TestCase
2022
{
23+
use MockCreationTrait;
24+
2125
/**
2226
* @var InstructionsConfigProvider
2327
*/
@@ -40,16 +44,14 @@ class InstructionsConfigProviderTest extends TestCase
4044

4145
protected function setUp(): void
4246
{
43-
$this->methodOneMock = $this->getMockBuilder(AbstractMethod::class)
44-
->addMethods(['getInstructions'])
45-
->onlyMethods(['isAvailable'])
46-
->disableOriginalConstructor()
47-
->getMockForAbstractClass();
48-
$this->methodTwoMock = $this->getMockBuilder(AbstractMethod::class)
49-
->addMethods(['getInstructions'])
50-
->onlyMethods(['isAvailable'])
51-
->disableOriginalConstructor()
52-
->getMockForAbstractClass();
47+
$this->methodOneMock = $this->createPartialMockWithReflection(
48+
AbstractMethod::class,
49+
['getInstructions', 'isAvailable']
50+
);
51+
$this->methodTwoMock = $this->createPartialMockWithReflection(
52+
AbstractMethod::class,
53+
['getInstructions', 'isAvailable']
54+
);
5355

5456
/** @var PaymentHelper|MockObject $paymentHelperMock */
5557
$paymentHelperMock = $this->createMock(PaymentHelper::class);
@@ -77,8 +79,8 @@ protected function setUp(): void
7779
* @param bool $isTwoAvailable
7880
* @param string $instructionsTwo
7981
* @param array $result
80-
* @dataProvider dataProviderGetConfig
8182
*/
83+
#[DataProvider('dataProviderGetConfig')]
8284
public function testGetConfig($isOneAvailable, $instructionsOne, $isTwoAvailable, $instructionsTwo, $result)
8385
{
8486
$this->methodOneMock->expects($this->once())

0 commit comments

Comments
 (0)