/** * Validation of given Mail Params * * @param \In2code\Powermail\Domain\Model\Mail $mail * @return bool */ public function isValid($mail) { foreach ($mail->getAnswers() as $answer) { if ($answer->getValueType() === 3) { if (!is_array($answer->getValue())) { continue; } foreach ($answer->getValue() as $value) { if (!BasicFileUtility::checkExtension($value, $this->settings['misc.']['file.']['extension'])) { $this->setErrorAndMessage($answer->getField(), 'upload_extension'); continue; } if (!BasicFileUtility::checkFilesize($value, $this->settings)) { $this->setErrorAndMessage($answer->getField(), 'upload_size'); continue; } } } } return $this->isValidState(); }
/** * checkExtensionReturnBool Test * * @param string $filename * @param string $allowedFileExtensions * @param string $expectedResult * @dataProvider checkExtensionReturnBoolDataProvider * @return void * @test */ public function checkExtensionReturnBool($filename, $allowedFileExtensions, $expectedResult) { $result = BasicFileUtility::checkExtension($filename, $allowedFileExtensions); $this->assertSame($expectedResult, $result); }