/** * @return void */ public function testValidate() { $validateMock = $this->getMock('Zend_Validate', ['isValid']); $validateMock->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->validateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($validateMock)); $this->assertTrue($this->model->validate($this->getOptionValue(), $this->getProductOption())); }
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); }