/**
  * Find entities by criteria
  *
  * @param SearchCriteria $searchCriteria
  * @return OrderItemInterface[]
  */
 public function getList(SearchCriteria $searchCriteria)
 {
     /** @var OrderItemSearchResultInterface $searchResult */
     $searchResult = $this->searchResultFactory->create();
     $searchResult->setSearchCriteria($searchCriteria);
     foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
         foreach ($filterGroup->getFilters() as $filter) {
             $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
             $searchResult->addFieldToFilter($filter->getField(), [$condition => $filter->getValue()]);
         }
     }
     /** @var OrderItemInterface $orderItem */
     foreach ($searchResult->getItems() as $orderItem) {
         $this->addProductOption($orderItem);
     }
     return $searchResult;
 }
 public function testGetList()
 {
     $productType = 'configurable';
     $field = 'field';
     $value = 'value';
     $this->productOptionData = ['option1' => 'value1'];
     $filterMock = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->disableOriginalConstructor()->getMock();
     $filterMock->expects($this->once())->method('getConditionType')->willReturn(null);
     $filterMock->expects($this->once())->method('getField')->willReturn($field);
     $filterMock->expects($this->once())->method('getValue')->willReturn($value);
     $filterGroupMock = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\FilterGroup')->disableOriginalConstructor()->getMock();
     $filterGroupMock->expects($this->once())->method('getFilters')->willReturn([$filterMock]);
     $searchCriteriaMock = $this->getMockBuilder('Magento\\Framework\\Api\\SearchCriteria')->disableOriginalConstructor()->getMock();
     $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]);
     $this->getProductOptionExtensionMock();
     $productOption = $this->getProductOptionMock();
     $orderItemMock = $this->getOrderMock($productType, $productOption);
     $searchResultMock = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderItemSearchResultInterface')->setMethods(['addFieldToFilter', 'getItems'])->getMockForAbstractClass();
     $searchResultMock->expects($this->once())->method('addFieldToFilter')->with($field, ['eq' => $value])->willReturnSelf();
     $searchResultMock->expects($this->once())->method('getItems')->willReturn([$orderItemMock]);
     $this->searchResultFactory->expects($this->once())->method('create')->willReturn($searchResultMock);
     $model = $this->getModel($orderItemMock, $productType);
     $this->assertSame($searchResultMock, $model->getList($searchCriteriaMock));
 }