public function testMoveFileName() { $fileName = 'test_uploader_file'; $expectedRelativeFilePath = $this->uploader->getTmpDir() . '/' . $fileName; $this->directoryMock->expects($this->any())->method('getRelativePath')->with($expectedRelativeFilePath); $uploaderMock = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Uploader')->setConstructorArgs([$this->coreFileStorageDb, $this->coreFileStorage, $this->imageFactory, $this->validator, $this->filesystem, $this->readFactory])->setMethods(['_setUploadFile', 'save', 'getTmpDir'])->getMock(); //Check invoking of getTmpDir(), _setUploadFile(), save() methods. $uploaderMock->expects($this->once())->method('getTmpDir')->will($this->returnValue('')); $uploaderMock->expects($this->once())->method('_setUploadFile')->will($this->returnSelf()); $uploaderMock->expects($this->once())->method('save')->will($this->returnValue(['name' => null])); $uploaderMock->move($fileName); }
/** * Tests if getting just the tmp directory works * * @return null */ public function testGetTmpDirNothingToAppend() { $mockHost = $this->getMockBuilder('\\AppserverIo\\Appserver\\Core\\Api\\Node\\HostNodeInterface')->setMethods(get_class_methods('\\AppserverIo\\Appserver\\Core\\Api\\Node\\HostNodeInterface'))->getMock(); $mockHost->expects($this->once())->method('getTmpBase')->willReturn('var/tmp'); $mockContainer = $this->getMockBuilder('\\AppserverIo\\Appserver\\Core\\Api\\Node\\ContainerNodeInterface')->setMethods(get_class_methods('\\AppserverIo\\Appserver\\Core\\Api\\Node\\ContainerNodeInterface'))->getMock(); $mockContainer->expects($this->once())->method('getHost')->willReturn($mockHost); $tmpDir = $this->service->getTmpDir($mockContainer); $this->assertEquals('/opt/appserver/var/tmp', $tmpDir); $this->assertNotEquals('/opt/appserver/var/tmp/test/directory', $tmpDir); }
public function testGetTmpDir() { $this->assertEquals(self::$_tmpDir, $this->_bootstrap->getTmpDir()); }
/** * Tests if getting just the tmp directory works * * @return null */ public function testGetTmpDirNothingToAppend() { $tmpDir = $this->service->getTmpDir(); $this->assertEquals('/opt/appserver/var/tmp', $tmpDir); $this->assertNotEquals('/opt/appserver/var/tmp/test/directory', $tmpDir); }