Skip to content

Commit 0cb8b17

Browse files
Merge pull request #443 from magento-folks/bugs
Bug MAGETWO-57852 [FT] There is no "Reset filter" button on grids that use UI grid component MAGETWO-58133 Incorrect number of login failures to lock Customer account MAGETWO-56587 [FT] Fix AssertProductDataInMiniShoppingCart constraint MAGETWO-54109 Unskip Tests which Refer to Already Closed Tickets MAGETWO-57986 [FT] Can not get discount price in shopping cart
2 parents 353ef4f + 32e5b0b commit 0cb8b17

File tree

34 files changed

+738
-1229
lines changed

34 files changed

+738
-1229
lines changed

app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php

Lines changed: 177 additions & 397 deletions
Large diffs are not rendered by default.

app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,14 @@ public function testSetData()
245245
*/
246246
public function testSetDataWithMultidimensionalArray()
247247
{
248-
$this->markTestSkipped('Need to revert changes from MAGETWO-39106 and then modify this test.');
249248
$expected = [
250249
'key' => 'value',
251-
'array' => 'value1',
250+
'street' => 'value1',
252251
];
253252

254253
$key = [
255254
'key' => 'value',
256-
'array' => [
255+
'street' => [
257256
'key1' => 'value1',
258257
]
259258
];

app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php

Lines changed: 63 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase
4040
*/
4141
protected $addressRepository;
4242

43+
/**
44+
* @var \PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
private $shippingAssignmentMock;
47+
4348
/**
4449
* @return void
4550
*/
@@ -59,6 +64,19 @@ protected function setUp()
5964
'addressRepository' => $this->addressRepository
6065
]
6166
);
67+
68+
$this->shippingAssignmentMock = $this->getMock(
69+
\Magento\Quote\Model\ShippingAddressAssignment::class,
70+
['setAddress'],
71+
[],
72+
'',
73+
false
74+
);
75+
$this->objectManager->setBackwardCompatibleProperty(
76+
$this->model,
77+
'shippingAddressAssignment',
78+
$this->shippingAssignmentMock
79+
);
6280
}
6381

6482
/**
@@ -76,95 +94,44 @@ public function testGetAddress()
7694
$this->assertEquals($addressMock, $this->model->get('cartId'));
7795
}
7896

79-
/**
80-
* @return void
81-
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
82-
* @expectedExceptionMessage error123
83-
*/
84-
public function testSetAddressValidationFailed()
85-
{
86-
$this->markTestSkipped('MAGETWO-48531');
87-
$address = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class);
88-
$quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false);
89-
$this->quoteRepositoryMock->expects($this->once())
90-
->method('getActive')
91-
->with('cartId')
92-
->will($this->returnValue($quoteMock));
93-
94-
$this->validatorMock->expects($this->once())
95-
->method('validate')
96-
->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException(__('error123'))));
97-
98-
$this->model->assign('cartId', $address);
99-
}
100-
10197
/**
10298
* @return void
10399
*/
104100
public function testSetAddress()
105101
{
106-
$this->markTestSkipped('MAGETWO-48531');
107102
$cartId = 100;
108103
$useForShipping = true;
109104
$addressId = 1;
110-
$customerAddressId = 10;
111105

112106
$address = $this->getMock(
113107
\Magento\Quote\Model\Quote\Address::class,
114-
['setSaveInAddressBook', 'getCustomerAddressId', 'getSaveInAddressBook'],
108+
['getId'],
115109
[],
116110
'',
117111
false
118112
);
119-
$quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false);
120-
121-
$this->quoteRepositoryMock->expects($this->once())
122-
->method('getActive')
123-
->with($cartId)
124-
->willReturn($quoteMock);
125-
$this->validatorMock->expects($this->once())->method('validate')
126-
->with($address)
127-
->willReturn(true);
128-
129-
$address->expects($this->once())->method('getCustomerAddressId')->willReturn($customerAddressId);
130-
$address->expects($this->once())->method('getSaveInAddressBook')->willReturn(1);
131-
132-
$customerAddressMock = $this->getMock(\Magento\Customer\Api\Data\AddressInterface::class, [], [], '', false);
133-
$this->addressRepository->expects($this->once())
134-
->method('getById')
135-
->with($customerAddressId)
136-
->willReturn($customerAddressMock);
137-
138-
$quoteBillingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false);
139-
$quoteBillingAddress->expects($this->once())->method('getId')->will($this->returnValue($addressId));
140-
$quoteMock->expects($this->exactly(2))->method('getBillingAddress')->willReturn($quoteBillingAddress);
141-
$quoteBillingAddress->expects($this->once())
142-
->method('importCustomerAddressData')
143-
->with($customerAddressMock)
144-
->willReturnSelf();
145-
146-
$quoteShippingAddress = $this->getMock(
147-
\Magento\Quote\Model\Quote\Address::class,
148-
['setSaveInAddressBook', 'setSameAsBilling', 'setCollectShippingRates', 'importCustomerAddressData'],
113+
$quoteMock = $this->getMock(
114+
\Magento\Quote\Model\Quote::class,
115+
['removeAddress', 'getBillingAddress', 'setBillingAddress', 'setDataChanges'],
149116
[],
150117
'',
151118
false
152119
);
153-
$quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($quoteShippingAddress);
154-
$quoteShippingAddress->expects($this->once())
155-
->method('importCustomerAddressData')
156-
->with($customerAddressMock)
157-
->willReturnSelf();
158-
$quoteShippingAddress->expects($this->once())->method('setSaveInAddressBook')->with(1)->willReturnSelf();
159120

160-
$quoteBillingAddress->expects($this->once())->method('setSaveInAddressBook')->with(1)->willReturnSelf();
161-
$quoteMock->expects($this->once())->method('setBillingAddress')->with($quoteBillingAddress)->willReturnSelf();
121+
$this->quoteRepositoryMock->expects($this->once())
122+
->method('getActive')
123+
->with($cartId)
124+
->willReturn($quoteMock);
162125

163-
$quoteShippingAddress->expects($this->once())->method('setSameAsBilling')->with(1)->willReturnSelf();
164-
$quoteShippingAddress->expects($this->once())->method('setCollectShippingRates')->with(true)->willReturnSelf();
126+
$address->expects($this->exactly(2))->method('getId')->willReturn($addressId);
127+
$quoteMock->expects($this->exactly(2))->method('getBillingAddress')->willReturn($address);
128+
$quoteMock->expects($this->once())->method('removeAddress')->with($addressId)->willReturnSelf();
129+
$quoteMock->expects($this->once())->method('setBillingAddress')->with($address)->willReturnSelf();
130+
$quoteMock->expects($this->once())->method('setDataChanges')->with(1)->willReturnSelf();
165131

166-
$quoteMock->expects($this->once())->method('setShippingAddress')->with($quoteShippingAddress);
167-
$quoteMock->expects($this->once())->method('setDataChanges')->with(true);
132+
$this->shippingAssignmentMock->expects($this->once())
133+
->method('setAddress')
134+
->with($quoteMock, $address, $useForShipping);
168135

169136
$this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock);
170137
$this->assertEquals($addressId, $this->model->assign($cartId, $address, $useForShipping));
@@ -177,27 +144,45 @@ public function testSetAddress()
177144
*/
178145
public function testSetAddressWithInabilityToSaveQuote()
179146
{
180-
$this->markTestSkipped('MAGETWO-48531');
181-
$address = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false, false);
147+
$cartId = 100;
148+
$addressId = 1;
149+
150+
$address = $this->getMock(
151+
\Magento\Quote\Model\Quote\Address::class,
152+
['getId'],
153+
[],
154+
'',
155+
false
156+
);
157+
$quoteMock = $this->getMock(
158+
\Magento\Quote\Model\Quote::class,
159+
['removeAddress', 'getBillingAddress', 'setBillingAddress', 'setDataChanges'],
160+
[],
161+
'',
162+
false
163+
);
182164

183-
$quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false);
184165
$this->quoteRepositoryMock->expects($this->once())
185166
->method('getActive')
186-
->with('cartId')
187-
->will($this->returnValue($quoteMock));
167+
->with($cartId)
168+
->willReturn($quoteMock);
169+
170+
$address->expects($this->once())->method('getId')->willReturn($addressId);
171+
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($address);
172+
$quoteMock->expects($this->once())->method('removeAddress')->with($addressId)->willReturnSelf();
173+
$quoteMock->expects($this->once())->method('setBillingAddress')->with($address)->willReturnSelf();
174+
$quoteMock->expects($this->once())->method('setDataChanges')->with(1)->willReturnSelf();
188175

189-
$this->validatorMock->expects($this->once())->method('validate')
190-
->with($address)
191-
->will($this->returnValue(true));
176+
$this->shippingAssignmentMock->expects($this->once())
177+
->method('setAddress')
178+
->with($quoteMock, $address, false);
192179

193-
$quoteMock->expects($this->once())->method('setBillingAddress')->with($address);
194-
$quoteMock->expects($this->once())->method('setDataChanges')->with(true);
195180
$this->quoteRepositoryMock->expects($this->once())
196181
->method('save')
197182
->with($quoteMock)
198183
->willThrowException(
199184
new \Exception('Some DB Error')
200185
);
201-
$this->model->assign('cartId', $address);
186+
$this->model->assign($cartId, $address);
202187
}
203188
}

0 commit comments

Comments
 (0)