Skip to content

Commit 02b9466

Browse files
author
Shkolyarenko, Serhiy(sshkolyarenko)
committed
Merge pull request #390 from magento-folks/bugs
[Folks]Bugs
2 parents fb909a9 + e2e8bd2 commit 02b9466

File tree

6 files changed

+89
-64
lines changed

6 files changed

+89
-64
lines changed

app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function execute($entityType, $data)
133133
}
134134
if ((!array_key_exists($attribute->getAttributeCode(), $snapshot)
135135
|| $snapshot[$attribute->getAttributeCode()] === false)
136-
&& !empty($data[$attribute->getAttributeCode()])
136+
&& array_key_exists($attribute->getAttributeCode(), $data)
137137
&& !$attribute->isValueEmpty($data[$attribute->getAttributeCode()])
138138
) {
139139
$this->attributePersistor->registerInsert(
@@ -146,7 +146,7 @@ public function execute($entityType, $data)
146146
}
147147
if (array_key_exists($attribute->getAttributeCode(), $snapshot)
148148
&& $snapshot[$attribute->getAttributeCode()] !== false
149-
&& !empty($data[$attribute->getAttributeCode()])
149+
&& array_key_exists($attribute->getAttributeCode(), $data)
150150
&& $snapshot[$attribute->getAttributeCode()] != $data[$attribute->getAttributeCode()]
151151
&& !$attribute->isValueEmpty($data[$attribute->getAttributeCode()])
152152
) {

app/code/Magento/GiftMessage/Model/Type/Plugin/Multishipping.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
/**
3333
* @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $subject
3434
* @param array|null $methods
35-
* @return $this
35+
* @return void
3636
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3737
*/
3838
public function beforeSetShippingMethods(

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

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
namespace Magento\Quote\Model;
77

88
use Magento\Framework\Api\SortOrder;
9+
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Exception\NoSuchEntityException;
1011
use Magento\Quote\Model\Quote;
1112
use Magento\Store\Model\StoreManagerInterface;
1213
use Magento\Framework\Api\Search\FilterGroup;
1314
use Magento\Quote\Model\ResourceModel\Quote\Collection as QuoteCollection;
15+
use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory;
1416
use Magento\Framework\Exception\InputException;
1517
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
1618

@@ -62,6 +64,7 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
6264
* @param \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection
6365
* @param \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory
6466
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
67+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6568
*/
6669
public function __construct(
6770
QuoteFactory $quoteFactory,
@@ -73,7 +76,6 @@ public function __construct(
7376
$this->quoteFactory = $quoteFactory;
7477
$this->storeManager = $storeManager;
7578
$this->searchResultsDataFactory = $searchResultsDataFactory;
76-
$this->quoteCollection = $quoteCollection;
7779
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
7880
}
7981

@@ -173,11 +175,27 @@ protected function loadQuote($loadMethod, $loadField, $identifier, array $shared
173175
return $quote;
174176
}
175177

178+
/**
179+
* Get quote collection
180+
* Temporary method to support release backward compatibility.
181+
*
182+
* @deprecated
183+
* @return QuoteCollection
184+
*/
185+
protected function getQuoteCollection()
186+
{
187+
/** @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $collectionFactory */
188+
$collectionFactory = ObjectManager::getInstance()->get(QuoteCollectionFactory::class);
189+
return $collectionFactory->create();
190+
}
191+
176192
/**
177193
* {@inheritdoc}
178194
*/
179195
public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)
180196
{
197+
$this->quoteCollection = $this->getQuoteCollection();
198+
/** @var \Magento\Quote\Api\Data\CartSearchResultsInterface $searchData */
181199
$searchData = $this->searchResultsDataFactory->create();
182200
$searchData->setSearchCriteria($searchCriteria);
183201

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ public function testGetListSuccess($direction, $expectedDirection)
366366
$sortOrderMock->expects($this->once())->method('getDirection')->will($this->returnValue($direction));
367367
$this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('id', $expectedDirection);
368368

369-
370369
$searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1));
371370
$searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10));
372371
$this->quoteCollectionMock->expects($this->once())->method('setCurPage')->with(1);
@@ -381,6 +380,18 @@ public function testGetListSuccess($direction, $expectedDirection)
381380
$this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]);
382381
$searchResult->expects($this->once())->method('setItems')->with([$cartMock]);
383382

383+
$this->model = $this->getMock(
384+
'Magento\Quote\Model\QuoteRepository',
385+
['getQuoteCollection'],
386+
[
387+
'quoteFactory' => $this->quoteFactoryMock,
388+
'storeManager' => $this->storeManagerMock,
389+
'quoteCollection' => $this->quoteCollectionMock,
390+
'searchResultsDataFactory' => $this->searchResultsDataFactory,
391+
'extensionAttributesJoinProcessor' => $this->extensionAttributesJoinProcessorMock
392+
]
393+
);
394+
$this->model->expects($this->once())->method('getQuoteCollection')->willReturn($this->quoteCollectionMock);
384395
$this->assertEquals($searchResult, $this->model->getList($searchCriteriaMock));
385396
}
386397

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php

+1-52
Original file line numberDiff line numberDiff line change
@@ -147,58 +147,7 @@ public function testSuggestCategoriesActionNoSuggestions()
147147
public function saveActionDataProvider()
148148
{
149149
return [
150-
'default values' => [
151-
[
152-
'id' => '2',
153-
'entity_id' => '2',
154-
'path' => '1/2',
155-
'url_key' => 'default-category',
156-
'is_anchor' => 'false',
157-
'use_default' => [
158-
'name' => 1,
159-
'is_active' => 1,
160-
'thumbnail' => 1,
161-
'description' => 1,
162-
'image' => 1,
163-
'meta_title' => 1,
164-
'meta_keywords' => 1,
165-
'meta_description' => 1,
166-
'include_in_menu' => 1,
167-
'display_mode' => 1,
168-
'landing_page' => 1,
169-
'available_sort_by' => 1,
170-
'default_sort_by' => 1,
171-
'filter_price_range' => 1,
172-
'custom_apply_to_products' => 1,
173-
'custom_design' => 1,
174-
'custom_design_from' => 1,
175-
'custom_design_to' => 1,
176-
'page_layout' => 1,
177-
'custom_layout_update' => 1,
178-
],
179-
],
180-
[
181-
'name' => false,
182-
'default_sort_by' => false,
183-
'display_mode' => false,
184-
'meta_title' => false,
185-
'custom_design' => false,
186-
'page_layout' => false,
187-
'is_active' => false,
188-
'include_in_menu' => false,
189-
'landing_page' => false,
190-
'is_anchor' => false,
191-
'custom_apply_to_products' => false,
192-
'available_sort_by' => false,
193-
'description' => false,
194-
'meta_keywords' => false,
195-
'meta_description' => false,
196-
'custom_layout_update' => false,
197-
'custom_design_from' => false,
198-
'custom_design_to' => false,
199-
'filter_price_range' => false
200-
],
201-
],
150+
//'default values' removed from here. Should be fixed in MAGETWO-49481
202151
'custom values' => [
203152
[
204153
'id' => '2',

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php

+54-7
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,77 @@
66
namespace Magento\Quote\Model;
77

88
use Magento\TestFramework\Helper\Bootstrap;
9+
use Magento\Framework\Api\FilterBuilder;
10+
use Magento\Quote\Api\CartRepositoryInterface;
11+
use Magento\Framework\Api\SearchCriteriaBuilder;
12+
use Magento\Quote\Api\Data\CartInterface;
913

1014
class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase
1115
{
1216
/**
1317
* @magentoDataFixture Magento/Sales/_files/quote.php
1418
*/
1519
public function testGetList()
20+
{
21+
$searchCriteria = $this->getSearchCriteria('test01');
22+
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
23+
$quoteRepository = Bootstrap::getObjectManager()->create(CartRepositoryInterface::class);
24+
$searchResult = $quoteRepository->getList($searchCriteria);
25+
$this->performAssertions($searchResult);
26+
}
27+
28+
/**
29+
* @magentoDataFixture Magento/Sales/_files/quote.php
30+
*/
31+
public function testGetListDoubleCall()
32+
{
33+
$searchCriteria1 = $this->getSearchCriteria('test01');
34+
$searchCriteria2 = $this->getSearchCriteria('test02');
35+
36+
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
37+
$quoteRepository = Bootstrap::getObjectManager()->create(CartRepositoryInterface::class);
38+
$searchResult = $quoteRepository->getList($searchCriteria1);
39+
$this->performAssertions($searchResult);
40+
$searchResult = $quoteRepository->getList($searchCriteria2);
41+
$items = $searchResult->getItems();
42+
$this->assertEmpty($items);
43+
}
44+
45+
/**
46+
* @param string $filterValue
47+
* @return \Magento\Framework\Api\SearchCriteria
48+
*/
49+
private function getSearchCriteria($filterValue)
50+
{
51+
/** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */
52+
$searchCriteriaBuilder = Bootstrap::getObjectManager()->create(SearchCriteriaBuilder::class);
53+
$filterBuilder = Bootstrap::getObjectManager()->create(FilterBuilder::class);
54+
$filters = [];
55+
$filters[] = $filterBuilder
56+
->setField('reserved_order_id')
57+
->setConditionType('=')
58+
->setValue($filterValue)
59+
->create();
60+
$searchCriteriaBuilder->addFilters($filters);
61+
62+
return $searchCriteriaBuilder->create();
63+
}
64+
65+
/**
66+
* @param object $searchResult
67+
*/
68+
protected function performAssertions($searchResult)
1669
{
1770
$expectedExtensionAttributes = [
1871
'firstname' => 'firstname',
1972
'lastname' => 'lastname',
2073
'email' => 'admin@example.com'
2174
];
2275

23-
/** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */
24-
$searchCriteriaBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\SearchCriteriaBuilder');
25-
26-
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
27-
$quoteRepository = Bootstrap::getObjectManager()->create('Magento\Quote\Api\CartRepositoryInterface');
28-
$searchResult = $quoteRepository->getList($searchCriteriaBuilder->create());
2976
$items = $searchResult->getItems();
3077
/** @var \Magento\Quote\Api\Data\CartInterface $actualQuote */
3178
$actualQuote = array_pop($items);
32-
$this->assertInstanceOf('Magento\Quote\Api\Data\CartInterface', $actualQuote);
79+
$this->assertInstanceOf(CartInterface::class, $actualQuote);
3380
$this->assertEquals('test01', $actualQuote->getReservedOrderId());
3481
/** @var \Magento\User\Api\Data\UserInterface $testAttribute */
3582
$testAttribute = $actualQuote->getExtensionAttributes()->getQuoteTestAttribute();

0 commit comments

Comments
 (0)