/** * @covers DmFileman\InputFilter\UploadFile */ public function testFileValidatorSAreSet() { $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'])->disableOriginalConstructor()->getMock(); $fileInputMock->expects($this->exactly(2))->method('getValidatorChain')->will($this->returnValue($validatorChainMock)); $validatorChainMock->expects($this->exactly(2))->method('attachByName')->will($this->returnValue($validatorChainMock)); $fileInputMock->expects($this->never())->method('getFilterChain')->will($this->returnValue($filterChainMock)); $filterChainMock->expects($this->never())->method('attachByName')->will($this->returnValue($filterChainMock)); $this->sut->setFileInput($fileInputMock); $this->sut->setMaxSize(1000); $this->sut->setExtensions(['jpg']); $this->sut->init(); }
/** * @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; }