Ejemplo n.º 1
0
 /**
  * Testing the getValue method.
  *
  * @since 1.0
  */
 public function testGetValue()
 {
     $enum = new Enum();
     $enum->setOptions(array('a', 'b', 'c'));
     try {
         $enum->setValue('b');
     } catch (IllegalArguementException $e) {
         $this->fail('testing the getValue method');
     }
     $this->assertEquals('b', $enum->getValue(), 'testing the getValue method');
 }
Ejemplo n.º 2
0
 /**
  * The constructor.
  *
  * @param $source
  * @param $width
  * @param $height
  * @param $sourceType
  * @param $quality
  * @param $scale
  *
  * @throws Alpha\Exception\IllegalArguementException
  *
  * @since 1.0
  */
 public function __construct($source, $width, $height, $sourceType, $quality = 0.75, $scale = false, $secure = false)
 {
     self::$logger = new Logger('Image');
     self::$logger->debug('>>__construct(source=[' . $source . '], width=[' . $width . '], height=[' . $height . '], sourceType=[' . $sourceType . '], quality=[' . $quality . '], scale=[' . $scale . '], secure=[' . $secure . '])');
     $config = ConfigProvider::getInstance();
     if (file_exists($source)) {
         $this->source = $source;
     } else {
         throw new IllegalArguementException('The source file for the Image widget [' . $source . '] cannot be found!');
     }
     $this->sourceType = new Enum();
     $this->sourceType->setOptions(array('jpg', 'png', 'gif'));
     $this->sourceType->setValue($sourceType);
     if ($quality < 0.0 || $quality > 1.0) {
         throw new IllegalArguementException('The quality setting of [' . $quality . '] is outside of the allowable range of 0.0 to 1.0');
     }
     $this->quality = new Double($quality);
     $this->scale = new Boolean($scale);
     $this->secure = new Boolean($secure);
     $this->width = new Integer($width);
     $this->height = new Integer($height);
     $this->setFilename();
     self::$logger->debug('<<__construct');
 }