Example #1
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return UploadFileInputFilter
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var OptionsHelper $optionsHelper */
     $optionsHelper = $serviceLocator->get('DmFileman\\Helper\\Options');
     $uploadFileFilter = new UploadFileInputFilter();
     $uploadFileFilter->setExtensions($optionsHelper->getExtensions());
     $uploadFileFilter->setMaxSize($optionsHelper->getMaxSize());
     return $uploadFileFilter;
 }
Example #2
0
 /**
  * @covers DmFileman\InputFilter\UploadFile
  */
 public function testRenameFilterIsSet()
 {
     $validatorChainMock = $this->getMockBuilder('Zend\\Validator\\ValidatorChain')->setMethods(['attachByName'])->disableOriginalConstructor()->getMock();
     $filterChainMock = $this->getMockBuilder('Zend\\Filter\\FilterChain')->setMethods(['attachByName'])->disableOriginalConstructor()->getMock();
     $fileInputMock = $this->getMockBuilder('Zend\\InputFilter\\FileInput')->setMethods(['getValidatorChain', 'getFilterChain', 'setName', 'setRequired'])->disableOriginalConstructor()->getMock();
     $fileInputMock->expects($this->never())->method('getValidatorChain')->will($this->returnValue($validatorChainMock));
     $validatorChainMock->expects($this->never())->method('attachByName')->will($this->returnValue($validatorChainMock));
     $fileInputMock->expects($this->exactly(1))->method('getFilterChain')->will($this->returnValue($filterChainMock));
     $filterChainMock->expects($this->exactly(1))->method('attachByName')->will($this->returnValue($filterChainMock));
     $this->sut->setFileInput($fileInputMock);
     $this->sut->setCurrentDir('');
     $this->sut->init();
 }