/** * @param bool|int $expected * @param int $storage * @param int $callNum * @param int $callSaveFileNum * @param int $fileId * @dataProvider processStorageFileDataProvider */ public function testProcessStorageFile($expected, $storage, $callNum, $callSaveFileNum, $fileId = null) { $this->configMock->expects($this->once())->method('getValue')->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default')->will($this->returnValue($storage)); $filename = 'filename'; $relativePath = 'relativePath'; $this->coreFileStorageDbMock->expects($this->exactly($callNum))->method('getMediaRelativePath')->with($filename)->will($this->returnValue($relativePath)); $storageModelMock = $this->getMockBuilder('Magento\\Framework\\Model\\AbstractModel')->disableOriginalConstructor()->setMethods(['loadByFileName', '__wakeup'])->getMock(); $this->storageMock->expects($this->exactly($callNum))->method('getStorageModel')->will($this->returnValue($storageModelMock)); $fileMock = $this->getMockBuilder('Magento\\MediaStorage\\Model\\File\\Storage\\Database')->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock(); $storageModelMock->expects($this->exactly($callNum))->method('loadByFilename')->with($relativePath)->will($this->returnValue($fileMock)); $fileMock->expects($this->exactly($callNum))->method('getId')->will($this->returnValue($fileId)); $this->filesystemStorageMock->expects($this->exactly($callSaveFileNum))->method('saveFile')->with($fileMock, true)->will($this->returnValue(1)); $this->assertEquals($expected, $this->helper->processStorageFile($filename)); }