Skip to content

Commit 79bacd3

Browse files
committed
MAGETWO-57868: Search fails with an error when used user-defined price attribute as searchable - for mainline
2 parents 8949550 + 0cb8b17 commit 79bacd3

File tree

48 files changed

+842
-1257
lines changed

Some content is hidden

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

48 files changed

+842
-1257
lines changed

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testToHtml()
5353
->disableOriginalConstructor()
5454
->setMethods(['dispatch'])
5555
->getMock();
56-
$eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true));
56+
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
5757

5858
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
5959
->setMethods(['getValue'])

app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function testGetProductsCount()
186186

187187
protected function generalGetProductCollection()
188188
{
189-
$this->eventManager->expects($this->once())->method('dispatch')
189+
$this->eventManager->expects($this->exactly(2))->method('dispatch')
190190
->will($this->returnValue(true));
191191
$this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
192192
->willReturn(false);

app/code/Magento/CatalogInventory/Model/Stock/Status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getWebsiteId()
100100
*/
101101
public function getStockId()
102102
{
103-
return $this->getData(self::KEY_WEBSITE_ID);
103+
return $this->getData(self::KEY_STOCK_ID);
104104
}
105105

106106
/**

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/Email/Model/AbstractTemplate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,13 @@ public function getTemplateFilter()
663663
* Save current design config and replace with design config from specified store
664664
* Event is not dispatched.
665665
*
666-
* @param int|string $storeId
666+
* @param null|bool|int|string $storeId
667667
* @param string $area
668668
* @return void
669669
*/
670670
public function emulateDesign($storeId, $area = self::DEFAULT_DESIGN_AREA)
671671
{
672-
if ($storeId) {
672+
if ($storeId !== null && $storeId !== false) {
673673
// save current design settings
674674
$this->emulatedDesignConfig = clone $this->getDesignConfig();
675675
if (

app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,24 @@ public function testEmulateDesignAndRevertDesign()
331331
{
332332
$model = $this->getModelMock();
333333
$originalConfig = ['area' => 'some_area', 'store' => 1];
334-
$expectedConfig = ['area' => 'frontend', 'store' => 2];
335334
$model->setDesignConfig($originalConfig);
336335

337-
$model->emulateDesign(2);
338-
// assert config data has been emulated
339-
$this->assertEquals($expectedConfig, $model->getDesignConfig()->getData());
340-
341-
$model->revertDesign();
342-
// assert config data has been reverted to the original state
343-
$this->assertEquals($originalConfig, $model->getDesignConfig()->getData());
336+
$expectedConfigs = [
337+
['in' => ['area' => 'frontend', 'store' => null], 'out' => $originalConfig],
338+
['in' => ['area' => 'frontend', 'store' => false], 'out' => $originalConfig],
339+
['in' => ['area' => 'frontend', 'store' => 0], 'out' => ['area' => 'frontend', 'store' => 0]],
340+
['in' => ['area' => 'frontend', 'store' => 1], 'out' => ['area' => 'frontend', 'store' => 1]],
341+
['in' => ['area' => 'frontend', 'store' => 2], 'out' => ['area' => 'frontend', 'store' => 2]],
342+
];
343+
foreach ($expectedConfigs as $set) {
344+
$model->emulateDesign($set['in']['store'], $set['in']['area']);
345+
// assert config data has been emulated
346+
$this->assertEquals($set['out'], $model->getDesignConfig()->getData());
347+
348+
$model->revertDesign();
349+
// assert config data has been reverted to the original state
350+
$this->assertEquals($originalConfig, $model->getDesignConfig()->getData());
351+
}
344352
}
345353

346354
public function testGetDesignConfig()

app/code/Magento/Paypal/Model/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ public function isOrderReviewStepDisabled()
866866
*/
867867
public function getExpressCheckoutStartUrl($token)
868868
{
869-
return sprintf('https://www.%spaypal.com/checkoutnow/2%s',
869+
return sprintf('https://www.%spaypal.com/checkoutnow%s',
870870
$this->getValue('sandboxFlag') ? 'sandbox.' : '',
871871
'?token=' . urlencode($token));
872872
}

app/code/Magento/Paypal/Test/Unit/Block/Billing/AgreementsTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ public function testGetWizardPaymentMethodOptions()
235235
public function testToHtml()
236236
{
237237
$this->eventManager
238-
->expects($this->once())
238+
->expects($this->at(0))
239239
->method('dispatch')
240240
->with('view_block_abstract_to_html_before', ['block' => $this->block]);
241+
$transport = new \Magento\Framework\DataObject(['html' => '']);
242+
$this->eventManager
243+
->expects($this->at(1))
244+
->method('dispatch')
245+
->with('view_block_abstract_to_html_after', ['block' => $this->block, 'transport' => $transport]);
241246
$this->scopeConfig
242247
->expects($this->once())
243248
->method('getValue')

app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ public function testToHtml($customerId)
261261
$this->additional->setData('cache_lifetime', 789);
262262
$this->additional->setData('cache_key', 'cache-key');
263263

264-
$this->eventManagerMock->expects($this->once())
264+
$this->eventManagerMock->expects($this->at(0))
265265
->method('dispatch')
266266
->with('view_block_abstract_to_html_before', ['block' => $this->additional]);
267+
$this->eventManagerMock->expects($this->at(1))
268+
->method('dispatch')
269+
->with('view_block_abstract_to_html_after');
267270
$this->scopeConfigMock->expects($this->once())
268271
->method('getValue')
269272
->with(

app/code/Magento/Quote/Model/Quote/Payment.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class Payment extends \Magento\Payment\Model\Info implements PaymentInterface
6060
*/
6161
protected $methodSpecificationFactory;
6262

63+
/**
64+
* @var array
65+
*/
66+
private $additionalChecks;
67+
6368
/**
6469
* @param \Magento\Framework\Model\Context $context
6570
* @param \Magento\Framework\Registry $registry
@@ -71,6 +76,7 @@ class Payment extends \Magento\Payment\Model\Info implements PaymentInterface
7176
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
7277
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
7378
* @param array $data
79+
* @param array $additionalChecks
7480
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7581
*/
7682
public function __construct(
@@ -83,9 +89,11 @@ public function __construct(
8389
\Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory,
8490
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
8591
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
86-
array $data = []
92+
array $data = [],
93+
array $additionalChecks = []
8794
) {
8895
$this->methodSpecificationFactory = $methodSpecificationFactory;
96+
$this->additionalChecks = $additionalChecks;
8997
parent::__construct(
9098
$context,
9199
$registry,
@@ -162,7 +170,8 @@ public function importData(array $data)
162170
*/
163171
$quote->collectTotals();
164172

165-
$methodSpecification = $this->methodSpecificationFactory->create($data->getChecks());
173+
$checks = array_merge($data->getChecks(), $this->additionalChecks);
174+
$methodSpecification = $this->methodSpecificationFactory->create($checks);
166175
if (!$method->isAvailable($quote) || !$methodSpecification->isApplicable($method, $quote)) {
167176
throw new \Magento\Framework\Exception\LocalizedException(
168177
__('The requested Payment Method is not available.')

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)