Ejemplo n.º 1
0
 public function testGetList()
 {
     $criteriaMock = $this->getMockBuilder('Magento\\CatalogInventory\\Api\\StockItemCriteriaInterface')->getMock();
     $queryBuilderMock = $this->getMockBuilder('Magento\\Framework\\DB\\QueryBuilder')->disableOriginalConstructor()->setMethods(['setCriteria', 'setResource', 'create'])->getMock();
     $queryMock = $this->getMockBuilder('Magento\\Framework\\DB\\QueryInterface')->getMock();
     $queryCollectionMock = $this->getMockBuilder('Magento\\CatalogInventory\\Api\\Data\\StockItemCollectionInterface')->getMock();
     $this->queryBuilderFactoryMock->expects($this->once())->method('create')->willReturn($queryBuilderMock);
     $queryBuilderMock->expects($this->once())->method('setCriteria')->with($criteriaMock)->willReturnSelf();
     $queryBuilderMock->expects($this->once())->method('setResource')->with($this->stockItemResourceMock)->willReturnSelf();
     $queryBuilderMock->expects($this->once())->method('create')->willReturn($queryMock);
     $this->stockItemCollectionMock->expects($this->once())->method('create')->willReturn($queryCollectionMock);
     $this->assertEquals($queryCollectionMock, $this->model->getList($criteriaMock));
 }