Ejemplo n.º 1
0
 public function isValid($data)
 {
     $ret = parent::isValid($data);
     if ($this->getElement('title') && !$this->getElement('title')->hasErrors()) {
         $fileExistsValidator = new Zend_Validate_File_NotExists();
         $fileExistsValidator->setDirectory(UPLOAD_PATH . DIRECTORY_SEPARATOR . 'static')->setMessage('cms_form_error_title_exists');
         if (!$fileExistsValidator->isValid($data['title'] . '.html')) {
             $this->getElement('title')->addErrors($fileExistsValidator->getMessages());
             $ret = false;
         }
     }
     return $ret;
 }
Ejemplo n.º 2
0
 /**
  * Ensures that addDirectory() returns expected value
  *
  * @return void
  */
 public function testAddDirectory()
 {
     $validator = new Zend_Validate_File_NotExists('temp');
     $validator->addDirectory('gif');
     $this->assertEquals('temp,gif', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif'), $validator->getDirectory(true));
     $validator->addDirectory('jpg, to');
     $this->assertEquals('temp,gif,jpg,to', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif', 'jpg', 'to'), $validator->getDirectory(true));
     $validator->addDirectory(array('zip', 'ti'));
     $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true));
     $validator->addDirectory('');
     $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true));
 }