From 4527e3241fc2a7e73b23148e48ee7f321b2059dd Mon Sep 17 00:00:00 2001 From: Vinai Kopp Date: Sun, 28 Jun 2015 10:07:02 +0200 Subject: [PATCH] Rename \Magento\Framework\Api\SearchCriteriaBuilder::addFilter() to addFilters() Purpose == Make method name more descriptive and easier to understand. Background == Having a method called `addFilter()` which take an array of `Filter` instances caused many doubletakes and facepalms during the m2 dev training. It seems as if the method name originated from the old collection `addFieldToFilter` from collections in Magento 1, where the condition type was set as a key in the passed argument array (e.g. `addFieldToFilter('name', ['eq' => $filter])`). In fact, some integration tests even set such expectations on the searchCriteriaBuilder, for example *app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php*. However, this must be a bug because the array keys in the argument array are ignored, and the code only happened to work because the repositories in question default to using the 'eq' operator when applying the filter groups to the collection if no condition type is set on the filter instance. Reasons for this PR == Make the method name more intuitive. Naming definitely could still be improved, but at least it no longer is that misleading. Maybe using `addFilterGroupWithFilters()` would be even more descriptive, but I chose the smaller change, since it probably is "good enough". Remove wrong examples of method usage from tests, so they don't serve as wrong documentation. --- .../Magento/Backend/Model/Search/Customer.php | 2 +- .../Model/Category/AttributeRepository.php | 2 +- .../Model/Product/Attribute/Repository.php | 2 +- .../Model/Product/Attribute/SetRepository.php | 2 +- .../Catalog/Model/ProductRepository.php | 2 +- .../Category/AttributeRepositoryTest.php | 2 +- .../Product/Attribute/RepositoryTest.php | 2 +- .../Product/Attribute/SetRepositoryTest.php | 2 +- .../Test/Unit/Model/ProductRepositoryTest.php | 2 +- .../Customer/Model/GroupManagement.php | 4 +-- .../Group/Grid/ServiceCollectionTest.php | 10 +++--- .../Block/Checkout/Address/Select.php | 2 +- .../Checkout/Address/ShippingSaved.php | 2 +- .../Model/Checkout/Type/Multishipping.php | 2 +- .../Block/Checkout/Address/SelectTest.php | 4 +-- .../Checkout/Address/ShippingSavedTest.php | 2 +- .../Model/Checkout/Type/MultishippingTest.php | 2 +- app/code/Magento/Quote/Model/Quote.php | 4 +-- .../Adminhtml/Order/Create/Form/Address.php | 8 ++--- .../Order/Payment/TransactionRepository.php | 2 +- .../Sales/Model/Service/CreditmemoService.php | 4 +-- .../Sales/Model/Service/InvoiceService.php | 4 +-- .../Sales/Model/Service/OrderService.php | 4 +-- .../Sales/Model/Service/ShipmentService.php | 4 +-- .../Payment/TransactionRepositoryTest.php | 2 +- .../Model/Service/CreditmemoServiceTest.php | 12 ++++--- .../Unit/Model/Service/InvoiceServiceTest.php | 22 +++++++------ .../Unit/Model/Service/OrderServiceTest.php | 8 +++-- .../Model/Service/ShipmentServiceTest.php | 22 +++++++------ app/code/Magento/Tax/Model/Calculation.php | 2 +- .../Magento/Tax/Model/TaxClass/Management.php | 4 +-- .../Tax/Model/TaxClass/Source/Customer.php | 2 +- .../Tax/Model/TaxClass/Source/Product.php | 2 +- .../Tax/Model/TaxClass/Type/Customer.php | 2 +- .../Magento/Tax/Model/TaxRateManagement.php | 4 +-- .../Unit/Model/TaxClass/ManagementTest.php | 2 +- .../Model/TaxClass/Source/CustomerTest.php | 6 ++-- .../Model/TaxClass/Source/ProductTest.php | 4 +-- .../Unit/Model/TaxClass/Type/CustomerTest.php | 5 ++- .../Test/Unit/Model/TaxRateManagementTest.php | 2 +- .../Magento/Ui/Model/BookmarkManagement.php | 4 +-- .../Magento/Cms/Api/BlockRepositoryTest.php | 3 +- .../Magento/Cms/Api/PageRepositoryTest.php | 3 +- .../Customer/Api/CustomerRepositoryTest.php | 32 +++++++++---------- .../Customer/Api/GroupRepositoryTest.php | 6 ++-- .../Magento/Quote/Api/CartRepositoryTest.php | 18 +++++------ .../Quote/Api/CartTotalRepositoryTest.php | 4 +-- .../Api/GuestCartTotalRepositoryTest.php | 4 +-- .../Sales/Service/V1/CreditmemoListTest.php | 2 +- .../Sales/Service/V1/InvoiceListTest.php | 2 +- .../Sales/Service/V1/OrderListTest.php | 2 +- .../Sales/Service/V1/ShipmentListTest.php | 2 +- .../Sales/Service/V1/TransactionTest.php | 2 +- .../Tax/Api/TaxClassRepositoryTest.php | 10 +++--- .../Magento/Tax/Api/TaxRateRepositoryTest.php | 4 +-- .../Api/TaxRuleRepositoryInterfaceTest.php | 6 ++-- .../Magento/Webapi/JoinDirectivesTest.php | 2 +- .../Customer/Api/AddressRepositoryTest.php | 4 +-- .../Block/Adminhtml/Group/Edit/FormTest.php | 2 +- .../Block/Adminhtml/Group/EditTest.php | 2 +- .../Model/Resource/AddressRepositoryTest.php | 4 +-- .../Model/Resource/CustomerRepositoryTest.php | 8 ++--- .../Model/Resource/GroupRepositoryTest.php | 4 +-- .../ExtensionAttribute/JoinProcessorTest.php | 6 ++-- .../Model/Calculation/RateRepositoryTest.php | 4 +-- .../Tax/Model/TaxRuleRepositoryTest.php | 4 +-- .../Api/AbstractServiceCollection.php | 2 +- .../Api/Search/FilterGroupBuilder.php | 2 +- .../Framework/Api/SearchCriteriaBuilder.php | 2 +- 69 files changed, 176 insertions(+), 151 deletions(-) diff --git a/app/code/Magento/Backend/Model/Search/Customer.php b/app/code/Magento/Backend/Model/Search/Customer.php index f326d0b2fc0a6..7b16b1c894467 100644 --- a/app/code/Magento/Backend/Model/Search/Customer.php +++ b/app/code/Magento/Backend/Model/Search/Customer.php @@ -96,7 +96,7 @@ public function load() ->setValue($this->getQuery() . '%') ->create(); } - $this->searchCriteriaBuilder->addFilter($filters); + $this->searchCriteriaBuilder->addFilters($filters); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchResults = $this->customerRepository->getList($searchCriteria); diff --git a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php index 38ee0f02fccdd..8b9c1f4702a3d 100644 --- a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php +++ b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php @@ -73,7 +73,7 @@ public function getCustomAttributesMetadata($dataObjectClassName = null) $defaultAttributeSetId = $this->eavConfig ->getEntityType(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE) ->getDefaultAttributeSetId(); - $searchCriteria = $this->searchCriteriaBuilder->addFilter( + $searchCriteria = $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('attribute_set_id') diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php index 49fdcf4a8a892..07096562de955 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php @@ -212,7 +212,7 @@ public function getCustomAttributesMetadata($dataObjectClassName = null) $defaultAttributeSetId = $this->eavConfig ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) ->getDefaultAttributeSetId(); - $searchCriteria = $this->searchCriteriaBuilder->addFilter( + $searchCriteria = $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('attribute_set_id') diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php index 1ff9a50bea62c..b47a9351889c8 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php @@ -62,7 +62,7 @@ public function save(\Magento\Eav\Api\Data\AttributeSetInterface $attributeSet) */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { - $this->searchCriteriaBuilder->addFilter( + $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('entity_type_code') diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 33ef608575c92..cf617c076ab80 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -652,7 +652,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr $defaultAttributeSetId = $this->eavConfig ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) ->getDefaultAttributeSetId(); - $extendedSearchCriteria = $this->searchCriteriaBuilder->addFilter( + $extendedSearchCriteria = $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('attribute_set_id') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php index c2c63a0ed168c..3626042fac91c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php @@ -114,7 +114,7 @@ public function testGetCustomAttributesMetadata() 3 )->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); - $this->searchBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock])->willReturnSelf(); + $this->searchBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock])->willReturnSelf(); $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); $this->searchBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); $itemMock = $this->getMock('Magento\Framework\Object', [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php index 5bdbcde5c5ee4..ae38586c74cef 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php @@ -180,7 +180,7 @@ public function testGetCustomAttributesMetadata() ->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$filterMock]) ->willReturnSelf(); $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php index 70ba8feab8dac..65ce4d9a084c7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php @@ -181,7 +181,7 @@ public function testGetList() $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$filterMock]) ->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 1cbc3749362b2..a84bf2e1b532f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -573,7 +573,7 @@ public function testGetList() $this->filterBuilderMock->expects($this->once())->method('setValue') ->with(4) ->willReturn($this->filterBuilderMock); - $this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock]) + $this->searchCriteriaBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock]) ->willReturn($searchCriteriaBuilderMock); $searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($extendedSearchCriteriaMock); $this->metadataServiceMock->expects($this->once())->method('getList')->with($extendedSearchCriteriaMock) diff --git a/app/code/Magento/Customer/Model/GroupManagement.php b/app/code/Magento/Customer/Model/GroupManagement.php index fb05d732285d7..bb5012de52d14 100644 --- a/app/code/Magento/Customer/Model/GroupManagement.php +++ b/app/code/Magento/Customer/Model/GroupManagement.php @@ -154,8 +154,8 @@ public function getLoggedInGroups() ->setValue(self::CUST_GROUP_ALL) ->create(); $searchCriteria = $this->searchCriteriaBuilder - ->addFilter($notLoggedInFilter) - ->addFilter($groupAll) + ->addFilters($notLoggedInFilter) + ->addFilters($groupAll) ->create(); return $this->groupRepository->getList($searchCriteria)->getItems(); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php b/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php index 1094b73194e5b..e3010d24601b6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php @@ -88,7 +88,7 @@ public function testGetSearchCriteriaImplicitEq() ->setCurrentPage(1) ->setPageSize(false) ->addSortOrder($sortOrder) - ->addFilter( + ->addFilters( [$this->filterBuilder->setField('name')->setConditionType('eq')->setValue('Magento')->create()] )->create(); @@ -119,7 +119,7 @@ public function testGetSearchCriteriaOneField() ->setCurrentPage(1) ->setPageSize(0) ->addSortOrder($sortOrder) - ->addFilter([$filter]) + ->addFilters([$filter]) ->create(); // Verifies that the search criteria Data Object created by the serviceCollection matches expected @@ -150,7 +150,7 @@ public function testGetSearchCriteriaOr() ->setCurrentPage(1) ->setPageSize(0) ->addSortOrder($sortOrder) - ->addFilter( + ->addFilters( [ $this->filterBuilder->setField($fieldA)->setConditionType('eq')->setValue($value)->create(), $this->filterBuilder->setField($fieldB)->setConditionType('eq')->setValue($value)->create(), @@ -186,13 +186,13 @@ public function testGetSearchCriteriaAnd() ->setCurrentPage(1) ->setPageSize(0) ->addSortOrder($sortOrder) - ->addFilter( + ->addFilters( [ $this->filterBuilder->setField($fieldA)->setConditionType('gt') ->setValue($value)->create(), ] ) - ->addFilter( + ->addFilters( [ $this->filterBuilder->setField($fieldB)->setConditionType('gt') ->setValue($value)->create(), diff --git a/app/code/Magento/Multishipping/Block/Checkout/Address/Select.php b/app/code/Magento/Multishipping/Block/Checkout/Address/Select.php index 8b9efa916bf1a..0eb803c02acb1 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Address/Select.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Address/Select.php @@ -101,7 +101,7 @@ public function getAddress() ->setConditionType('eq') ->create(); $addresses = (array)($this->addressRepository->getList( - $this->searchCriteriaBuilder->addFilter([$filter])->create() + $this->searchCriteriaBuilder->addFilters([$filter])->create() )->getItems()); } catch (NoSuchEntityException $e) { return []; diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/ShippingSaved.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/ShippingSaved.php index 43356ee11eaf0..01187fce18184 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/ShippingSaved.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/ShippingSaved.php @@ -61,7 +61,7 @@ public function execute() $filter = $this->filterBuilder->setField('parent_id')->setValue($this->_getCheckout()->getCustomer()->getId()) ->setConditionType('eq')->create(); $addresses = (array)($this->addressRepository->getList( - $this->searchCriteriaBuilder->addFilter([$filter])->create() + $this->searchCriteriaBuilder->addFilters([$filter])->create() )->getItems()); /** diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index 74f396ea18a7f..7d44458a8f03c 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -878,7 +878,7 @@ private function getDefaultAddressByDataKey($key, $defaultAddressIdFromCustomer) ->setConditionType('eq') ->create(); $addresses = (array)($this->addressRepository->getList( - $this->searchCriteriaBuilder->addFilter([$filter])->create() + $this->searchCriteriaBuilder->addFilters([$filter])->create() )->getItems()); if ($addresses) { $address = reset($addresses); diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php index c2a7cb36458ce..0b623ac944020 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php @@ -130,7 +130,7 @@ public function testGetAddress() $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($this->filterMock); $this->searchCriteriaBuilderMock ->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$this->filterMock]) ->willReturnSelf(); $this->searchCriteriaBuilderMock @@ -176,7 +176,7 @@ public function testGetAddressWhenItNotExistInCustomer() $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($this->filterMock); $this->searchCriteriaBuilderMock ->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$this->filterMock]) ->willReturnSelf(); $this->searchCriteriaBuilderMock diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php index e9a6d82cdd83e..ffb91ebb4e132 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/ShippingSavedTest.php @@ -138,7 +138,7 @@ private function mockCustomerAddressRepository($customerId, array $addresses) $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $searchCriteriaMock = $this->getMock('Magento\Framework\Api\SearchCriteria', [], [], '', false); - $this->criteriaBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock])->willReturnSelf(); + $this->criteriaBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock])->willReturnSelf(); $this->criteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); $searchResultMock = $this->getMock('Magento\Customer\Api\Data\AddressSearchResultsInterface'); diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php index 415bdd643029d..f66cdc2e22bb5 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php @@ -149,7 +149,7 @@ public function testSetShippingItemsInformation() $this->filterBuilderMock->expects($this->atLeastOnce())->method('create')->willReturnSelf(); $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); - $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('addFilter')->willReturnSelf(); + $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('addFilters')->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('create') ->willReturn($searchCriteriaMock); diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index 2dd5c4ca3add0..38e59e9d33316 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -268,7 +268,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C * * @var \Magento\Framework\Api\SearchCriteriaBuilder */ - protected $criteriaBuilder; + protected $searchCriteriaBuilder; /** * Filter builder @@ -421,7 +421,7 @@ public function __construct( $this->_quotePaymentCollectionFactory = $quotePaymentCollectionFactory; $this->_objectCopyService = $objectCopyService; $this->addressRepository = $addressRepository; - $this->criteriaBuilder = $criteriaBuilder; + $this->searchCriteriaBuilder = $criteriaBuilder; $this->filterBuilder = $filterBuilder; $this->stockRegistry = $stockRegistry; $this->itemProcessor = $itemProcessor; diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php index d370b76c17fa6..1ee0386f87110 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php @@ -61,7 +61,7 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF * * @var \Magento\Framework\Api\SearchCriteriaBuilder */ - protected $criteriaBuilder; + protected $searchCriteriaBuilder; /** * Filter builder @@ -121,7 +121,7 @@ public function __construct( $this->_customerFormFactory = $customerFormFactory; $this->_addressHelper = $addressHelper; $this->addressService = $addressService; - $this->criteriaBuilder = $criteriaBuilder; + $this->searchCriteriaBuilder = $criteriaBuilder; $this->filterBuilder = $filterBuilder; $this->addressMapper = $addressMapper; parent::__construct( @@ -159,8 +159,8 @@ public function getAddressCollection() ->setValue($this->getCustomerId()) ->setConditionType('eq') ->create(); - $this->criteriaBuilder->addFilter([$filter]); - $criteria = $this->criteriaBuilder->create(); + $this->searchCriteriaBuilder->addFilters([$filter]); + $criteria = $this->searchCriteriaBuilder->create(); $result = $this->addressService->getList($criteria); return $result->getItems(); } diff --git a/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php b/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php index da58fb8949588..bbe428020fc9f 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php +++ b/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php @@ -81,7 +81,7 @@ public function get($id) } if (!isset($this->registry[$id])) { $filter = $this->filterBuilder->setField('transaction_id')->setValue($id)->setConditionType('eq')->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $this->find($this->searchCriteriaBuilder->create()); if (!isset($this->registry[$id])) { diff --git a/app/code/Magento/Sales/Model/Service/CreditmemoService.php b/app/code/Magento/Sales/Model/Service/CreditmemoService.php index 4e5946f5b16be..8e4b2c7256861 100644 --- a/app/code/Magento/Sales/Model/Service/CreditmemoService.php +++ b/app/code/Magento/Sales/Model/Service/CreditmemoService.php @@ -75,8 +75,8 @@ public function cancel($id) */ public function getCommentsList($id) { - $this->searchCriteriaBuilder->addFilter( - ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + $this->searchCriteriaBuilder->addFilters( + [$this->filterBuilder->setField('parent_id')->setValue($id)->setConditionType('eq')->create()] ); $criteria = $this->searchCriteriaBuilder->create(); return $this->creditmemoCommentRepository->getList($criteria); diff --git a/app/code/Magento/Sales/Model/Service/InvoiceService.php b/app/code/Magento/Sales/Model/Service/InvoiceService.php index 85e356206e048..cc1d737c69d9d 100644 --- a/app/code/Magento/Sales/Model/Service/InvoiceService.php +++ b/app/code/Magento/Sales/Model/Service/InvoiceService.php @@ -88,8 +88,8 @@ public function setCapture($id) */ public function getCommentsList($id) { - $this->criteriaBuilder->addFilter( - ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + $this->criteriaBuilder->addFilters( + [$this->filterBuilder->setField('parent_id')->setValue($id)->setConditionType('eq')->create()] ); $criteria = $this->criteriaBuilder->create(); return $this->commentRepository->getList($criteria); diff --git a/app/code/Magento/Sales/Model/Service/OrderService.php b/app/code/Magento/Sales/Model/Service/OrderService.php index 20733b00649dd..b6037c73c9bf0 100644 --- a/app/code/Magento/Sales/Model/Service/OrderService.php +++ b/app/code/Magento/Sales/Model/Service/OrderService.php @@ -89,8 +89,8 @@ public function cancel($id) */ public function getCommentsList($id) { - $this->criteriaBuilder->addFilter( - ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + $this->criteriaBuilder->addFilters( + [$this->filterBuilder->setField('parent_id')->setValue($id)->setConditionType('eq')->create()] ); $criteria = $this->criteriaBuilder->create(); return $this->historyRepository->getList($criteria); diff --git a/app/code/Magento/Sales/Model/Service/ShipmentService.php b/app/code/Magento/Sales/Model/Service/ShipmentService.php index 6ae8cb4f64a1a..6523e8e83825e 100644 --- a/app/code/Magento/Sales/Model/Service/ShipmentService.php +++ b/app/code/Magento/Sales/Model/Service/ShipmentService.php @@ -88,8 +88,8 @@ public function getLabel($id) */ public function getCommentsList($id) { - $this->criteriaBuilder->addFilter( - ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + $this->criteriaBuilder->addFilters( + [$this->filterBuilder->setField('parent_id')->setValue($id)->setConditionType('eq')->create()] ); $criteria = $this->criteriaBuilder->create(); return $this->commentRepository->getList($criteria); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php index ae0a682d0c934..0b42ab53944a0 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php @@ -112,7 +112,7 @@ public function testGet($id, array $collectionIds, $conditionType) ->method('getFilterGroups') ->willReturn([$filterGroup]); $this->searchCriteriaBuilder->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$filter]); $this->searchCriteriaBuilder->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php index ca97c74c3cd9e..388d0ddebef0c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php @@ -63,14 +63,14 @@ protected function setUp() ); $this->searchCriteriaBuilderMock = $this->getMock( 'Magento\Framework\Api\SearchCriteriaBuilder', - ['create', 'addFilter'], + ['create', 'addFilters'], [], '', false ); $this->filterBuilderMock = $this->getMock( 'Magento\Framework\Api\FilterBuilder', - ['setField', 'setValue', 'create'], + ['setField', 'setValue', 'setConditionType', 'create'], [], '', false @@ -150,12 +150,16 @@ public function testGetCommentsList() ->method('setValue') ->with($id) ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('setConditionType') + ->with('eq') + ->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once()) ->method('create') ->will($this->returnValue($filterMock)); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') - ->with(['eq' => $filterMock]); + ->method('addFilters') + ->with([$filterMock]); $this->searchCriteriaBuilderMock->expects($this->once()) ->method('create') ->will($this->returnValue($searchCriteriaMock)); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php index 9aaef7fa2b1c4..ff8b45cb7ec0c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/InvoiceServiceTest.php @@ -31,7 +31,7 @@ class InvoiceServiceTest extends \PHPUnit_Framework_TestCase * * @var \Magento\Framework\Api\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $criteriaBuilderMock; + protected $searchCriteriaBuilderMock; /** * Filter Builder @@ -71,16 +71,16 @@ protected function setUp() '', false ); - $this->criteriaBuilderMock = $this->getMock( + $this->searchCriteriaBuilderMock = $this->getMock( 'Magento\Framework\Api\SearchCriteriaBuilder', - ['create', 'addFilter'], + ['create', 'addFilters'], [], '', false ); $this->filterBuilderMock = $this->getMock( 'Magento\Framework\Api\FilterBuilder', - ['setField', 'setValue', 'create'], + ['setField', 'setValue', 'setConditionType', 'create'], [], '', false @@ -98,7 +98,7 @@ protected function setUp() [ 'repository' => $this->repositoryMock, 'commentRepository' => $this->commentRepositoryMock, - 'criteriaBuilder' => $this->criteriaBuilderMock, + 'criteriaBuilder' => $this->searchCriteriaBuilderMock, 'filterBuilder' => $this->filterBuilderMock, 'notifier' => $this->invoiceNotifierMock ] @@ -163,13 +163,17 @@ public function testGetCommentsList() ->method('setValue') ->with($id) ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('setConditionType') + ->with('eq') + ->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once()) ->method('create') ->will($this->returnValue($filterMock)); - $this->criteriaBuilderMock->expects($this->once()) - ->method('addFilter') - ->with(['eq' => $filterMock]); - $this->criteriaBuilderMock->expects($this->once()) + $this->searchCriteriaBuilderMock->expects($this->once()) + ->method('addFilters') + ->with([$filterMock]); + $this->searchCriteriaBuilderMock->expects($this->once()) ->method('create') ->will($this->returnValue($searchCriteriaMock)); $this->commentRepositoryMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php index 97414f5511a6e..a318afa775f7f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php @@ -151,12 +151,16 @@ public function testGetCommentsList() ->method('setValue') ->with(123) ->willReturnSelf(); + $this->filterBuilderMock->expects($this->once()) + ->method('setConditionType') + ->with('eq') + ->willReturnSelf(); $this->filterBuilderMock->expects($this->once()) ->method('create') ->willReturn($this->filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') - ->with(['eq' => $this->filterMock]) + ->method('addFilters') + ->with([$this->filterMock]) ->willReturn($this->filterBuilderMock); $this->searchCriteriaBuilderMock->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php index b63c3c2adc547..d189f052338a8 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/ShipmentServiceTest.php @@ -24,7 +24,7 @@ class ShipmentServiceTest extends \PHPUnit_Framework_TestCase * * @var \Magento\Framework\Api\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $criteriaBuilderMock; + protected $searchCriteriaBuilderMock; /** * Filter Builder @@ -65,16 +65,16 @@ protected function setUp() '', false ); - $this->criteriaBuilderMock = $this->getMock( + $this->searchCriteriaBuilderMock = $this->getMock( 'Magento\Framework\Api\SearchCriteriaBuilder', - ['create', 'addFilter'], + ['create', 'addFilters'], [], '', false ); $this->filterBuilderMock = $this->getMock( 'Magento\Framework\Api\FilterBuilder', - ['setField', 'setValue', 'create'], + ['setField', 'setValue', 'setConditionType', 'create'], [], '', false @@ -97,7 +97,7 @@ protected function setUp() 'Magento\Sales\Model\Service\ShipmentService', [ 'commentRepository' => $this->commentRepositoryMock, - 'criteriaBuilder' => $this->criteriaBuilderMock, + 'criteriaBuilder' => $this->searchCriteriaBuilderMock, 'filterBuilder' => $this->filterBuilderMock, 'repository' => $this->repositoryMock, 'notifier' => $this->notifierMock, @@ -163,13 +163,17 @@ public function testGetCommentsList() ->method('setValue') ->with($id) ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('setConditionType') + ->with('eq') + ->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once()) ->method('create') ->will($this->returnValue($filterMock)); - $this->criteriaBuilderMock->expects($this->once()) - ->method('addFilter') - ->with(['eq' => $filterMock]); - $this->criteriaBuilderMock->expects($this->once()) + $this->searchCriteriaBuilderMock->expects($this->once()) + ->method('addFilters') + ->with([$filterMock]); + $this->searchCriteriaBuilderMock->expects($this->once()) ->method('create') ->will($this->returnValue($searchCriteriaMock)); $this->commentRepositoryMock->expects($this->once()) diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php index 3de896077dc99..4fc6ecf33e823 100755 --- a/app/code/Magento/Tax/Model/Calculation.php +++ b/app/code/Magento/Tax/Model/Calculation.php @@ -698,7 +698,7 @@ public function getTaxRates($billingAddress, $shippingAddress, $customerTaxClass } $rateRequest = $this->getRateRequest($shippingAddressObj, $billingAddressObj, $customerTaxClassId); - $searchCriteria = $this->searchCriteriaBuilder->addFilter( + $searchCriteria = $this->searchCriteriaBuilder->addFilters( [$this->filterBuilder->setField(ClassModel::KEY_TYPE) ->setValue(\Magento\Tax\Api\TaxClassManagementInterface::TYPE_PRODUCT) ->create()] diff --git a/app/code/Magento/Tax/Model/TaxClass/Management.php b/app/code/Magento/Tax/Model/TaxClass/Management.php index eb7871c1086c2..04567c80e4199 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Management.php +++ b/app/code/Magento/Tax/Model/TaxClass/Management.php @@ -60,9 +60,9 @@ public function getTaxClassId($taxClassKey, $taxClassType = self::TYPE_PRODUCT) case TaxClassKeyInterface::TYPE_ID: return $taxClassKey->getValue(); case TaxClassKeyInterface::TYPE_NAME: - $searchCriteria = $this->searchCriteriaBuilder->addFilter( + $searchCriteria = $this->searchCriteriaBuilder->addFilters( [$this->filterBuilder->setField(ClassModel::KEY_TYPE)->setValue($taxClassType)->create()] - )->addFilter( + )->addFilters( [ $this->filterBuilder->setField(ClassModel::KEY_NAME) ->setValue($taxClassKey->getValue()) diff --git a/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php b/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php index ca0dd21abdd84..799443d5c7230 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php +++ b/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php @@ -60,7 +60,7 @@ public function getAllOptions() $filter = $this->filterBuilder->setField(ClassModel::KEY_TYPE) ->setValue(TaxClassManagementInterface::TYPE_CUSTOMER) ->create(); - $searchCriteria = $this->searchCriteriaBuilder->addFilter([$filter])->create(); + $searchCriteria = $this->searchCriteriaBuilder->addFilters([$filter])->create(); $searchResults = $this->taxClassRepository->getList($searchCriteria); foreach ($searchResults->getItems() as $taxClass) { $options[] = [ diff --git a/app/code/Magento/Tax/Model/TaxClass/Source/Product.php b/app/code/Magento/Tax/Model/TaxClass/Source/Product.php index 37844ab57076c..c2f167bf0ee22 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Source/Product.php +++ b/app/code/Magento/Tax/Model/TaxClass/Source/Product.php @@ -71,7 +71,7 @@ public function getAllOptions($withEmpty = true) ->setField(ClassModel::KEY_TYPE) ->setValue(TaxClassManagementInterface::TYPE_PRODUCT) ->create(); - $searchCriteria = $this->_searchCriteriaBuilder->addFilter([$filter])->create(); + $searchCriteria = $this->_searchCriteriaBuilder->addFilters([$filter])->create(); $searchResults = $this->_taxClassRepository->getList($searchCriteria); foreach ($searchResults->getItems() as $taxClass) { $this->_options[] = [ diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php b/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php index a46d45fc4a0e3..86c4870851b4a 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php +++ b/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php @@ -61,7 +61,7 @@ public function __construct( public function isAssignedToObjects() { $searchCriteria = $this->searchCriteriaBuilder - ->addFilter( + ->addFilters( [ $this->filterBuilder->setField(CustomerGroup::TAX_CLASS_ID)->setValue($this->getId())->create(), ] diff --git a/app/code/Magento/Tax/Model/TaxRateManagement.php b/app/code/Magento/Tax/Model/TaxRateManagement.php index 0db4b62825687..aa4eea14e542e 100644 --- a/app/code/Magento/Tax/Model/TaxRateManagement.php +++ b/app/code/Magento/Tax/Model/TaxRateManagement.php @@ -57,7 +57,7 @@ public function __construct( */ public function getRatesByCustomerAndProductTaxClassId($customerTaxClassId, $productTaxClassId) { - $this->searchCriteriaBuilder->addFilter( + $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('customer_tax_class_ids') @@ -66,7 +66,7 @@ public function getRatesByCustomerAndProductTaxClassId($customerTaxClassId, $pro ] ); - $this->searchCriteriaBuilder->addFilter( + $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('product_tax_class_ids') diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/ManagementTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/ManagementTest.php index de391779d3ec9..2bea35d4735b1 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/ManagementTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/ManagementTest.php @@ -98,7 +98,7 @@ public function testGetTaxClassIdByNameType() $this->filterBuilder->expects($this->exactly(2))->method('create')->willReturn($filter); $this->searchCriteriaBuilder ->expects($this->exactly(2)) - ->method('addFilter') + ->method('addFilters') ->with([$filter]) ->willReturnSelf(); diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/CustomerTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/CustomerTest.php index 4124d8a646c8a..c9df7db823edc 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/CustomerTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/CustomerTest.php @@ -54,7 +54,7 @@ protected function setUp() ); $this->searchCriteriaBuilderMock = $this->getMock( 'Magento\Framework\Api\SearchCriteriaBuilder', - ['addFilter', 'create'], + ['addFilters', 'create'], [], '', false @@ -130,7 +130,7 @@ public function testGetAllOptions($isEmpty, array $expected) ->method('create') ->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$filterMock]) ->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->once()) @@ -234,7 +234,7 @@ public function testGetAllOptionsNameIntegrity(array $value) ->method('create') ->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$filterMock]) ->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->once()) diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/ProductTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/ProductTest.php index 41003b50f31d8..93ce70fd209e6 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/ProductTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Source/ProductTest.php @@ -49,7 +49,7 @@ public function setUp() ); $this->searchCriteriaBuilderMock = $this->getMock( 'Magento\Framework\Api\SearchCriteriaBuilder', - ['addFilter', 'create'], + ['addFilters', 'create'], [], '', false @@ -152,7 +152,7 @@ public function testGetAllOptionsNameIntegrity(array $value) ->method('create') ->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addFilter') + ->method('addFilters') ->with([$filterMock]) ->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->once()) diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php index 4e2abcaa8e941..60647533c09a1 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php @@ -19,10 +19,13 @@ public function testIsAssignedToObjects() ->method('getItems') ->will($this->returnValue(['randomValue'])); + /** @var \Magento\Framework\Api\FilterBuilder $filterBuilder */ $filterBuilder = $objectManagerHelper ->getObject('Magento\Framework\Api\FilterBuilder'); + /** @var \Magento\Framework\Api\Search\FilterGroupBuilder $filterGroupBuilder */ $filterGroupBuilder = $objectManagerHelper ->getObject('Magento\Framework\Api\Search\FilterGroupBuilder'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = $objectManagerHelper->getObject( 'Magento\Framework\Api\SearchCriteriaBuilder', [ @@ -30,7 +33,7 @@ public function testIsAssignedToObjects() ] ); $expectedSearchCriteria = $searchCriteriaBuilder - ->addFilter([$filterBuilder->setField('tax_class_id')->setValue(5)->create()]) + ->addFilters([$filterBuilder->setField('tax_class_id')->setValue(5)->create()]) ->create(); $customerGroupServiceMock = $this->getMockBuilder('Magento\Customer\Api\GroupRepositoryInterface') diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxRateManagementTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxRateManagementTest.php index 8775f3395cfb4..e4582bfb6152e 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxRateManagementTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxRateManagementTest.php @@ -76,7 +76,7 @@ public function testGetRatesByCustomerAndProductTaxClassId() $customerFilterMock, $productFilterMock ); - $this->searchCriteriaBuilderMock->expects($this->exactly(2))->method('addFilter')->withConsecutive( + $this->searchCriteriaBuilderMock->expects($this->exactly(2))->method('addFilters')->withConsecutive( [[$customerFilterMock]], [[$productFilterMock]] ); diff --git a/app/code/Magento/Ui/Model/BookmarkManagement.php b/app/code/Magento/Ui/Model/BookmarkManagement.php index a467bfd7a9dd7..39eed9cfa8916 100644 --- a/app/code/Magento/Ui/Model/BookmarkManagement.php +++ b/app/code/Magento/Ui/Model/BookmarkManagement.php @@ -51,7 +51,7 @@ public function __construct( */ public function loadByNamespace($namespace) { - $this->searchCriteriaBuilder->addFilter( + $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('user_id') @@ -77,7 +77,7 @@ public function loadByNamespace($namespace) */ public function getByIdentifierNamespace($identifier, $namespace) { - $this->searchCriteriaBuilder->addFilter( + $this->searchCriteriaBuilder->addFilters( [ $this->filterBuilder ->setField('user_id') diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php index 7d6aa8b83d901..f481ba5906509 100644 --- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/BlockRepositoryTest.php @@ -222,13 +222,14 @@ public function testSearch() $this->currentBlock = $this->blockRepository->save($blockDataObject); $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); $filter = $filterBuilder ->setField(BlockInterface::IDENTIFIER) ->setValue($blockIdentifier) ->create(); - $searchCriteriaBuilder->addFilter([$filter]); + $searchCriteriaBuilder->addFilters([$filter]); $searchData = $searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php index 4997e46348822..99226415cf234 100644 --- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php @@ -222,13 +222,14 @@ public function testSearch() $this->currentPage = $this->pageRepository->save($pageDataObject); $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); $filter = $filterBuilder ->setField(PageInterface::IDENTIFIER) ->setValue($pageIdentifier) ->create(); - $searchCriteriaBuilder->addFilter([$filter]); + $searchCriteriaBuilder->addFilters([$filter]); $searchData = $searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index 939bbeca314ca..8b357da784ba4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -357,7 +357,7 @@ public function testSearchCustomers() ->setField(Customer::EMAIL) ->setValue($customerData[Customer::EMAIL]) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $searchData = $this->dataObjectProcessor->buildOutputDataArray( $this->searchCriteriaBuilder->create(), 'Magento\Framework\Api\SearchCriteriaInterface' @@ -391,7 +391,7 @@ public function testSearchCustomersUsingGET() ->setField(Customer::EMAIL) ->setValue($customerData[Customer::EMAIL]) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $searchData = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -451,8 +451,8 @@ public function testSearchCustomersMultipleFiltersWithSort() $filter3 = $builder->setField(Customer::LASTNAME) ->setValue($customerData1[Customer::LASTNAME]) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter1, $filter2]); - $this->searchCriteriaBuilder->addFilter([$filter3]); + $this->searchCriteriaBuilder->addFilters([$filter1, $filter2]); + $this->searchCriteriaBuilder->addFilters([$filter3]); /**@var \Magento\Framework\Api\SortOrderBuilder $sortOrderBuilder */ $sortOrderBuilder = Bootstrap::getObjectManager()->create( @@ -500,8 +500,8 @@ public function testSearchCustomersMultipleFiltersWithSortUsingGET() $filter3 = $builder->setField(Customer::LASTNAME) ->setValue($customerData1[Customer::LASTNAME]) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter1, $filter2]); - $this->searchCriteriaBuilder->addFilter([$filter3]); + $this->searchCriteriaBuilder->addFilters([$filter1, $filter2]); + $this->searchCriteriaBuilder->addFilters([$filter3]); $this->searchCriteriaBuilder->setSortOrders([Customer::EMAIL => SearchCriteria::SORT_ASC]); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchData = $searchCriteria->__toArray(); @@ -536,8 +536,8 @@ public function testSearchCustomersNonExistentMultipleFilters() $filter3 = $builder->setField(Customer::LASTNAME) ->setValue('INVALID') ->create(); - $this->searchCriteriaBuilder->addFilter([$filter1, $filter2]); - $this->searchCriteriaBuilder->addFilter([$filter3]); + $this->searchCriteriaBuilder->addFilters([$filter1, $filter2]); + $this->searchCriteriaBuilder->addFilters([$filter3]); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchData = $searchCriteria->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -574,8 +574,8 @@ public function testSearchCustomersNonExistentMultipleFiltersGET() $filter3 = $builder->setField(Customer::LASTNAME) ->setValue('INVALID') ->create(); - $this->searchCriteriaBuilder->addFilter([$filter1, $filter2]); - $this->searchCriteriaBuilder->addFilter([$filter3]); + $this->searchCriteriaBuilder->addFilters([$filter1, $filter2]); + $this->searchCriteriaBuilder->addFilters([$filter3]); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchData = $searchCriteria->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -612,9 +612,9 @@ public function testSearchCustomersMultipleFilterGroups() ->setValue($customerData1[Customer::LASTNAME]) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter1]); - $this->searchCriteriaBuilder->addFilter([$filter2, $filter3]); - $this->searchCriteriaBuilder->addFilter([$filter4]); + $this->searchCriteriaBuilder->addFilters([$filter1]); + $this->searchCriteriaBuilder->addFilters([$filter2, $filter3]); + $this->searchCriteriaBuilder->addFilters([$filter4]); $searchCriteria = $this->searchCriteriaBuilder->setCurrentPage(1)->setPageSize(10)->create(); $searchData = $searchCriteria->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -638,9 +638,9 @@ public function testSearchCustomersMultipleFilterGroups() ->setValue('invalid') ->create(); - $this->searchCriteriaBuilder->addFilter([$filter1]); - $this->searchCriteriaBuilder->addFilter([$filter2, $filter3]); - $this->searchCriteriaBuilder->addFilter([$filter4]); + $this->searchCriteriaBuilder->addFilters([$filter1]); + $this->searchCriteriaBuilder->addFilters([$filter2, $filter3]); + $this->searchCriteriaBuilder->addFilters([$filter4]); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchData = $searchCriteria->__toArray(); $requestData = ['searchCriteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php index 722dfb6770135..d29db94ffc7c7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php @@ -921,13 +921,14 @@ public function testSearchGroupsDataProvider() public function testSearchGroups($filterField, $filterValue, $expectedResult) { $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); $filter = $filterBuilder ->setField($filterField) ->setValue($filterValue) ->create(); - $searchCriteriaBuilder->addFilter([$filter]); + $searchCriteriaBuilder->addFilters([$filter]); $searchData = $searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -968,13 +969,14 @@ public function testSearchGroupsWithGET($filterField, $filterValue, $expectedRes { $this->_markTestAsRestOnly('SOAP is covered in '); $filterBuilder = Bootstrap::getObjectManager()->create('Magento\Framework\Api\FilterBuilder'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); $filter = $filterBuilder ->setField($filterField) ->setValue($filterValue) ->create(); - $searchCriteriaBuilder->addFilter([$filter]); + $searchCriteriaBuilder->addFilters([$filter]); $searchData = $searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; $searchQueryString = http_build_query($requestData); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php index 9169ee6ca6ab6..7c9661e471e94 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php @@ -23,7 +23,7 @@ class CartRepositoryTest extends WebapiAbstract /** * @var SearchCriteriaBuilder */ - private $searchBuilder; + private $searchCriteriaBuilder; /** * @var SortOrderBuilder @@ -44,7 +44,7 @@ protected function setUp() $this->sortOrderBuilder = $this->objectManager->create( 'Magento\Framework\Api\SortOrderBuilder' ); - $this->searchBuilder = $this->objectManager->create( + $this->searchCriteriaBuilder = $this->objectManager->create( 'Magento\Framework\Api\SearchCriteriaBuilder' ); } @@ -174,13 +174,13 @@ public function testGetList() ->setValue($tomorrowDate) ->create(); - $this->searchBuilder->addFilter([$grandTotalFilter, $subtotalFilter]); - $this->searchBuilder->addFilter([$minCreatedAtFilter]); - $this->searchBuilder->addFilter([$maxCreatedAtFilter]); + $this->searchCriteriaBuilder->addFilters([$grandTotalFilter, $subtotalFilter]); + $this->searchCriteriaBuilder->addFilters([$minCreatedAtFilter]); + $this->searchCriteriaBuilder->addFilters([$maxCreatedAtFilter]); /** @var SortOrder $sortOrder */ $sortOrder = $this->sortOrderBuilder->setField('subtotal')->setDirection(SearchCriteria::SORT_ASC)->create(); - $this->searchBuilder->setSortOrders([$sortOrder]); - $searchCriteria = $this->searchBuilder->create()->__toArray(); + $this->searchCriteriaBuilder->setSortOrders([$sortOrder]); + $searchCriteria = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchCriteria]; $serviceInfo = [ @@ -233,8 +233,8 @@ public function testGetListThrowsExceptionIfProvidedSearchFieldIsInvalid() ->setValue(0) ->create(); - $this->searchBuilder->addFilter([$invalidFilter]); - $searchCriteria = $this->searchBuilder->create()->__toArray(); + $this->searchCriteriaBuilder->addFilters([$invalidFilter]); + $searchCriteria = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchCriteria]; $this->_webApiCall($serviceInfo, $requestData); } diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php index 1380a7251302f..463f06438b084 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php @@ -23,7 +23,7 @@ class CartTotalRepositoryTest extends WebapiAbstract /** * @var SearchCriteriaBuilder */ - private $searchBuilder; + private $searchCriteriaBuilder; /** * @var FilterBuilder @@ -33,7 +33,7 @@ class CartTotalRepositoryTest extends WebapiAbstract protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->searchBuilder = $this->objectManager->create( + $this->searchCriteriaBuilder = $this->objectManager->create( 'Magento\Framework\Api\SearchCriteriaBuilder' ); $this->filterBuilder = $this->objectManager->create( diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php index 85417b70b1673..2cc8193a06ece 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php @@ -23,7 +23,7 @@ class GuestCartTotalRepositoryTest extends WebapiAbstract /** * @var SearchCriteriaBuilder */ - private $searchBuilder; + private $searchCriteriaBuilder; /** * @var FilterBuilder @@ -33,7 +33,7 @@ class GuestCartTotalRepositoryTest extends WebapiAbstract protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->searchBuilder = $this->objectManager->create( + $this->searchCriteriaBuilder = $this->objectManager->create( 'Magento\Framework\Api\SearchCriteriaBuilder' ); $this->filterBuilder = $this->objectManager->create( diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php index 77eef801d6f19..d3216b9cf41c1 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoListTest.php @@ -58,7 +58,7 @@ public function testCreditmemoList() 'Magento\Framework\Api\FilterBuilder' ); - $searchCriteriaBuilder->addFilter( + $searchCriteriaBuilder->addFilters( [ $filterBuilder ->setField('state') diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php index b141daca7f67b..b529af4d554d2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceListTest.php @@ -43,7 +43,7 @@ public function testInvoiceList() 'Magento\Framework\Api\FilterBuilder' ); - $searchCriteriaBuilder->addFilter( + $searchCriteriaBuilder->addFilters( [ $filterBuilder ->setField('state') diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php index cd4e5f2256926..003ccfccf94e8 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderListTest.php @@ -44,7 +44,7 @@ public function testOrderList() 'Magento\Framework\Api\FilterBuilder' ); - $searchCriteriaBuilder->addFilter( + $searchCriteriaBuilder->addFilters( [ $filterBuilder ->setField('status') diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php index 8873212b5abf5..a06f22664920a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentListTest.php @@ -43,7 +43,7 @@ public function testShipmentList() 'Magento\Framework\Api\FilterBuilder' ); - $searchCriteriaBuilder->addFilter([$filterBuilder->setField('shipment_status')->setValue(1)->create()]); + $searchCriteriaBuilder->addFilters([$filterBuilder->setField('shipment_status')->setValue(1)->create()]); $searchData = $searchCriteriaBuilder->create()->__toArray(); $requestData = ['criteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php index ccf75d353d226..cbba01c42b788 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/TransactionTest.php @@ -105,7 +105,7 @@ public function testTransactionList($filters) 'Magento\Framework\Api\SearchCriteriaBuilder' ); - $searchCriteriaBuilder->addFilter($filters); + $searchCriteriaBuilder->addFilters($filters); $searchData = $searchCriteriaBuilder->create()->__toArray(); $requestData = ['criteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php index 2d20a4e911093..23457812903f6 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php @@ -225,7 +225,7 @@ public function testSearchTaxClass() $filter = $this->filterBuilder->setField($taxClassNameField) ->setValue($taxClassName) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $searchData = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; $serviceInfo = [ @@ -273,8 +273,8 @@ public function testSearchTaxClassMultipleFilterGroups() * (class_name == 'Retail Customer' || class_name == 'Taxable Goods) * && ( class_type == 'CUSTOMER' || class_type == 'PRODUCT') */ - $this->searchCriteriaBuilder->addFilter([$filter1, $filter2]); - $this->searchCriteriaBuilder->addFilter([$filter3, $filter4]); + $this->searchCriteriaBuilder->addFilters([$filter1, $filter2]); + $this->searchCriteriaBuilder->addFilters([$filter3, $filter4]); $searchCriteria = $this->searchCriteriaBuilder->setCurrentPage(1)->setPageSize(10)->create(); $searchData = $searchCriteria->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -301,8 +301,8 @@ public function testSearchTaxClassMultipleFilterGroups() ); /** class_name == 'Retail Customer' && ( class_type == 'CUSTOMER' || class_type == 'PRODUCT') */ - $this->searchCriteriaBuilder->addFilter([$filter2]); - $this->searchCriteriaBuilder->addFilter([$filter3, $filter4]); + $this->searchCriteriaBuilder->addFilters([$filter2]); + $this->searchCriteriaBuilder->addFilters([$filter3, $filter4]); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchData = $searchCriteria->__toArray(); $requestData = ['searchCriteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php index a140347e2498f..5b42630456d99 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php @@ -437,7 +437,7 @@ public function testSearchTaxRates() ->setValue('codeUs12') ->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $searchData = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; @@ -488,7 +488,7 @@ public function testSearchTaxRatesCz() ->setDirection(SearchCriteria::SORT_DESC) ->create(); // Order them by descending postcode (not the default order) - $this->searchCriteriaBuilder->addFilter([$filter]) + $this->searchCriteriaBuilder->addFilters([$filter]) ->addSortOrder($sortOrder); $searchData = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php index 50d6c9ccb8792..5fbb623eb16dd 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php @@ -269,7 +269,7 @@ public function testSearchTaxRulesSimple() ->setValue('Test Rule') ->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $fixtureRule = $this->getFixtureTaxRules()[1]; @@ -324,7 +324,7 @@ public function testSearchTaxRulesCodeLike() ->setValue(0) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter, $sortFilter]); + $this->searchCriteriaBuilder->addFilters([$filter, $sortFilter]); $fixtureRule = $this->getFixtureTaxRules()[1]; @@ -522,7 +522,7 @@ public function testSearchTaxRule() $filter = $this->filterBuilder->setField('code') ->setValue($fixtureRule->getCode()) ->create(); - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); $searchData = $this->searchCriteriaBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchData]; $serviceInfo = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php index 142283fa8ac35..0130fac8f341f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php @@ -89,7 +89,7 @@ public function testAutoGeneratedGetList() /** @var SortOrder $sortOrder */ $sortOrder = $this->sortOrderBuilder->setField('store_id')->setDirection(SearchCriteria::SORT_ASC)->create(); $this->searchBuilder->setSortOrders([$sortOrder]); - $this->searchBuilder->addFilter([$this->filterBuilder->setField('state')->setValue(2)->create()]); + $this->searchBuilder->addFilters([$this->filterBuilder->setField('state')->setValue(2)->create()]); $searchCriteria = $this->searchBuilder->create()->__toArray(); $requestData = ['criteria' => $searchCriteria]; diff --git a/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php index 438de55ed11d1..544874bba4701 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php @@ -306,10 +306,10 @@ public function testSearchAddresses($filters, $filterGroup, $expectedResult) /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */ $searchBuilder = $this->_objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); foreach ($filters as $filter) { - $searchBuilder->addFilter([$filter]); + $searchBuilder->addFilters([$filter]); } if ($filterGroup !== null) { - $searchBuilder->addFilter($filterGroup); + $searchBuilder->addFilters($filterGroup); } $searchResults = $this->repository->getList($searchBuilder->create()); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php index 9a6522e54c4c8..39c9f750d8ca2 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php @@ -100,7 +100,7 @@ public function testGetFormExistInCustomGroup() /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteria */ $searchCriteria = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder') - ->addFilter([$builder->setField('code')->setValue('custom_group')->create()]); + ->addFilters([$builder->setField('code')->setValue('custom_group')->create()]); /** @var GroupInterface $customerGroup */ $customerGroup = $this->groupRepository->getList($searchCriteria->create())->getItems()[0]; $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php index 9756119f36a7c..cf82e5dbc3451 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php @@ -85,7 +85,7 @@ public function testDeleteButtonExistInCustomGroup() /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteria */ $searchCriteria = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder') - ->addFilter([$builder->setField('code')->setValue('custom_group')->create()])->create(); + ->addFilters([$builder->setField('code')->setValue('custom_group')->create()])->create(); $customerGroup = $this->groupRepository->getList($searchCriteria)->getItems()[0]; $this->getRequest()->setParam('id', $customerGroup->getId()); $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php index 3c2e285709e08..a7fa061cad205 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php @@ -308,10 +308,10 @@ public function testSearchAddresses($filters, $filterGroup, $filterOrders, $expe /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */ $searchBuilder = $this->_objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); foreach ($filters as $filter) { - $searchBuilder->addFilter([$filter]); + $searchBuilder->addFilters([$filter]); } if ($filterGroup !== null) { - $searchBuilder->addFilter($filterGroup); + $searchBuilder->addFilters($filterGroup); } if ($filterOrders !== null) { foreach ($filterOrders as $order) { diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php index 4265207f0c644..e73d1a170b748 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php @@ -299,14 +299,14 @@ public function testUpdateCustomerDeleteAllAddressesWithEmptyArray() */ public function testSearchCustomers($filters, $filterGroup, $expectedResult) { - /** @var \Magento\Framework\Api\SearchCriteriBuilder $searchBuilder */ + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */ $searchBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); foreach ($filters as $filter) { - $searchBuilder->addFilter([$filter]); + $searchBuilder->addFilters([$filter]); } if ($filterGroup !== null) { - $searchBuilder->addFilter($filterGroup); + $searchBuilder->addFilters($filterGroup); } $searchResults = $this->customerRepository->getList($searchBuilder->create()); @@ -338,7 +338,7 @@ public function testSearchCustomersOrder() ->setConditionType('like') ->setValue('First%') ->create(); - $searchBuilder->addFilter([$firstnameFilter]); + $searchBuilder->addFilters([$firstnameFilter]); // Search ascending order $sortOrderBuilder = $objectManager->create('Magento\Framework\Api\SortOrderBuilder'); $sortOrder = $sortOrderBuilder diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php index 905a5a9affc1d..90480ef34222f 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php @@ -197,10 +197,10 @@ public function testGetAllGroups() public function testGetList($filters, $filterGroup, $expectedResult) { foreach ($filters as $filter) { - $this->searchCriteriaBuilder->addFilter([$filter]); + $this->searchCriteriaBuilder->addFilters([$filter]); } if ($filterGroup !== null) { - $this->searchCriteriaBuilder->addFilter($filterGroup); + $this->searchCriteriaBuilder->addFilters($filterGroup); } $searchResults = $this->groupRepository->getList($this->searchCriteriaBuilder->create()); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php index 10be075426201..7210b415ac2c9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php @@ -321,6 +321,7 @@ public function testGetListWithFilterBySimpleDummyAttributeWithMapping() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $groupRepository = $objectManager->create('Magento\Customer\Api\GroupRepositoryInterface'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = $objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); $builder = $objectManager->create('Magento\Framework\Api\FilterBuilder'); $joinedExtensionAttribute = 'test_dummy_attribute'; @@ -328,7 +329,7 @@ public function testGetListWithFilterBySimpleDummyAttributeWithMapping() $filter = $builder->setField($joinedExtensionAttribute) ->setValue($joinedExtensionAttributeValue) ->create(); - $searchCriteriaBuilder->addFilter([$filter]); + $searchCriteriaBuilder->addFilters([$filter]); $searchResults = $groupRepository->getList($searchCriteriaBuilder->create()); $items = $searchResults->getItems(); $this->assertCount(1, $items, 'Filtration by extension attribute does not work.'); @@ -346,6 +347,7 @@ public function testGetListWithFilterByComplexDummyAttributeWithSetterMapping() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $groupRepository = $objectManager->create('Magento\Customer\Api\GroupRepositoryInterface'); + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = $objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); $builder = $objectManager->create('Magento\Framework\Api\FilterBuilder'); $joinedExtensionAttribute = 'test_complex_dummy_attribute.frontend_label'; @@ -353,7 +355,7 @@ public function testGetListWithFilterByComplexDummyAttributeWithSetterMapping() $filter = $builder->setField($joinedExtensionAttribute) ->setValue($joinedExtensionAttributeValue) ->create(); - $searchCriteriaBuilder->addFilter([$filter]); + $searchCriteriaBuilder->addFilters([$filter]); $searchResults = $groupRepository->getList($searchCriteriaBuilder->create()); $items = $searchResults->getItems(); $this->assertCount(1, $items, 'Filtration by extension attribute does not work.'); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Calculation/RateRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Calculation/RateRepositoryTest.php index 2b0d311757846..18718f51da805 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Calculation/RateRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Calculation/RateRepositoryTest.php @@ -545,10 +545,10 @@ public function testGetList($filters, $filterGroup, $expectedRateCodes) $searchBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); foreach ($filters as $filter) { - $searchBuilder->addFilter([$filter]); + $searchBuilder->addFilters([$filter]); } if ($filterGroup !== null) { - $searchBuilder->addFilter($filterGroup); + $searchBuilder->addFilters($filterGroup); } $searchCriteria = $searchBuilder->create(); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxRuleRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxRuleRepositoryTest.php index 875c5ee5481ce..65fbcc7f23f72 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxRuleRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxRuleRepositoryTest.php @@ -300,10 +300,10 @@ public function testGetList($filters, $filterGroup, $expectedRuleCodes) $searchBuilder = Bootstrap::getObjectManager() ->create('Magento\Framework\Api\SearchCriteriaBuilder'); foreach ($filters as $filter) { - $searchBuilder->addFilter([$filter]); + $searchBuilder->addFilters([$filter]); } if ($filterGroup !== null) { - $searchBuilder->addFilter($filterGroup); + $searchBuilder->addFilters($filterGroup); } $searchCriteria = $searchBuilder->create(); diff --git a/lib/internal/Magento/Framework/Api/AbstractServiceCollection.php b/lib/internal/Magento/Framework/Api/AbstractServiceCollection.php index 08c81040594f5..06ebb9d08e76f 100644 --- a/lib/internal/Magento/Framework/Api/AbstractServiceCollection.php +++ b/lib/internal/Magento/Framework/Api/AbstractServiceCollection.php @@ -134,7 +134,7 @@ protected function getSearchCriteria() $filterGroup[] = $this->createFilterData($field, $filter['condition'][$index]); } } - $this->searchCriteriaBuilder->addFilter($filterGroup); + $this->searchCriteriaBuilder->addFilters($filterGroup); } foreach ($this->_orders as $field => $direction) { /** @var \Magento\Framework\Api\SortOrder $sortOrder */ diff --git a/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php b/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php index afc1dca15ffbf..48ffc8078d44f 100644 --- a/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php +++ b/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php @@ -52,7 +52,7 @@ public function addFilter(\Magento\Framework\Api\Filter $filter) * @param \Magento\Framework\Api\Filter[] $filters * @return $this */ - public function setFilters($filters) + public function setFilters(array $filters) { return $this->_set(FilterGroup::FILTERS, $filters); } diff --git a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php index faec4510efc5c..82c08f3e5cf8f 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php @@ -52,7 +52,7 @@ public function create() * @param \Magento\Framework\Api\Filter[] $filter * @return $this */ - public function addFilter(array $filter) + public function addFilters(array $filter) { $this->data[SearchCriteria::FILTER_GROUPS][] = $this->_filterGroupBuilder->setFilters($filter)->create(); return $this;