public function testUploadFile() { $content = "testUploadFile\nline1\nline2\n"; $root = vfsstream::setup('root'); $url = vfsStream::newFile('test.txt')->withContent($content)->at($root)->url(); $uploader = $this->getMockBuilder('Library\\InventoryUploader')->disableOriginalConstructor()->setMethods(array('uploadData'))->getMock(); $uploader->expects($this->once())->method('uploadData')->with($content)->will($this->returnValue('response')); $this->assertEquals('response', $uploader->uploadFile($url)); }
public function testAutoArchiveUnsupportedPlatform() { $root = vfsstream::setup('root'); $source = vfsStream::newFile('source')->at($root)->url(); $data = array('FileLocation' => $source, 'FileName' => 'FileName', 'Platform' => 'linux'); $archiveManager = $this->createMock('Library\\ArchiveManager'); $archiveManager->expects($this->never())->method('isSupported'); $archiveManager->expects($this->never())->method('isArchive'); $archiveManager->expects($this->never())->method('createArchive'); $archiveManager->expects($this->never())->method('addFile'); $archiveManager->expects($this->never())->method('closeArchive'); $model = $this->_getModel(array('Library\\ArchiveManager' => $archiveManager)); $this->assertEquals($source, @$model->autoArchive($data, 'path', true)); $this->assertFileExists($source); }