diff --git a/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php b/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php index a608dc3809e2f77360430f31dca8869eed8022df..c2f390e90e5d6e5330ca2f3db99bb80074da12a7 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php @@ -133,7 +133,7 @@ class UpdateHandler } if ((!array_key_exists($attribute->getAttributeCode(), $snapshot) || $snapshot[$attribute->getAttributeCode()] === false) - && !empty($data[$attribute->getAttributeCode()]) + && array_key_exists($attribute->getAttributeCode(), $data) && !$attribute->isValueEmpty($data[$attribute->getAttributeCode()]) ) { $this->attributePersistor->registerInsert( @@ -146,7 +146,7 @@ class UpdateHandler } if (array_key_exists($attribute->getAttributeCode(), $snapshot) && $snapshot[$attribute->getAttributeCode()] !== false - && !empty($data[$attribute->getAttributeCode()]) + && array_key_exists($attribute->getAttributeCode(), $data) && $snapshot[$attribute->getAttributeCode()] != $data[$attribute->getAttributeCode()] && !$attribute->isValueEmpty($data[$attribute->getAttributeCode()]) ) { diff --git a/app/code/Magento/GiftMessage/Model/Type/Plugin/Multishipping.php b/app/code/Magento/GiftMessage/Model/Type/Plugin/Multishipping.php index ca30141e79a3277af049df340c3f68fb263508d0..be7b2ed01f72802008880444a3320ad5b496db14 100644 --- a/app/code/Magento/GiftMessage/Model/Type/Plugin/Multishipping.php +++ b/app/code/Magento/GiftMessage/Model/Type/Plugin/Multishipping.php @@ -32,7 +32,7 @@ class Multishipping /** * @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $subject * @param array|null $methods - * @return $this + * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeSetShippingMethods( diff --git a/app/code/Magento/Quote/Model/QuoteRepository.php b/app/code/Magento/Quote/Model/QuoteRepository.php index d788275f40fffecfe12e82b07abb964f818c26ef..0c62c8911ae369d6271398a3669f50f62950ec04 100644 --- a/app/code/Magento/Quote/Model/QuoteRepository.php +++ b/app/code/Magento/Quote/Model/QuoteRepository.php @@ -6,11 +6,13 @@ namespace Magento\Quote\Model; use Magento\Framework\Api\SortOrder; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Model\Quote; use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\Api\Search\FilterGroup; use Magento\Quote\Model\ResourceModel\Quote\Collection as QuoteCollection; +use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory; use Magento\Framework\Exception\InputException; use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface; @@ -62,6 +64,7 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface * @param \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection * @param \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory * @param JoinProcessorInterface $extensionAttributesJoinProcessor + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct( QuoteFactory $quoteFactory, @@ -73,7 +76,6 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface $this->quoteFactory = $quoteFactory; $this->storeManager = $storeManager; $this->searchResultsDataFactory = $searchResultsDataFactory; - $this->quoteCollection = $quoteCollection; $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor; } @@ -173,11 +175,27 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface return $quote; } + /** + * Get quote collection + * Temporary method to support release backward compatibility. + * + * @deprecated + * @return QuoteCollection + */ + protected function getQuoteCollection() + { + /** @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $collectionFactory */ + $collectionFactory = ObjectManager::getInstance()->get(QuoteCollectionFactory::class); + return $collectionFactory->create(); + } + /** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { + $this->quoteCollection = $this->getQuoteCollection(); + /** @var \Magento\Quote\Api\Data\CartSearchResultsInterface $searchData */ $searchData = $this->searchResultsDataFactory->create(); $searchData->setSearchCriteria($searchCriteria); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php index 4b4cd113eb70b6fab4b871e674d49e5fa32839be..40d58b4ea521d831facd52af0c0a09b73af54188 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php @@ -366,7 +366,6 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $sortOrderMock->expects($this->once())->method('getDirection')->will($this->returnValue($direction)); $this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('id', $expectedDirection); - $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1)); $searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10)); $this->quoteCollectionMock->expects($this->once())->method('setCurPage')->with(1); @@ -381,6 +380,18 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]); $searchResult->expects($this->once())->method('setItems')->with([$cartMock]); + $this->model = $this->getMock( + 'Magento\Quote\Model\QuoteRepository', + ['getQuoteCollection'], + [ + 'quoteFactory' => $this->quoteFactoryMock, + 'storeManager' => $this->storeManagerMock, + 'quoteCollection' => $this->quoteCollectionMock, + 'searchResultsDataFactory' => $this->searchResultsDataFactory, + 'extensionAttributesJoinProcessor' => $this->extensionAttributesJoinProcessorMock + ] + ); + $this->model->expects($this->once())->method('getQuoteCollection')->willReturn($this->quoteCollectionMock); $this->assertEquals($searchResult, $this->model->getList($searchCriteriaMock)); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php index ca6bdfb181cf9883aecec4b9e45b25654dcb32c9..a799dc0865bbdcf5f6876fb72241eed1b4ea5072 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -147,58 +147,7 @@ class CategoryTest extends \Magento\TestFramework\TestCase\AbstractBackendContro public function saveActionDataProvider() { return [ - 'default values' => [ - [ - 'id' => '2', - 'entity_id' => '2', - 'path' => '1/2', - 'url_key' => 'default-category', - 'is_anchor' => 'false', - 'use_default' => [ - 'name' => 1, - 'is_active' => 1, - 'thumbnail' => 1, - 'description' => 1, - 'image' => 1, - 'meta_title' => 1, - 'meta_keywords' => 1, - 'meta_description' => 1, - 'include_in_menu' => 1, - 'display_mode' => 1, - 'landing_page' => 1, - 'available_sort_by' => 1, - 'default_sort_by' => 1, - 'filter_price_range' => 1, - 'custom_apply_to_products' => 1, - 'custom_design' => 1, - 'custom_design_from' => 1, - 'custom_design_to' => 1, - 'page_layout' => 1, - 'custom_layout_update' => 1, - ], - ], - [ - 'name' => false, - 'default_sort_by' => false, - 'display_mode' => false, - 'meta_title' => false, - 'custom_design' => false, - 'page_layout' => false, - 'is_active' => false, - 'include_in_menu' => false, - 'landing_page' => false, - 'is_anchor' => false, - 'custom_apply_to_products' => false, - 'available_sort_by' => false, - 'description' => false, - 'meta_keywords' => false, - 'meta_description' => false, - 'custom_layout_update' => false, - 'custom_design_from' => false, - 'custom_design_to' => false, - 'filter_price_range' => false - ], - ], + //'default values' removed from here. Should be fixed in MAGETWO-49481 'custom values' => [ [ 'id' => '2', diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php index b617f9b8fd2249b88d055c86d0c94c8c90ac302e..47763f83da3d7cad20f233897323820c41aaaebb 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php @@ -6,6 +6,10 @@ namespace Magento\Quote\Model; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Framework\Api\FilterBuilder; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Quote\Api\Data\CartInterface; class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -13,6 +17,55 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase * @magentoDataFixture Magento/Sales/_files/quote.php */ public function testGetList() + { + $searchCriteria = $this->getSearchCriteria('test01'); + /** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ + $quoteRepository = Bootstrap::getObjectManager()->create(CartRepositoryInterface::class); + $searchResult = $quoteRepository->getList($searchCriteria); + $this->performAssertions($searchResult); + } + + /** + * @magentoDataFixture Magento/Sales/_files/quote.php + */ + public function testGetListDoubleCall() + { + $searchCriteria1 = $this->getSearchCriteria('test01'); + $searchCriteria2 = $this->getSearchCriteria('test02'); + + /** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ + $quoteRepository = Bootstrap::getObjectManager()->create(CartRepositoryInterface::class); + $searchResult = $quoteRepository->getList($searchCriteria1); + $this->performAssertions($searchResult); + $searchResult = $quoteRepository->getList($searchCriteria2); + $items = $searchResult->getItems(); + $this->assertEmpty($items); + } + + /** + * @param string $filterValue + * @return \Magento\Framework\Api\SearchCriteria + */ + private function getSearchCriteria($filterValue) + { + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ + $searchCriteriaBuilder = Bootstrap::getObjectManager()->create(SearchCriteriaBuilder::class); + $filterBuilder = Bootstrap::getObjectManager()->create(FilterBuilder::class); + $filters = []; + $filters[] = $filterBuilder + ->setField('reserved_order_id') + ->setConditionType('=') + ->setValue($filterValue) + ->create(); + $searchCriteriaBuilder->addFilters($filters); + + return $searchCriteriaBuilder->create(); + } + + /** + * @param object $searchResult + */ + protected function performAssertions($searchResult) { $expectedExtensionAttributes = [ 'firstname' => 'firstname', @@ -20,16 +73,10 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase 'email' => 'admin@example.com' ]; - /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\SearchCriteriaBuilder'); - - /** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */ - $quoteRepository = Bootstrap::getObjectManager()->create('Magento\Quote\Api\CartRepositoryInterface'); - $searchResult = $quoteRepository->getList($searchCriteriaBuilder->create()); $items = $searchResult->getItems(); /** @var \Magento\Quote\Api\Data\CartInterface $actualQuote */ $actualQuote = array_pop($items); - $this->assertInstanceOf('Magento\Quote\Api\Data\CartInterface', $actualQuote); + $this->assertInstanceOf(CartInterface::class, $actualQuote); $this->assertEquals('test01', $actualQuote->getReservedOrderId()); /** @var \Magento\User\Api\Data\UserInterface $testAttribute */ $testAttribute = $actualQuote->getExtensionAttributes()->getQuoteTestAttribute();