/** * @test */ public function addFileFailsIfFileDoesNotExist() { $mockedFolder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array(), array(), '', FALSE); $this->setExpectedException('InvalidArgumentException', '', 1319552745); $this->prepareFixture(array()); $this->fixture->addFile('/some/random/file', $mockedFolder); }
/** * @test */ public function addFileFailsIfFileDoesNotExist() { /** @var Folder|\PHPUnit_Framework_MockObject_MockObject $mockedFolder */ $mockedFolder = $this->getMock(Folder::class, array(), array(), '', false); $this->setExpectedException('InvalidArgumentException', '', 1319552745); $this->prepareSubject(array()); $this->subject->addFile('/some/random/file', $mockedFolder); }
/** * @test */ public function addFileChangesFilenameIfFileExists() { $mockedFolder = $this->getSimpleFolderMock('/'); $this->addToMount(array('targetFolder' => array('file.ext' => 'asdf', 'file_01.ext' => 'asjdlkajs'), 'file.ext' => 'ajslkd')); $this->initializeVfs(); $this->prepareFixture(array()); /** @var $driver \TYPO3\CMS\Core\Resource\Driver\LocalDriver */ $driver = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Driver\\LocalDriver', array('addFile', 'fileExistsInFolder'), array(array('basePath' => $this->getUrlInMount('targetFolder/')))); $driver->expects($this->once())->method('addFile')->with($this->anything(), $this->anything(), $this->equalTo('file_02.ext')); $driver->expects($this->exactly(3))->method('fileExistsInFolder')->will($this->onConsecutiveCalls($this->returnValue(TRUE), $this->returnValue(TRUE), $this->returnValue(FALSE))); $this->fixture->setDriver($driver); $this->fixture->addFile($this->getUrlInMount('file.ext'), $mockedFolder); }
/** * Adds a file from the local server disk. If the file already exists and * overwriting is disabled, * * @param string $localFilePath * @param string $fileName * @param string $conflictMode possible value are 'cancel', 'replace', 'changeName' * @return File The file object */ public function addFile($localFilePath, $fileName = NULL, $conflictMode = 'cancel') { $fileName = $fileName ? $fileName : PathUtility::basename($localFilePath); return $this->storage->addFile($localFilePath, $this, $fileName, $conflictMode); }
/** * Adds a file from the local server disk. If the file already exists and * overwriting is disabled, * * @param string $localFilePath * @param string $fileName * @param string $conflictMode a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration * @return File The file object */ public function addFile($localFilePath, $fileName = null, $conflictMode = DuplicationBehavior::CANCEL) { $fileName = $fileName ? $fileName : PathUtility::basename($localFilePath); return $this->storage->addFile($localFilePath, $this, $fileName, $conflictMode); }