public function testGetStock()
 {
     $this->stockCriteriaFactory->expects($this->once())->method('create')->willReturn($this->stockCriteria);
     $this->stockCriteria->expects($this->once())->method('setScopeFilter')->willReturn(null);
     $stockCollection = $this->getMock('\\Magento\\CatalogInventory\\Model\\ResourceModel\\Stock\\Collection', ['getFirstItem', '__wakeup', 'getItems'], [], '', false);
     $stockCollection->expects($this->once())->method('getItems')->willReturn([$this->stock]);
     $this->stockRepository->expects($this->once())->method('getList')->willReturn($stockCollection);
     $this->stock->expects($this->once())->method('getStockId')->willReturn(true);
     $this->assertEquals($this->stock, $this->stockRegistryProvider->getStock($this->scopeId));
 }
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Invalid stock item id: 35. Assigned stock item id is 40
  */
 public function testAroundSaveWithNotAssignedStockItemId()
 {
     $stockId = 80;
     $stockItemId = 35;
     $defaultScopeId = 100;
     $defaultStockId = 80;
     $storedStockitemId = 40;
     $this->stockItem->expects($this->once())->method('getStockId')->willReturn($stockId);
     $this->stockRegistry->expects($this->once())->method('getStock')->with($defaultScopeId)->willReturn($this->defaultStock);
     $this->stockConfiguration->expects($this->once())->method('getDefaultScopeId')->willReturn($defaultScopeId);
     $this->defaultStock->expects($this->once())->method('getStockId')->willReturn($defaultStockId);
     $this->product->expects($this->once())->method('getExtensionAttributes')->willReturn($this->productExtension);
     $this->productExtension->expects($this->once())->method('getStockItem')->willReturn($this->stockItem);
     $this->stockItem->expects($this->once())->method('getItemId')->willReturn($stockItemId);
     $storedStockItem = $this->getMockBuilder(StockItemInterface::class)->setMethods(['getItemId'])->getMockForAbstractClass();
     $storedStockItem->expects($this->once())->method('getItemId')->willReturn($storedStockitemId);
     $this->stockRegistry->expects($this->once())->method('getStockItem')->willReturn($storedStockItem);
     $this->plugin->aroundSave($this->productRepository, $this->closure, $this->product);
 }