/**
  * Ensures that setImageHeight() returns expected value
  *
  * @return void
  */
 public function testSetImageHeight()
 {
     $validator = new Zend_Validate_File_ImageSize(array('minwidth' => 100, 'minheight' => 1000, 'maxwidth' => 10000, 'maxheight' => 100000));
     $validator->setImageHeight(array('minheight' => 2000, 'maxheight' => 2200));
     $this->assertEquals(array('minheight' => 2000, 'maxheight' => 2200), $validator->getImageHeight());
     try {
         $validator->setImageHeight(array('minheight' => 20000, 'maxheight' => 200));
         $this->fail("Missing exception");
     } catch (Zend_Validate_Exception $e) {
         $this->assertContains("less than or equal", $e->getMessage());
     }
 }
Exemplo n.º 2
0
 /**
  *
  * @param type $minHeight
  * @param type $maxHeight
  * @param type $minWidth
  * @param type $maxWidth
  * @param type $messages_prefixed
  * @return \Zend_Validate_File_ImageSize 
  */
 protected function _getValidateImageSize($minHeight = 40, $maxHeight = 320, $minWidth = 40, $maxWidth = 800, $messages_prefixed = "")
 {
     $image = new Zend_Validate_File_ImageSize(array('minHeight' => $minHeight, 'maxHeight' => $maxHeight, 'minWidth' => $minWidth, 'maxWidth' => $maxWidth));
     $image->setMessage(sprintf($this->_translate('ERROR_IMAGE_HEIGHT_TOO_SMALL'), $this->_translate($messages_prefixed), $minHeight), Zend_Validate_File_ImageSize::HEIGHT_TOO_SMALL);
     $image->setMessage(sprintf($this->_translate('ERROR_IMAGE_HEIGHT_TOO_BIG'), $this->_translate($messages_prefixed), $maxHeight), Zend_Validate_File_ImageSize::HEIGHT_TOO_BIG);
     $image->setMessage(sprintf($this->_translate('ERROR_IMAGE_WIDTH_TO_SMALL'), $this->_translate($messages_prefixed), $minWidth), Zend_Validate_File_ImageSize::WIDTH_TOO_SMALL);
     $image->setMessage(sprintf($this->_translate('ERROR_IMAGE_WIDTH_TO_BIG'), $this->_translate($messages_prefixed), $maxWidth), Zend_Validate_File_ImageSize::WIDTH_TOO_BIG);
     return $image;
 }