Skip to content

Commit fb72f9d

Browse files
committed
Fix unit tests
1 parent 56256a6 commit fb72f9d

File tree

7 files changed

+75
-35
lines changed

7 files changed

+75
-35
lines changed

app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPal/VaultDetailsHandlerTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use Braintree\Result\Successful;
99
use Braintree\Transaction;
1010
use Braintree\Transaction\PayPalDetails;
11-
use Magento\Braintree\Gateway\SubjectReader;
1211
use Magento\Braintree\Gateway\Response\PayPal\VaultDetailsHandler;
12+
use Magento\Braintree\Gateway\SubjectReader;
1313
use Magento\Framework\Intl\DateTimeFactory;
1414
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1515
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
@@ -99,7 +99,12 @@ protected function setUp()
9999
->getMock();
100100

101101
$this->paymentExtensionMock = $this->getMockBuilder(OrderPaymentExtensionInterface::class)
102-
->setMethods(['setVaultPaymentToken', 'getVaultPaymentToken'])
102+
->setMethods([
103+
'setVaultPaymentToken',
104+
'getVaultPaymentToken',
105+
'setNotificationMessage',
106+
'getNotificationMessage'
107+
])
103108
->disableOriginalConstructor()
104109
->getMock();
105110
$this->paymentExtensionFactoryMock = $this->getMockBuilder(OrderPaymentExtensionInterfaceFactory::class)
@@ -119,7 +124,7 @@ protected function setUp()
119124
->disableOriginalConstructor()
120125
->setMethods(['create'])
121126
->getMock();
122-
127+
123128
$this->handler = new VaultDetailsHandler(
124129
$this->paymentTokenFactoryMock,
125130
$this->paymentExtensionFactoryMock,
@@ -139,7 +144,7 @@ public function testHandle()
139144
->with($this->paymentTokenMock);
140145
$this->paymentExtensionMock->method('getVaultPaymentToken')
141146
->willReturn($this->paymentTokenMock);
142-
147+
143148
$this->paymentDataObjectMock->method('getPayment')
144149
->willReturn($this->paymentInfoMock);
145150

@@ -154,7 +159,7 @@ public function testHandle()
154159
$expirationDate = '2017-07-05 00:00:00';
155160
$this->dateTimeFactoryMock->method('create')
156161
->willReturn($dateTime);
157-
162+
158163
$this->handler->handle($this->subject, $response);
159164

160165
$extensionAttributes = $this->paymentInfoMock->getExtensionAttributes();

app/code/Magento/Braintree/Test/Unit/Gateway/Response/VaultDetailsHandlerTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use PHPUnit_Framework_MockObject_MockObject as MockObject;
2626

2727
/**
28-
* VaultDetailsHandler Test
28+
* Verify class VaultDetailsHandler
2929
*
3030
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3131
*/
@@ -216,7 +216,12 @@ private function getConfigMock(): Config
216216
private function initPaymentExtensionAttributesMock()
217217
{
218218
$this->paymentExtension = $this->getMockBuilder(OrderPaymentExtensionInterface::class)
219-
->setMethods(['setVaultPaymentToken', 'getVaultPaymentToken'])
219+
->setMethods([
220+
'setVaultPaymentToken',
221+
'getVaultPaymentToken',
222+
'setNotificationMessage',
223+
'getNotificationMessage'
224+
])
220225
->disableOriginalConstructor()
221226
->getMock();
222227

app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function testAddChildNonExistingOption()
391391
}
392392

393393
/**
394-
* @ex@expectedException \Magento\Framework\Exception\InputException
394+
* @expectedException \Magento\Framework\Exception\InputException
395395
* @expectedExceptionMessage The bundle product can't contain another composite product.
396396
*/
397397
public function testAddChildLinkedProductIsComposite()
@@ -449,7 +449,7 @@ public function testAddChildLinkedProductIsComposite()
449449
}
450450

451451
/**
452-
* @ex@expectedException \Magento\Framework\Exception\CouldNotSaveException
452+
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
453453
*/
454454
public function testAddChildProductAlreadyExistsInOption()
455455
{
@@ -525,7 +525,7 @@ public function testAddChildProductAlreadyExistsInOption()
525525
}
526526

527527
/**
528-
* @ex@expectedException \Magento\Framework\Exception\CouldNotSaveException
528+
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
529529
*/
530530
public function testAddChildCouldNotSave()
531531
{
@@ -759,7 +759,7 @@ public function testSaveChild()
759759
}
760760

761761
/**
762-
* @ex@expectedException \Magento\Framework\Exception\CouldNotSaveException
762+
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
763763
*/
764764
public function testSaveChildFailedToSave()
765765
{
@@ -842,7 +842,7 @@ public function testSaveChildFailedToSave()
842842
}
843843

844844
/**
845-
* @ex@expectedException \Magento\Framework\Exception\InputException
845+
* @expectedException \Magento\Framework\Exception\InputException
846846
*/
847847
public function testSaveChildWithoutId()
848848
{
@@ -874,7 +874,7 @@ public function testSaveChildWithoutId()
874874
}
875875

876876
/**
877-
* @ex@expectedException \Magento\Framework\Exception\InputException
877+
* @expectedException \Magento\Framework\Exception\InputException
878878
* @expectedExceptionMessage The product link with the "12345" ID field wasn't found. Verify the ID and try again.
879879
*/
880880
public function testSaveChildWithInvalidId()
@@ -925,7 +925,7 @@ public function testSaveChildWithInvalidId()
925925
}
926926

927927
/**
928-
* @ex@expectedException \Magento\Framework\Exception\InputException
928+
* @expectedException \Magento\Framework\Exception\InputException
929929
*/
930930
public function testSaveChildWithCompositeProductLink()
931931
{
@@ -954,7 +954,7 @@ public function testSaveChildWithCompositeProductLink()
954954
}
955955

956956
/**
957-
* @ex@expectedException \Magento\Framework\Exception\InputException
957+
* @expectedException \Magento\Framework\Exception\InputException
958958
*/
959959
public function testSaveChildWithSimpleProduct()
960960
{
@@ -1016,7 +1016,7 @@ public function testRemoveChild()
10161016
}
10171017

10181018
/**
1019-
* @ex@expectedException \Magento\Framework\Exception\InputException
1019+
* @expectedException \Magento\Framework\Exception\InputException
10201020
*/
10211021
public function testRemoveChildForbidden()
10221022
{

app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionsTest.php

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@
77

88
namespace Magento\Bundle\Test\Unit\Pricing\Price;
99

10-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
11-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
12-
use Magento\Framework\Pricing\Amount\AmountFactory;
13-
use Magento\Framework\Pricing\Adjustment\Calculator as AdjustmentCalculator;
14-
use Magento\Framework\Pricing\PriceInfo\Base as BasePriceInfo;
15-
use Magento\Framework\Pricing\PriceCurrencyInterface;
16-
use Magento\Framework\Pricing\Amount\AmountInterface;
17-
use Magento\Framework\Pricing\Amount\Base as BaseAmount;
18-
use Magento\Bundle\Pricing\Price\BundleOptions;
19-
use Magento\Bundle\Pricing\Price\BundleSelectionPrice;
20-
use Magento\Bundle\Pricing\Price\BundleSelectionFactory;
21-
use Magento\Bundle\Pricing\Adjustment\Calculator as BundleAdjustmentCalculator;
2210
use Magento\Bundle\Model\Option as BundleOption;
2311
use Magento\Bundle\Model\Product\Type as BundleProductType;
2412
use Magento\Bundle\Model\ResourceModel\Option\Collection as BundleOptionCollection;
13+
use Magento\Bundle\Pricing\Adjustment\Calculator as BundleAdjustmentCalculator;
14+
use Magento\Bundle\Pricing\Adjustment\SelectionPriceListProviderInterface;
15+
use Magento\Bundle\Pricing\Price\BundleOptions;
16+
use Magento\Bundle\Pricing\Price\BundleSelectionFactory;
17+
use Magento\Bundle\Pricing\Price\BundleSelectionPrice;
2518
use Magento\Catalog\Model\Product;
19+
use Magento\Framework\Pricing\Adjustment\Calculator as AdjustmentCalculator;
20+
use Magento\Framework\Pricing\Amount\AmountFactory;
21+
use Magento\Framework\Pricing\Amount\AmountInterface;
22+
use Magento\Framework\Pricing\Amount\Base as BaseAmount;
23+
use Magento\Framework\Pricing\PriceCurrencyInterface;
24+
use Magento\Framework\Pricing\PriceInfo\Base as BasePriceInfo;
25+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
2626
use Magento\Tax\Helper\Data as TaxHelperData;
27+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
2728

2829
/**
2930
* Test for Magento\Bundle\Pricing\Price\BundleOptions
@@ -71,6 +72,11 @@ class BundleOptionsTest extends \PHPUnit\Framework\TestCase
7172
*/
7273
private $priceInfoMock;
7374

75+
/**
76+
* @var SelectionPriceListProviderInterface
77+
*/
78+
private $selectionPriceListProviderMock;
79+
7480
protected function setUp()
7581
{
7682
$this->priceInfoMock = $this->getMockBuilder(BasePriceInfo::class)
@@ -102,9 +108,20 @@ function ($fullAmount, $adjustments) {
102108
->disableOriginalConstructor()
103109
->getMock();
104110

111+
$this->selectionPriceListProviderMock = $this->getMockBuilder(SelectionPriceListProviderInterface::class)
112+
->disableOriginalConstructor()
113+
->getMock();
114+
105115
$this->bundleCalculatorMock = $this->getMockBuilder(BundleAdjustmentCalculator::class)
106116
->setConstructorArgs(
107-
[$this->baseCalculator, $this->amountFactory, $this->selectionFactoryMock, $taxData, $priceCurrency]
117+
[
118+
$this->baseCalculator,
119+
$this->amountFactory,
120+
$this->selectionFactoryMock,
121+
$taxData,
122+
$priceCurrency,
123+
$this->selectionPriceListProviderMock
124+
]
108125
)
109126
->setMethods(['getOptionsAmount'])
110127
->getMock();

app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
namespace Magento\Newsletter\Test\Unit\Model\Plugin;
77

88
use Magento\Customer\Api\CustomerRepositoryInterface;
9+
use Magento\Customer\Api\Data\CustomerExtensionInterface;
910
use Magento\Customer\Api\Data\CustomerInterface;
1011
use Magento\Customer\Model\Config\Share;
1112
use Magento\Customer\Model\ResourceModel\CustomerRepository;
12-
use Magento\Customer\Api\Data\CustomerExtensionInterface;
1313
use Magento\Framework\Api\ExtensionAttributesFactory;
1414
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1515
use Magento\Newsletter\Model\Plugin\CustomerPlugin;
@@ -134,7 +134,13 @@ public function testAfterSave(?int $originalStatus, ?bool $newValue, ?bool $expe
134134
}
135135
$this->subscriberFactory->method('create')->willReturn($subscriber);
136136

137-
$customerExtension = $this->createPartialMock(CustomerExtensionInterface::class, ['getIsSubscribed']);
137+
$customerExtension = $this->createPartialMock(
138+
CustomerExtensionInterface::class,
139+
[
140+
'getIsSubscribed',
141+
'CustomerExtensionInterface'
142+
]
143+
);
138144
$customerExtension->method('getIsSubscribed')->willReturn($newValue);
139145
/** @var CustomerInterface|MockObject $customer */
140146
$customer = $this->createMock(CustomerInterface::class);
@@ -152,7 +158,14 @@ public function testAfterSave(?int $originalStatus, ?bool $newValue, ?bool $expe
152158
$this->subscriptionManager->expects($this->never())->method('subscribeCustomer');
153159
$this->subscriptionManager->expects($this->never())->method('unsubscribeCustomer');
154160
}
155-
$resultExtension = $this->createPartialMock(CustomerExtensionInterface::class, ['setIsSubscribed']);
161+
$resultExtension = $this->createPartialMock(
162+
CustomerExtensionInterface::class,
163+
[
164+
'setIsSubscribed',
165+
'getIsSubscribed',
166+
'CustomerExtensionInterface'
167+
]
168+
);
156169
$resultExtension->expects($this->once())->method('setIsSubscribed')->with($resultIsSubscribed);
157170
/** @var CustomerInterface|MockObject $result */
158171
$result = $this->createMock(CustomerInterface::class);
@@ -291,7 +304,7 @@ public function testAfterGetByIdCreatesExtensionAttributes(): void
291304

292305
$customerExtension = $this->createPartialMock(
293306
CustomerExtensionInterface::class,
294-
['getIsSubscribed', 'setIsSubscribed']
307+
['getIsSubscribed', 'setIsSubscribed','CustomerExtensionInterface']
295308
);
296309
$customerExtension->expects($this->once())->method('setIsSubscribed')->with($subscribed);
297310
$this->extensionFactory->expects($this->once())->method('create')->willReturn($customerExtension);

app/code/Magento/WeeeGraphQl/Test/Unit/FixedProductTaxTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function setUp()
5858
->getMock();
5959

6060
$this->extensionAttributesMock = $this->getMockBuilder(ContextExtensionInterface::class)
61-
->setMethods(['getStore'])
61+
->setMethods(['getStore', 'setStore', 'getIsCustomer', 'setIsCustomer'])
6262
->getMock();
6363

6464
$this->contextMock->method('getExtensionAttributes')

app/code/Magento/WishlistGraphQl/Test/Unit/CustomerWishlistResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function setUp()
5858
->getMock();
5959

6060
$this->extensionAttributesMock = $this->getMockBuilder(ContextExtensionInterface::class)
61-
->setMethods(['getIsCustomer'])
61+
->setMethods(['getStore', 'setStore', 'getIsCustomer', 'setIsCustomer'])
6262
->getMock();
6363

6464
$this->contextMock->method('getExtensionAttributes')

0 commit comments

Comments
 (0)