public function testGetStockStatus()
 {
     $this->stockStatusCriteriaFactory->expects($this->once())->method('create')->willReturn($this->stockStatusCriteria);
     $this->stockStatusCriteria->expects($this->once())->method('setScopeFilter')->willReturn(null);
     $this->stockStatusCriteria->expects($this->once())->method('setProductsFilter')->willReturn(null);
     $stockStatusCollection = $this->getMock('\\Magento\\CatalogInventory\\Model\\ResourceModel\\Stock\\Status\\Collection', ['getFirstItem', '__wakeup', 'getItems'], [], '', false);
     $stockStatusCollection->expects($this->once())->method('getItems')->willReturn([$this->stockStatus]);
     $this->stockStatusRepository->expects($this->once())->method('getList')->willReturn($stockStatusCollection);
     $this->stockStatus->expects($this->once())->method('getProductId')->willReturn($this->productId);
     $this->assertEquals($this->stockStatus, $this->stockRegistryProvider->getStockStatus($this->productId, $this->scopeId));
 }
 /**
  * @param int $productId
  * @param int $scopeId
  * @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
  */
 public function getStockStatus($productId, $scopeId)
 {
     $key = $scopeId . '/' . $productId;
     if (!isset($this->stockStatuses[$key])) {
         $criteria = $this->stockStatusCriteriaFactory->create();
         $criteria->setProductsFilter($productId);
         $criteria->setScopeFilter($scopeId);
         $collection = $this->stockStatusRepository->getList($criteria);
         $stockStatus = current($collection->getItems());
         if ($stockStatus && $stockStatus->getProductId()) {
             $this->stockStatuses[$key] = $stockStatus;
         } else {
             return $this->stockStatusFactory->create();
         }
     }
     return $this->stockStatuses[$key];
 }
 /**
  * @param int $productId
  * @param int $scopeId
  * @return \Magento\CatalogInventory\Api\Data\StockStatusInterface
  */
 public function getStockStatus($productId, $scopeId)
 {
     $stockStatus = $this->stockRegistryStorage->getStockStatus($productId, $scopeId);
     if (null === $stockStatus) {
         $criteria = $this->stockStatusCriteriaFactory->create();
         $criteria->setProductsFilter($productId);
         $criteria->setScopeFilter($scopeId);
         $collection = $this->stockStatusRepository->getList($criteria);
         $stockStatus = current($collection->getItems());
         if ($stockStatus && $stockStatus->getProductId()) {
             $this->stockRegistryStorage->setStockStatus($productId, $scopeId, $stockStatus);
         } else {
             $stockStatus = $this->stockStatusFactory->create();
         }
     }
     return $stockStatus;
 }