Пример #1
0
 protected function prepare()
 {
     $relativePath = '/custom_options/quote/file';
     $absolutePath = '/absolute/path' . $relativePath;
     $this->directoryRead->expects($this->once())->method('isFile')->with('/custom_options/quote/file')->willReturn(true);
     $this->directoryRead->expects($this->once())->method('getAbsolutePath')->with('/custom_options/quote/file')->willReturn($absolutePath);
     $this->validateFactory->expects($this->once())->method('create')->willReturn($this->zendValidator);
     $this->option->expects($this->once())->method('getImageSizeX')->willReturn(0);
     $this->option->expects($this->once())->method('getImageSizeY')->willReturn(0);
     $this->option->expects($this->once())->method('getFileExtension')->willReturn('');
     $this->scopeConfig->expects($this->once())->method('getValue')->with('catalog/custom_options/forbidden_extensions', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->willReturn('');
     $this->fileSize->expects($this->once())->method('getMaxFileSize')->willReturn(9999999);
     $this->zendValidator->expects($this->any())->method('addValidator');
     $this->zendValidator->expects($this->once())->method('isValid')->with($absolutePath)->willReturn(true);
 }
Пример #2
0
 public function testUploadJsFile()
 {
     $fileName = 'file.name';
     $this->_fileSizeMock->expects($this->once())->method('getMaxFileSize')->will($this->returnValue(600 * self::MB_MULTIPLIER));
     $this->_service = new \Magento\Theme\Model\Uploader\Service($this->_filesystemMock, $this->_fileSizeMock, $this->_uploaderFactory, ['js' => '500M']);
     $this->_directoryMock->expects($this->once())->method('getRelativePath')->with($fileName)->will($this->returnValue($fileName));
     $this->_directoryMock->expects($this->once())->method('readFile')->with($fileName)->will($this->returnValue('content'));
     $this->_uploader->expects($this->once())->method('validateFile')->will($this->returnValue(['name' => $fileName, 'tmp_name' => $fileName]));
     $this->_uploader->expects($this->once())->method('getFileSize')->will($this->returnValue('499'));
     $this->assertEquals(['content' => 'content', 'filename' => $fileName], $this->_service->uploadJsFile($fileName));
 }